#!/bin/sh NAME="Mail server" COMMAND=/usr/sbin/exim ARGS="-bd -q15m" OUTPUT_LOG=/dev/null START_TIMEOUT=3 STOP_TIMEOUT=3 # Fill in the correct information for the variables above. Any variable # that is not used should be left blank, with the exception of OUTPUT_LOG # which should be set to /dev/null. # You should not need to edit anything below this line. PATH=/sbin:/bin:/usr/sbin:/usr/bin case $1 in start) # check the current state of the daemon if [ "$(pidof $COMMAND)" = "" ]; then # as long as the deamon is not running, it's OK to start it if [ "$CONFIG_FILE" = "" ] || [ -e "$CONFIG_FILE" ]; then echo "$NAME is starting." $COMMAND $ARGS >>$OUTPUT_LOG 2>&1 # verify that it actually started, but be patient TIMER=$START_TIMEOUT while [ "$(pidof $COMMAND)" = "" ] && [ $TIMER -gt 0 ]; do sleep 1 TIMER=$(($TIMER-1)) done fi # report an error if it has not started by now if [ "$(pidof $COMMAND)" = "" ]; then echo "$NAME failed to start in a timely manner." fi fi ;; stop) # check the current state of the daemon if ! [ "$(pidof $COMMAND)" = "" ]; then # as long as the deamon is running, give the command to stop it echo "$NAME is stopping." killall $COMMAND # verify that it actually stopped, but be patient TIMER=$STOP_TIMEOUT while [ "$(pidof $COMMAND)" != "" ] && [ $TIMER -gt 0 ]; do sleep 1 TIMER=$(($TIMER-1)) done # report an error if it has not stopped by now if [ "$(pidof $COMMAND)" != "" ]; then echo "$NAME failed to stop in a timely manner." fi fi ;; restart) $0 stop $0 start ;; status|stat) if ! [ "$(pidof $COMMAND)" = "" ]; then echo "$NAME is running." else echo "$NAME is stopped." fi ;; *) echo "usage: $0 start|stop|restart|status" ;; esac