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.x 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 16prefix=@prefix@ 17exec_prefix=@exec_prefix@ 18PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} 19export PATH 20 21# kill the named process(es) 22killproc() 23{ 24# first try to get PID via an amq RPC 25pid=`amq -p 2>/dev/null` 26if test "$pid" != "" 27then 28 kill $pid 29 return 0 30fi 31 32# try bsd style ps 33pscmd="ps axc" 34pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 35if test "$pid" != "" 36then 37 kill $pid 38 return 0 39fi 40 41# try bsd44 style ps 42pscmd="ps -x" 43pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 44if test "$pid" != "" 45then 46 kill $pid 47 return 0 48fi 49 50# try svr4 style ps 51pscmd="ps -e" 52pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` 53if test "$pid" != "" 54then 55 kill $pid 56 return 0 57fi 58 59# failed 60return 1 61} 62 63# before running any real programs, chdir to / to avoid possible hangs on 64# (NFS) mounts which may be restarting. 65cd / 66 67# search for amd.conf file 68CF_FILE="@sysconfdir@/amd.conf" 69# any local copy of the conf file overrides the "global" one 70if [ -f /etc/amd.conf ] 71then 72 CF_FILE="/etc/amd.conf" 73fi 74if [ -f @sysconfdir@/amd.conf ] 75then 76 CF_FILE="@sysconfdir@/amd.conf" 77fi 78if [ -f /etc/local/amd.conf ] 79then 80 CF_FILE="/etc/local/amd.conf" 81fi 82 83# if have the directory /tftpboot/.amd, then add a tag to include it 84CF_TAG="" 85if [ -d /tftpboot/.amd ] 86then 87 CF_TAG="-T tftpboot" 88fi 89 90case "$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 98 fi 99 ;; 100 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 107 ;; 108 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 119 fi 120 ;; 121 122'condrestart') 123 if [ -f /var/lock/subsys/amd ]; then 124 ctl-amd stop 125 ctl-amd start 126 fi 127 ;; 128 129'reload') 130 amq -f 131 ;; 132 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" 141 fi 142 ;; 143 144# start_msg and stop_msg are for HPUX 145'start_msg') 146 echo "Start am-utils 6.1 automounter" 147 ;; 148'stop_msg') 149 echo "Stop am-utils 6.1 automounter" 150 ;; 151 152*) 153 echo "Usage: $0 [start|stop|status|restart|condrestart|reload]" 154 ;; 155esac 156