diff options
Diffstat (limited to 'contrib/amd/scripts/ctl-hlfsd.in')
-rwxr-xr-x | contrib/amd/scripts/ctl-hlfsd.in | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/contrib/amd/scripts/ctl-hlfsd.in b/contrib/amd/scripts/ctl-hlfsd.in new file mode 100755 index 0000000..a6e97f6 --- /dev/null +++ b/contrib/amd/scripts/ctl-hlfsd.in @@ -0,0 +1,101 @@ +#!/bin/sh +# control starting, stopping, or restarting hlfsd. +# usage: ctl-hlfsd [start | stop | restart] +# +# Package: am-utils-6.0 +# Author: Erez Zadok <ezk@cs.columbia.edu> + +# set path +prefix=@prefix@ +exec_prefix=@exec_prefix@ +PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} +export PATH + +# kill the named process(es) +killproc() +{ +# try bsd style ps +pscmd="ps axc" +pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` +if test "$pid" != "" +then + kill $pid + return 0 +fi + +# try bsd44 style ps +pscmd="ps -x" +pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` +if test "$pid" != "" +then + kill $pid + return 0 +fi + +# try svr4 style ps +pscmd="ps -e" +pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` +if test "$pid" != "" +then + kill $pid + return 0 +fi + +# failed +return 1 +} + +# locate logs directory +if [ -d /var/log ]; then + logdir="/var/log" +else + logdir="/tmp" +fi + +# locate the mail spool directory +if [ -d /var/mail/. ]; then + maildir="/var/mail" + altmaildir="/var/alt_mail" +else + maildir="/usr/spool/mail" + altmaildir="/usr/spool/alt_mail" +fi + +# locate any optional password file +if [ -f ${prefix}/etc/passwd ]; then + PASSWD_FILE="-P ${prefix}/etc/passwd" +else + PASSWD_FILE="" +fi + +case "$1" in +'start') + # + # Start the hlfsd mail redirector service + # + if [ -x @sbindir@/hlfsd -a -h $maildir ] + then + echo @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -D fork -l $logdir/hlfsd /mail/home .mailspool + @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -D fork -l $logdir/hlfsd /mail/home .mailspool & + fi + ;; + +'stop') + # prepend space to program name to ensure only amd process dies + killproc " hlfsd" + ;; + +'restart') + # kill hlfsd, wait for it to die, then restart + echo "killing hlfsd..." + ctl-hlfsd stop + echo "Waiting for 10 seconds..." + sleep 10 # hope that's enough + echo "Restarting hlfsd..." + ctl-hlfsd start + ;; + +*) + echo "Usage: @sbindir@/ctl-hlfsd [ start | stop | restart ]" + ;; +esac |