1998-08-23 22:07:21 +00:00
|
|
|
#!/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>
|
1999-01-13 19:23:16 +00:00
|
|
|
#
|
1999-09-15 02:50:52 +00:00
|
|
|
# chkconfig: - 72 28
|
1999-01-13 19:23:16 +00:00
|
|
|
# description: hlfsd is a daemon similar to amd, used to redirect user
|
|
|
|
# mail to home directory of the user
|
1999-09-15 02:50:52 +00:00
|
|
|
# processname: hlfsd
|
|
|
|
#
|
1998-08-23 22:07:21 +00:00
|
|
|
|
|
|
|
# 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"
|
2001-09-02 17:19:13 +00:00
|
|
|
elif [ -d /var/spool/mail/. ]; then
|
|
|
|
maildir="/var/spool/mail"
|
|
|
|
altmaildir="/var/spool/alt_mail"
|
1998-08-23 22:07:21 +00:00
|
|
|
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..."
|
1999-01-13 19:23:16 +00:00
|
|
|
sleep 10 # hope that would be enough
|
1998-08-23 22:07:21 +00:00
|
|
|
echo "Restarting hlfsd..."
|
|
|
|
ctl-hlfsd start
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "Usage: @sbindir@/ctl-hlfsd [ start | stop | restart ]"
|
|
|
|
;;
|
|
|
|
esac
|