mirror of
git://git.openembedded.org/meta-openembedded
synced 2026-08-17 02:38:28 +00:00
While hostname is numeric, start postfix failed ... root@qemux86-64:~# hostname 1.2.3.4 root@qemux86-64:~# systemctl restart postfix |Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details. root@qemux86-64:~# systemctl status postfix -l Dec 02 08:05:40 1.2.3.4 aliasesdb[535]: /usr/sbin/postconf: fatal: unable to use my own hostname Dec 02 08:05:41 1.2.3.4 aliasesdb[535]: newaliases: warning: valid_hostname: numeric hostname: 1.2.3.4 Dec 02 08:05:41 1.2.3.4 postfix/sendmail[537]: warning: valid_hostname: numeric hostname: 1.2.3.4 Dec 02 08:05:41 1.2.3.4 aliasesdb[535]: newaliases: fatal: unable to use my own hostname Dec 02 08:05:42 1.2.3.4 postfix[540]: warning: valid_hostname: numeric hostname: 1.2.3.4 Dec 02 08:05:42 1.2.3.4 postfix[540]: fatal: unable to use my own hostname ... Refer meta/recipes-core/initscripts/initscripts-1.0/hostname.sh in oe-core, add check_hostname.sh and invoke it before postfix start, if the hostname is invalid, set "localhost" to main.cf. Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
95 lines
1.9 KiB
Bash
Executable File
95 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
### BEGIN INIT INFO
|
|
# Provides: postfix MTA
|
|
# Default-Start: 2345
|
|
# Default-Stop: 016
|
|
# Short-Description: start and stop postfix
|
|
# Description: Postfix is a Mail Transport Agent, which is the program
|
|
# that moves mail from one machine to another.
|
|
### END INIT INFO
|
|
|
|
success() {
|
|
echo " Successful"
|
|
exit 0
|
|
}
|
|
|
|
fail() {
|
|
echo " Failed"
|
|
exit 1
|
|
|
|
}
|
|
|
|
check_return () {
|
|
local ret="$1"
|
|
|
|
if [ "$ret" = "0" ]; then
|
|
success
|
|
else
|
|
fail
|
|
fi
|
|
}
|
|
|
|
PIDFile=/var/spool/postfix/pid/master.pid
|
|
case "$1" in
|
|
|
|
start)
|
|
echo -n "Starting Postfix..."
|
|
if [ ! -e /etc/aliases.db ]; then
|
|
# The alias database is necessary for postfix to work correctly.
|
|
echo "Creating aliases database ..."
|
|
newaliases
|
|
fi
|
|
if ! postfix status >/dev/null 2>&1; then
|
|
/usr/sbin/check_hostname.sh
|
|
postfix start
|
|
check_return $?
|
|
else
|
|
success
|
|
fi
|
|
;;
|
|
|
|
stop)
|
|
echo -n "Stopping Postfix..."
|
|
if postfix status >/dev/null 2>&1; then
|
|
postfix stop
|
|
check_return $?
|
|
else
|
|
success
|
|
fi
|
|
;;
|
|
|
|
reload)
|
|
echo -n "Reloading Postfix..."
|
|
if postfix status >/dev/null 2>&1; then
|
|
postfix reload
|
|
check_return $?
|
|
else
|
|
postfix start
|
|
check_return $?
|
|
fi
|
|
;;
|
|
|
|
restart)
|
|
$0 stop
|
|
sleep 1
|
|
$0 start
|
|
;;
|
|
|
|
status)
|
|
if postfix status >/dev/null 2>&1; then
|
|
pid=`sed -e 's/\s//g' $PIDFile`
|
|
echo "The Postfix mail system is running (PID: $pid)"
|
|
exit 0
|
|
else
|
|
echo "The Postfix mail system is not running"
|
|
exit 1
|
|
fi
|
|
;;
|
|
|
|
*)
|
|
echo "Usage: $0 {start|stop|status|reload|restart}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|