meillo@0: #! /bin/sh meillo@0: # Author: Oliver Kurth meillo@0: # meillo@0: # /sbin/init.d/masqmail meillo@0: # meillo@0: meillo@0: . /etc/rc.config meillo@0: meillo@0: # Determine the base and follow a runlevel link name. meillo@0: base=${0##*/} meillo@0: link=${base#*[SK][0-9][0-9]} meillo@0: meillo@0: # Force execution if not called by a runlevel directory. meillo@0: test $link = $base && SMTP=yes meillo@0: test "$SMTP" = yes || exit 0 meillo@0: meillo@0: if test -z "$MASQMAIL_ARGS" ; then meillo@0: MASQMAIL_ARGS="-bd -q30m" meillo@0: fi meillo@0: meillo@0: # The echo return value for success (defined in /etc/rc.config). meillo@0: return=$rc_done meillo@0: case "$1" in meillo@0: start) meillo@0: echo -n "Starting SMTP (MasqMail)" meillo@0: ## Start daemon with startproc(8). If this fails meillo@0: ## the echo return value is set appropriate. meillo@0: meillo@0: startproc /usr/sbin/sendmail $MASQMAIL_ARGS || return=$rc_failed meillo@0: meillo@0: echo -e "$return" meillo@0: ;; meillo@0: stop) meillo@0: echo -n "Shutting down SMTP (MasqMail)" meillo@0: ## Stop daemon with killproc(8) and if this fails meillo@0: ## set echo the echo return value. meillo@0: meillo@0: killproc -TERM /usr/sbin/sendmail || return=$rc_failed meillo@0: meillo@0: echo -e "$return" meillo@0: ;; meillo@0: restart) meillo@0: ## If first returns OK call the second, if first or meillo@0: ## second command fails, set echo return value. meillo@0: $0 stop && $0 start || return=$rc_failed meillo@0: ;; meillo@0: reload) meillo@0: ## Choose ONE of the following two cases: meillo@0: meillo@0: ## First possibility: A few services accepts a signal meillo@0: ## to reread the (changed) configuration. meillo@0: meillo@0: #echo -n "Reload service MasqMail" meillo@0: #killproc -HUP /usr/sbin/sendmail || return=$rc_failed meillo@0: #echo -e "$return" meillo@0: meillo@0: ## Exclusive possibility: Some services must be stopped meillo@0: ## and started to force a new load of the configuration. meillo@0: meillo@0: $0 stop && $0 start || return=$rc_failed meillo@0: ;; meillo@0: status) meillo@0: echo -n "Checking for service SMTP (MasqMail): " meillo@0: ## Check status with checkproc(8), if process is running meillo@0: ## checkproc will return with exit status 0. meillo@0: meillo@0: checkproc /usr/sbin/sendmail && echo OK || echo No process meillo@0: ;; meillo@0: # probe) meillo@0: ## Optional: Probe for the necessity of a reload, meillo@0: ## give out the argument which is required for a reload. meillo@0: meillo@0: # test /usr/exim/configure -nt /var/lock/exim.pid && echo reload meillo@0: # ;; meillo@0: *) meillo@0: echo "Usage: $0 {start|stop|status|restart|reload|probe}" meillo@0: exit 1 meillo@0: ;; meillo@0: esac meillo@0: meillo@0: # Inform the caller not only verbosely and set an exit status. meillo@0: test "$return" = "$rc_done" || exit 1 meillo@0: exit 0