X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=postfix.init;h=10671edc7f84a05366fc0f25f22b123bc9c198b5;hb=53387d60d7fad4759ea1a2e10fb5780cbd82b9b2;hp=8378d7d5f13ada62a4646e3d73a67541ed3a84d0;hpb=a281e39716dbe49f248aeb6268ccd5af60ff3f4f;p=packages%2Fpostfix.git diff --git a/postfix.init b/postfix.init index 8378d7d..10671ed 100644 --- a/postfix.init +++ b/postfix.init @@ -1,70 +1,105 @@ #!/bin/sh # -# postfix This shell script takes care of starting and stopping -# postfix. +# postfix This shell script takes care of starting and stopping +# postfix. # -# chkconfig: 2345 80 30 -# description: Postfix is a Mail Transport Agent, which is the program -# that moves mail from one machine to another. +# chkconfig: 345 80 30 +# +# description: Postfix is a Mail Transport Agent, which is the program \ +# that moves mail from one machine to another. + -# Source function library. +# Source function library . /etc/rc.d/init.d/functions -# Source networking configuration. +# Get network config . /etc/sysconfig/network -# Check that networking is up. -[ "${NETWORKING}" = "no" ] && exit 0 +# Get service config +[ -f /etc/sysconfig/postfix ] && . /etc/sysconfig/postfix -[ -f /usr/sbin/postfix ] || exit 0 +# 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 + fi +else + exit 0 +fi +RETVAL=0 # See how we were called. case "$1" in start) - # Start daemons. - show "Starting postfix: " - busy - newaliases - $0 rebuilddb - if /usr/sbin/postfix start 2>/dev/null; then - deltext; ok + # Check if the service is already running? + if [ ! -f /var/lock/subsys/postfix ]; then + msg_starting Postfix + busy + MSG="`/usr/sbin/postfix start 2>&1`" + if [ $? -eq 0 ]; then + ok + touch /var/lock/subsys/postfix + else + RETVAL=1 + fail + echo "$MSG" + fi else - deltext;fail + msg_already_running Postfix fi - touch /var/lock/subsys/postfix ;; stop) # Stop daemons. - show "Shutting down postfix: " - busy - if /usr/sbin/postfix stop 2>/dev/null; then - deltext; ok + if [ -f /var/lock/subsys/postfix ]; then + msg_stopping Postfix + busy + MSG="`/usr/sbin/postfix stop 2>&1`" + if [ $? -eq 0 ]; then + ok + else + fail + echo "$MSG" + fi + rm -f /var/lock/subsys/postfix else - deltext; fail + msg_not_running Postfix fi - rm -f /var/lock/subsys/postfix ;; restart) $0 stop $0 start + exit $? ;; - reload) - /usr/sbin/postfix reload + reload|force-reload) + if [ -f /var/lock/subsys/postfix ]; then + msg_reloading Postfix + daemon /usr/sbin/postfix reload + RETVAL=$? + [ $RETVAL -ne 0 ] && RETVAL=7 + else + msg_not_running Postfix + exit 7 + fi ;; status) - status postfix + status master + exit $? ;; rebuilddb) - for I in access canonical relocated transport virtual - do - if [ -f /etc/mail/$I ] ; then - /usr/sbin/postmap hash:/etc/mail/$I < /etc/mail/$I - fi + 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$##') + 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 + fi done - ;; + /usr/bin/newaliases + ;; *) - echo "Usage: $0 {start|stop|restart|reload|status}" - exit 1 + msg_usage "$0 {start|stop|restart|reload|force-reload|rebuilddb|status}" + exit 3 esac -exit 0 +exit $RETVAL