Actually hook powernow.4 into the build.
[dragonfly.git] / contrib / amd / scripts / ctl-amd.in
blob22c367792a53aae9c18bebcd4ff0575dc69c957e
1 #!/bin/sh
2 # control starting, stopping, or restarting amd.
3 # usage: ctl-amd [start | stop | restart]
5 # Package: am-utils-6.0
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 # 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"
70 if [ -f ${prefix}/etc/amd.conf ]
71 then
72 CF_FILE="${prefix}/etc/amd.conf"
74 if [ -f /etc/local/amd.conf ]
75 then
76 CF_FILE="/etc/local/amd.conf"
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"
86 case "$1" in
87 'start')
89 # Start the amd automounter.
91 if [ -x @sbindir@/amd ]
92 then
93 # do not specify full path of amd so killproc() works
94 amd -F $CF_FILE $CF_TAG
98 'stop')
99 # prepend space to program name to ensure only amd process dies
100 echo "killing amd..."
101 killproc " amd"
102 wait4amd2die
105 'restart')
106 # kill amd, wait for it to die, then restart
107 ctl-amd stop
108 if [ $? != 0 ]
109 then
110 echo "NOT restarting amd!"
111 else
112 echo "Restarting amd..."
113 sleep 1
114 ctl-amd start
119 echo "Usage: @sbindir@/ctl-amd [ start | stop | restart ]"
121 esac