1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
#!/bin/sh
# control starting, stopping, or restarting amd.
# usage: ctl-amd [start|stop|status|restart|condrestart|reload]
#
# Package: am-utils-6.0
# Author: Erez Zadok <ezk@cs.columbia.edu>
#
# chkconfig: - 72 28
# description: Runs the automount daemon that mounts devices and NFS hosts \
# on demand.
# processname: amd
# config: /etc/amd.conf
#
# 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()
{
# first try to get PID via an amq RPC
pid=`amq -p 2>/dev/null`
if test "$pid" != ""
then
kill $pid
return 0
fi
# 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
}
# search for amd.conf file
CF_FILE="${prefix}/etc/amd.conf"
# any local copy of the conf file overrides the "global" one
if [ -f /etc/amd.conf ]
then
CF_FILE="/etc/amd.conf"
fi
if [ -f ${prefix}/etc/amd.conf ]
then
CF_FILE="${prefix}/etc/amd.conf"
fi
if [ -f /etc/local/amd.conf ]
then
CF_FILE="/etc/local/amd.conf"
fi
# if have the directory /tftpboot/.amd, then add a tag to include it
CF_TAG=""
if [ -d /tftpboot/.amd ]
then
CF_TAG="-T tftpboot"
fi
case "$1" in
'start')
# Start the amd automounter.
if [ -x @sbindir@/amd ]
then
# do not specify full path of amd so killproc() works
amd -F $CF_FILE $CF_TAG
fi
;;
'stop')
# prepend space to program name to ensure only amd process dies
echo "killing amd..."
killproc " amd"
wait4amd2die
;;
'restart')
# kill amd, wait for it to die, then restart
ctl-amd stop
if [ $? != 0 ]
then
echo "NOT restarting amd!"
else
echo "Restarting amd..."
sleep 1
ctl-amd start
fi
;;
'condrestart')
if [ -f /var/lock/subsys/amd ]; then
ctl-amd stop
ctl-amd start
fi
;;
'reload')
amq -f
;;
'status')
# run amq -v to produce status
pid=`amq -p 2>/dev/null`
if [ $? = 0 ]
then
echo "amd (pid $pid) is running..."
else
echo "amd is stopped"
fi
;;
# start_msg and stop_msg are for HPUX
'start_msg')
echo "Start am-utils 6.0 automounter"
;;
'stop_msg')
echo "Stop am-utils 6.0 automounter"
;;
*)
echo "Usage: @sbindir@/ctl-amd [start|stop|status|restart|condrestart|reload]"
;;
esac
|