10Sstevel@tonic-gate#!/bin/sh 20Sstevel@tonic-gate# control starting, stopping, or restarting hlfsd. 30Sstevel@tonic-gate# usage: ctl-hlfsd [start | stop | restart] 40Sstevel@tonic-gate# 50Sstevel@tonic-gate# Package: am-utils-6.x 60Sstevel@tonic-gate# Author: Erez Zadok <ezk@cs.columbia.edu> 70Sstevel@tonic-gate# 80Sstevel@tonic-gate# chkconfig: - 72 28 90Sstevel@tonic-gate# description: hlfsd is a daemon similar to amd, used to redirect user 100Sstevel@tonic-gate# mail to home directory of the user 110Sstevel@tonic-gate# processname: hlfsd 120Sstevel@tonic-gate# 130Sstevel@tonic-gate 140Sstevel@tonic-gate# set path 150Sstevel@tonic-gateprefix=@prefix@ 160Sstevel@tonic-gateexec_prefix=@exec_prefix@ 170Sstevel@tonic-gatePATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} 180Sstevel@tonic-gateexport PATH 190Sstevel@tonic-gate 200Sstevel@tonic-gate# kill the named process(es) 210Sstevel@tonic-gatekillproc() 220Sstevel@tonic-gate{ 230Sstevel@tonic-gate# try bsd style ps 240Sstevel@tonic-gatepscmd="ps axc" 250Sstevel@tonic-gatepid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 260Sstevel@tonic-gateif test "$pid" != "" 270Sstevel@tonic-gatethen 280Sstevel@tonic-gate kill $pid 290Sstevel@tonic-gate return 0 300Sstevel@tonic-gatefi 310Sstevel@tonic-gate 320Sstevel@tonic-gate# try bsd44 style ps 330Sstevel@tonic-gatepscmd="ps -x" 340Sstevel@tonic-gatepid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 350Sstevel@tonic-gateif test "$pid" != "" 360Sstevel@tonic-gatethen 370Sstevel@tonic-gate kill $pid 380Sstevel@tonic-gate return 0 390Sstevel@tonic-gatefi 400Sstevel@tonic-gate 410Sstevel@tonic-gate# try svr4 style ps 420Sstevel@tonic-gatepscmd="ps -e" 430Sstevel@tonic-gatepid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 440Sstevel@tonic-gateif test "$pid" != "" 450Sstevel@tonic-gatethen 460Sstevel@tonic-gate kill $pid 470Sstevel@tonic-gate return 0 480Sstevel@tonic-gatefi 490Sstevel@tonic-gate 500Sstevel@tonic-gate# failed 510Sstevel@tonic-gatereturn 1 520Sstevel@tonic-gate} 530Sstevel@tonic-gate 540Sstevel@tonic-gate# before running any real programs, chdir to / to avoid possible hangs on (NFS) 550Sstevel@tonic-gate# mounts. 560Sstevel@tonic-gatecd / 570Sstevel@tonic-gate 580Sstevel@tonic-gate# locate logs directory 590Sstevel@tonic-gateif [ -d /var/log ]; then 600Sstevel@tonic-gate logdir="/var/log" 610Sstevel@tonic-gateelse 620Sstevel@tonic-gate logdir="/tmp" 630Sstevel@tonic-gatefi 640Sstevel@tonic-gate 650Sstevel@tonic-gate# locate the mail spool directory 660Sstevel@tonic-gateif [ -d /var/mail/. ]; then 670Sstevel@tonic-gate maildir="/var/mail" 680Sstevel@tonic-gate altmaildir="/var/alt_mail" 690Sstevel@tonic-gateelif [ -d /var/spool/mail/. ]; then 700Sstevel@tonic-gate maildir="/var/spool/mail" 710Sstevel@tonic-gate altmaildir="/var/spool/alt_mail" 720Sstevel@tonic-gateelse 730Sstevel@tonic-gate maildir="/usr/spool/mail" 740Sstevel@tonic-gate altmaildir="/usr/spool/alt_mail" 750Sstevel@tonic-gatefi 760Sstevel@tonic-gate 770Sstevel@tonic-gate# locate any optional password file 780Sstevel@tonic-gateif [ -f @sysconfdir@/passwd ]; then 790Sstevel@tonic-gate PASSWD_FILE="-P @sysconfdir@/passwd" 800Sstevel@tonic-gateelse 810Sstevel@tonic-gate PASSWD_FILE="" 820Sstevel@tonic-gatefi 830Sstevel@tonic-gate 840Sstevel@tonic-gatecase "$1" in 850Sstevel@tonic-gate'start') 860Sstevel@tonic-gate # 870Sstevel@tonic-gate # Start the hlfsd mail redirector service 880Sstevel@tonic-gate # 890Sstevel@tonic-gate if [ -x @sbindir@/hlfsd -a -h $maildir ] 900Sstevel@tonic-gate then 910Sstevel@tonic-gate echo @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -l $logdir/hlfsd /mail/home .mailspool 920Sstevel@tonic-gate @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -l $logdir/hlfsd /mail/home .mailspool & 930Sstevel@tonic-gate test -x /var/lock/subsys && touch /var/lock/subsys/hlfsd 940Sstevel@tonic-gate fi 950Sstevel@tonic-gate ;; 960Sstevel@tonic-gate 970Sstevel@tonic-gate'stop') 980Sstevel@tonic-gate # prepend space to program name to ensure only amd process dies 990Sstevel@tonic-gate killproc " hlfsd" 1000Sstevel@tonic-gate test -f /var/lock/subsys/hlfsd && rm -f /var/lock/subsys/hlfsd 1010Sstevel@tonic-gate ;; 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate'restart') 1040Sstevel@tonic-gate # kill hlfsd, wait for it to die, then restart 1050Sstevel@tonic-gate echo "killing hlfsd..." 1060Sstevel@tonic-gate ctl-hlfsd stop 1070Sstevel@tonic-gate echo "Waiting for 10 seconds..." 1080Sstevel@tonic-gate sleep 10 # hope that would be enough 1090Sstevel@tonic-gate echo "Restarting hlfsd..." 1100Sstevel@tonic-gate ctl-hlfsd start 1110Sstevel@tonic-gate ;; 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate*) 1140Sstevel@tonic-gate echo "Usage: @sbindir@/ctl-hlfsd [ start | stop | restart ]" 1150Sstevel@tonic-gate ;; 1160Sstevel@tonic-gateesac 1170Sstevel@tonic-gate