ctl-hlfsd.in revision 1.1
1#!/bin/sh 2# control starting, stopping, or restarting hlfsd. 3# usage: ctl-hlfsd [start | stop | restart] 4# 5# Package: am-utils-6.x 6# Author: Erez Zadok <ezk@cs.columbia.edu> 7# 8# chkconfig: - 72 28 9# description: hlfsd is a daemon similar to amd, used to redirect user 10# mail to home directory of the user 11# processname: hlfsd 12# 13 14# set path 15prefix=@prefix@ 16exec_prefix=@exec_prefix@ 17PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} 18export PATH 19 20# kill the named process(es) 21killproc() 22{ 23# try bsd style ps 24pscmd="ps axc" 25pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 26if test "$pid" != "" 27then 28 kill $pid 29 return 0 30fi 31 32# try bsd44 style ps 33pscmd="ps -x" 34pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 35if test "$pid" != "" 36then 37 kill $pid 38 return 0 39fi 40 41# try svr4 style ps 42pscmd="ps -e" 43pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 44if test "$pid" != "" 45then 46 kill $pid 47 return 0 48fi 49 50# failed 51return 1 52} 53 54# before running any real programs, chdir to / to avoid possible hangs on (NFS) 55# mounts. 56cd / 57 58# locate logs directory 59if [ -d /var/log ]; then 60 logdir="/var/log" 61else 62 logdir="/tmp" 63fi 64 65# locate the mail spool directory 66if [ -d /var/mail/. ]; then 67 maildir="/var/mail" 68 altmaildir="/var/alt_mail" 69elif [ -d /var/spool/mail/. ]; then 70 maildir="/var/spool/mail" 71 altmaildir="/var/spool/alt_mail" 72else 73 maildir="/usr/spool/mail" 74 altmaildir="/usr/spool/alt_mail" 75fi 76 77# locate any optional password file 78if [ -f @sysconfdir@/passwd ]; then 79 PASSWD_FILE="-P @sysconfdir@/passwd" 80else 81 PASSWD_FILE="" 82fi 83 84case "$1" in 85'start') 86 # 87 # Start the hlfsd mail redirector service 88 # 89 if [ -x @sbindir@/hlfsd -a -h $maildir ] 90 then 91 echo @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -l $logdir/hlfsd /mail/home .mailspool 92 @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -l $logdir/hlfsd /mail/home .mailspool & 93 test -x /var/lock/subsys && touch /var/lock/subsys/hlfsd 94 fi 95 ;; 96 97'stop') 98 # prepend space to program name to ensure only amd process dies 99 killproc " hlfsd" 100 test -f /var/lock/subsys/hlfsd && rm -f /var/lock/subsys/hlfsd 101 ;; 102 103'restart') 104 # kill hlfsd, wait for it to die, then restart 105 echo "killing hlfsd..." 106 ctl-hlfsd stop 107 echo "Waiting for 10 seconds..." 108 sleep 10 # hope that would be enough 109 echo "Restarting hlfsd..." 110 ctl-hlfsd start 111 ;; 112 113*) 114 echo "Usage: @sbindir@/ctl-hlfsd [ start | stop | restart ]" 115 ;; 116esac 117