am-utils/am-utils.init

134 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
#
# Version: 1.3
#
# chkconfig: - 72 28
# description: Runs the automount daemon that mounts devices and NFS hosts \
# on demand.
# processname: amd
# config: /etc/amd.conf
### BEGIN INIT INFO
# Provides: amd
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Short-Description: start and stop early amd
# Description: Start and stop amd automounter
### END INIT INFO
# We require the /etc/amd.conf file, but supply it in the package, so it
# should always be there.
[ -f /etc/amd.conf ] || exit $?
# source function library.
. /etc/init.d/functions
[ -e /etc/sysconfig/amd ] && . /etc/sysconfig/amd
DAEMON=amd
prog=amd
exec=/usr/sbin/amd
config=/etc/amd.conf
optconfig=/etc/sysconfig/amd
lockfile=/var/lock/subsys/$DAEMON
[ -e $optconfig ] && . $optconfig
check() {
# Check that we're a privileged user
[ $(id -u) -eq 0 ] || exit 4
}
start () {
check
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
[ -f $optconfig ] || exit 6
echo -n $"Starting $prog: "
daemon $exec -F $config $AMDOPTS $OPTIONS $MOUNTPTS
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop () {
check
echo -n $"Stopping $prog: "
killproc $exec
delay=3
count=10
i=1
retval=1
maxcount=`expr $count + 1`
while [ $i != $maxcount ]; do
# run amq
/usr/sbin/amq > /dev/null 2>&1
if [ $? != 0 ]; then
# amq failed to run (because amd is dead)
retval=0
break
fi
sleep $delay
i=`expr $i + 1`
done
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
status $DAEMON
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?