X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=postfix.init;h=fe1a1a61801212e94118cd5e6c27804c691eb343;hb=2cebff6628851de03dd7c6e50efdede26377f9d5;hp=dd9f1d42a4b9f4efad4770c0fc085ab171e68502;hpb=ceec68da17696916773136a8ae4dc02503b08a31;p=packages%2Fpostfix.git diff --git a/postfix.init b/postfix.init index dd9f1d4..fe1a1a6 100644 --- a/postfix.init +++ b/postfix.init @@ -3,9 +3,9 @@ # postfix This shell script takes care of starting and stopping # postfix. # -# chkconfig: 345 80 30 +# chkconfig: 345 80 20 # -# description: Postfix is a Mail Transport Agent, which is the program +# description: Postfix is a Mail Transport Agent, which is the program \ # that moves mail from one machine to another. @@ -19,85 +19,116 @@ [ -f /etc/sysconfig/postfix ] && . /etc/sysconfig/postfix # Check that networking is up. -if is_yes "${NETWORKING}"; then - if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then - msg_network_down Postfix - exit 1 +networking_check() { + if is_yes "${NETWORKING}"; then + if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then + msg_network_down "Postfix" + exit 1 + fi + else + exit 0 fi -else - exit 0 -fi +} + +start() { + local msg -RETVAL=0 -# See how we were called. -case "$1" in - start) - # Check if the service is already running? if [ ! -f /var/lock/subsys/postfix ]; then - msg_starting Postfix + msg_starting "Postfix" busy - MSG="`/usr/sbin/postfix start 2>&1`" - if [ $? -eq 0 ]; then + msg=$(nice -n ${SERVICE_RUN_NICE_LEVEL:-${DEFAULT_SERVICE_RUN_NICE_LEVEL:-0}} /usr/sbin/postfix start 2>&1) + RETVAL=$? + if [ $RETVAL -eq 0 ]; then ok touch /var/lock/subsys/postfix else - RETVAL=1 fail - echo "$MSG" + echo >&2 "$msg" fi else - msg_already_running Postfix + msg_already_running "Postfix" fi - ;; - stop) - # Stop daemons. +} + +stop() { + local msg if [ -f /var/lock/subsys/postfix ]; then - msg_stopping Postfix + msg_stopping "Postfix" busy - MSG="`/usr/sbin/postfix stop 2>&1`" + msg=$(/usr/sbin/postfix stop 2>&1) if [ $? -eq 0 ]; then ok else fail - echo "$MSG" + echo >&2 "$msg" fi rm -f /var/lock/subsys/postfix else - msg_not_running Postfix + msg_not_running "Postfix" fi - ;; - restart) - $0 stop - $0 start - exit $? - ;; - reload|force-reload) +} + +reload() { + local msg if [ -f /var/lock/subsys/postfix ]; then - msg_reloading Postfix + msg_reloading "Postfix" busy - /usr/sbin/postfix reload + msg=$(/usr/sbin/postfix reload 2>&1) RETVAL=$? - [ $RETVAL -ne 0 ] && RETVAL=7 - [ $RETVAL -eq 0 ] && ok || died + if [ $RETVAL -eq 0 ]; then + ok + else + fail + echo >&2 "$msg" + RETVAL=7 + fi else - msg_not_running Postfix >&2 - exit 7 + msg_not_running "Postfix" + RETVAL=7 fi +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + networking_check + start ;; - status) - status master - exit $? + stop) + stop + ;; + restart) + networking_check + stop + start + ;; + reload|force-reload) + networking_check + reload ;; rebuilddb) standard_db="access canonical relocated transport virtual" - extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | grep -v aliases.db | sed -e 's#.db$##') + extra_db=$(ls -1 /etc/mail/*.db 2> /dev/null | egrep -v '/(access|canonical|relocated|transport|virtual|aliases)\.db$') + + echo -n "Rebuilding databases: " for base in $standard_db $extra_db; do - I=$(basename "$base") - if [ -f /etc/mail/$I ]; then - /usr/sbin/postmap hash:/etc/mail/$I < /etc/mail/$I + db=$(basename "$base" .db) + + if [ -f /etc/mail/$db ]; then + echo -n "$db " + /usr/sbin/postmap hash:/etc/mail/$db < /etc/mail/$db fi done + echo "...DONE" + + echo -n "Rebuilding aliases database" /usr/bin/newaliases + echo "...DONE" + ;; + status) + status master + exit $? ;; *) msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}"