Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / bsd / am-utils / dist / scripts / ctl-amd.in
blob694b31a9764c2c652e29720a5daabee449ed73ef
1 #!/bin/sh
2 # control starting, stopping, or restarting amd.
3 # usage: ctl-amd [start|stop|status|restart|condrestart|reload]
5 # Package: am-utils-6.x
6 # Author: Erez Zadok <ezk@cs.columbia.edu>
8 # chkconfig: - 72 28
9 # description: Runs the automount daemon that mounts devices and NFS hosts \
10 # on demand.
11 # processname: amd
12 # config: /etc/amd.conf
15 # set path
16 prefix=@prefix@
17 exec_prefix=@exec_prefix@
18 PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH}
19 export PATH
21 # kill the named process(es)
22 killproc()
24 # first try to get PID via an amq RPC
25 pid=`amq -p 2>/dev/null`
26 if test "$pid" != ""
27 then
28 kill $pid
29 return 0
32 # try bsd style ps
33 pscmd="ps axc"
34 pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'`
35 if test "$pid" != ""
36 then
37 kill $pid
38 return 0
41 # try bsd44 style ps
42 pscmd="ps -x"
43 pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'`
44 if test "$pid" != ""
45 then
46 kill $pid
47 return 0
50 # try svr4 style ps
51 pscmd="ps -e"
52 pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'`
53 if test "$pid" != ""
54 then
55 kill $pid
56 return 0
59 # failed
60 return 1
63 # before running any real programs, chdir to / to avoid possible hangs on
64 # (NFS) mounts which may be restarting.
65 cd /
67 # search for amd.conf file
68 CF_FILE="@sysconfdir@/amd.conf"
69 # any local copy of the conf file overrides the "global" one
70 if [ -f /etc/amd.conf ]
71 then
72 CF_FILE="/etc/amd.conf"
74 if [ -f @sysconfdir@/amd.conf ]
75 then
76 CF_FILE="@sysconfdir@/amd.conf"
78 if [ -f /etc/local/amd.conf ]
79 then
80 CF_FILE="/etc/local/amd.conf"
83 # if have the directory /tftpboot/.amd, then add a tag to include it
84 CF_TAG=""
85 if [ -d /tftpboot/.amd ]
86 then
87 CF_TAG="-T tftpboot"
90 case "$1" in
91 'start')
92 # Start the amd automounter.
93 if [ -x @sbindir@/amd ]
94 then
95 # do not specify full path of amd so killproc() works
96 amd -F $CF_FILE $CF_TAG
97 test -x /var/lock/subsys && touch /var/lock/subsys/amd
101 'stop')
102 # prepend space to program name to ensure only amd process dies
103 echo "killing amd..."
104 killproc " amd"
105 wait4amd2die
106 rm -f /var/lock/subsys/amd
109 'restart')
110 # kill amd, wait for it to die, then restart
111 ctl-amd stop
112 if [ $? != 0 ]
113 then
114 echo "NOT restarting amd!"
115 else
116 echo "Restarting amd..."
117 sleep 1
118 ctl-amd start
122 'condrestart')
123 if [ -f /var/lock/subsys/amd ]; then
124 ctl-amd stop
125 ctl-amd start
129 'reload')
130 amq -f
133 'status')
134 # run amq -v to produce status
135 pid=`amq -p 2>/dev/null`
136 if [ $? = 0 ]
137 then
138 echo "amd (pid $pid) is running..."
139 else
140 echo "amd is stopped"
144 # start_msg and stop_msg are for HPUX
145 'start_msg')
146 echo "Start am-utils 6.1 automounter"
148 'stop_msg')
149 echo "Stop am-utils 6.1 automounter"
153 echo "Usage: $0 [start|stop|status|restart|condrestart|reload]"
155 esac