]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/amd/scripts/ctl-amd.in
This commit was generated by cvs2svn to compensate for changes in r97241,
[FreeBSD/FreeBSD.git] / contrib / amd / scripts / ctl-amd.in
1 #!/bin/sh
2 # control starting, stopping, or restarting amd.
3 # usage: ctl-amd [start|stop|status|restart|condrestart|reload]
4 #
5 # Package:      am-utils-6.0
6 # Author:       Erez Zadok <ezk@cs.columbia.edu>
7 #
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
13 #
14
15 # set path
16 prefix=@prefix@
17 exec_prefix=@exec_prefix@
18 PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH}
19 export PATH
20
21 # kill the named process(es)
22 killproc()
23 {
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
30 fi
31
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
39 fi
40
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
48 fi
49
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
57 fi
58
59 # failed
60 return 1
61 }
62
63 # search for amd.conf file
64 CF_FILE="${prefix}/etc/amd.conf"
65 # any local copy of the conf file overrides the "global" one
66 if [ -f /etc/amd.conf ]
67 then
68         CF_FILE="/etc/amd.conf"
69 fi
70 if [ -f ${prefix}/etc/amd.conf ]
71 then
72         CF_FILE="${prefix}/etc/amd.conf"
73 fi
74 if [ -f /etc/local/amd.conf ]
75 then
76         CF_FILE="/etc/local/amd.conf"
77 fi
78
79 # if have the directory /tftpboot/.amd, then add a tag to include it
80 CF_TAG=""
81 if [ -d /tftpboot/.amd ]
82 then
83         CF_TAG="-T tftpboot"
84 fi
85
86 case "$1" in
87 'start')
88         # Start the amd automounter.
89         if [ -x @sbindir@/amd ]
90         then
91                 # do not specify full path of amd so killproc() works
92                 amd -F $CF_FILE $CF_TAG
93         fi
94         ;;
95
96 'stop')
97         # prepend space to program name to ensure only amd process dies
98         echo "killing amd..."
99         killproc " amd"
100         wait4amd2die
101         ;;
102
103 'restart')
104         # kill amd, wait for it to die, then restart
105         ctl-amd stop
106         if [ $? != 0 ]
107         then
108                 echo "NOT restarting amd!"
109         else
110                 echo "Restarting amd..."
111                 sleep 1
112                 ctl-amd start
113         fi
114         ;;
115
116 'condrestart')
117      if [ -f /var/lock/subsys/amd ]; then
118             ctl-amd stop
119             ctl-amd start
120         fi
121      ;;
122
123 'reload')
124         amq -f
125         ;;
126
127 'status')
128         # run amq -v to produce status
129         pid=`amq -p 2>/dev/null`
130         if [ $? = 0 ]
131         then
132                 echo "amd (pid $pid) is running..."
133         else
134                 echo "amd is stopped"
135         fi
136         ;;
137
138 # start_msg and stop_msg are for HPUX
139 'start_msg')
140         echo "Start am-utils 6.0 automounter"
141         ;;
142 'stop_msg')
143         echo "Stop am-utils 6.0 automounter"
144         ;;
145
146 *)
147         echo "Usage: @sbindir@/ctl-amd [start|stop|status|restart|condrestart|reload]"
148         ;;
149 esac