Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / am-utils / dist / scripts / redhat-ctl-amd.in
blob4d00d472c24aa37945079e806d332f4cc4b61554
1 #!/bin/bash
3 # Version: 1.3
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
12 # we require the /etc/amd.conf file
13 [ -f /etc/amd.conf ] || exit 0
14 [ -f /etc/sysconfig/amd ] || exit 0
16 # Source function library.
17 . /etc/init.d/functions
19 # Recover AMDOPTS from /etc/sysconfig/amd.
20 if [ -f /etc/sysconfig/amd ] ; then
21 . /etc/sysconfig/amd
24 RETVAL=0
25 prog=amd
26 prefix=@prefix@
27 exec_prefix=@exec_prefix@
28 amd=@sbindir@/amd
30 start() {
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
39 stop() {
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/ .*//'`
48 if [ "$pid" = "" ] ; then
49 failure "amd shutdown pid"
50 echo
51 return 1
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
70 sleep $delay
71 i=`expr $i + 1`
72 done
73 failure "amd shutdown (still up)"
74 echo
75 return 1
77 # See how we were called.
78 case "$1" in
79 start)
80 start
82 stop)
83 stop
85 status)
86 status $amd
88 restart)
89 stop
90 start
92 condrestart)
93 if [ -f /var/lock/subsys/amd ]; then
94 stop
95 start
98 reload)
99 action "Reloading $prog:" killall -HUP $amd
102 echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
103 exit 1
104 esac
106 exit 0