redhat-ctl-amd.in revision 256281
1#!/bin/bash 2# 3# Version: 1.3 4# 5# chkconfig: - 72 28 6# description: Runs the automount daemon that mounts devices and NFS hosts \ 7# on demand. 8# processname: amd 9# config: /etc/amd.conf 10# 11 12# we require the /etc/amd.conf file 13[ -f /etc/amd.conf ] || exit 0 14[ -f /etc/sysconfig/amd ] || exit 0 15 16# Source function library. 17. /etc/init.d/functions 18 19# Recover AMDOPTS from /etc/sysconfig/amd. 20if [ -f /etc/sysconfig/amd ] ; then 21 . /etc/sysconfig/amd 22fi 23 24RETVAL=0 25prog=amd 26prefix=@prefix@ 27exec_prefix=@exec_prefix@ 28amd=@sbindir@/amd 29 30start() { 31 echo -n "Starting $prog: " 32 daemon $amd -F /etc/amd.conf $AMDOPTS $OPTIONS $MOUNTPTS 33 RETVAL=$? 34 echo 35 [ $RETVAL = 0 ] && touch /var/lock/subsys/amd 36 return $RETVAL 37} 38 39stop() { 40 41 echo -n "Stopping $prog: " 42 # modeled from /usr/sbin/ctl-amd 43 pid=`/usr/sbin/amq -p 2>/dev/null` 44 if [ "$pid" = "" ] ; then 45 # amq -p did not give pid, so try ps 46 pid=`ps acx 2>/dev/null | grep "amd" | sed -e 's/^ *//' -e 's/ .*//'` 47 fi 48 if [ "$pid" = "" ] ; then 49 failure "amd shutdown pid" 50 echo 51 return 1 52 fi 53 kill $pid 54 # and this part is from wait4amd2die 55 delay=5 56 count=6 57 i=1 58 maxcount=`expr $count + 1` 59 while [ $i != $maxcount ]; do 60 # run amq 61 /usr/sbin/amq > /dev/null 2>&1 62 if [ $? != 0 ] 63 then 64 # amq failed to run (because amd is dead) 65 success "amd shutdown" 66 rm -f /var/lock/subsys/amd 67 echo 68 return 0 69 fi 70 sleep $delay 71 i=`expr $i + 1` 72 done 73 failure "amd shutdown (still up)" 74 echo 75 return 1 76} 77# See how we were called. 78case "$1" in 79 start) 80 start 81 ;; 82 stop) 83 stop 84 ;; 85 status) 86 status $amd 87 ;; 88 restart) 89 stop 90 start 91 ;; 92 condrestart) 93 if [ -f /var/lock/subsys/amd ]; then 94 stop 95 start 96 fi 97 ;; 98 reload) 99 action "Reloading $prog:" killall -HUP $amd 100 ;; 101 *) 102 echo "Usage: $0 {start|stop|restart|reload|condrestart|status}" 103 exit 1 104esac 105 106exit 0 107