2004-09-09 02:55:20 +00:00
|
|
|
#!/bin/bash
|
2004-09-09 02:55:14 +00:00
|
|
|
#
|
|
|
|
# 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
|
2008-05-29 12:08:33 +00:00
|
|
|
### 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
|
2004-09-09 02:55:14 +00:00
|
|
|
|
2004-09-09 02:55:29 +00:00
|
|
|
# We require the /etc/amd.conf file, but supply it in the package, so it
|
|
|
|
# should always be there.
|
|
|
|
[ -f /etc/amd.conf ] || exit $?
|
2004-09-09 02:55:14 +00:00
|
|
|
|
2010-02-24 14:00:23 +00:00
|
|
|
# source function library.
|
2004-09-09 02:55:14 +00:00
|
|
|
. /etc/init.d/functions
|
|
|
|
|
2010-02-24 14:00:23 +00:00
|
|
|
[ -e /etc/sysconfig/amd ] && . /etc/sysconfig/amd
|
2004-09-09 02:55:14 +00:00
|
|
|
|
2010-02-24 14:00:23 +00:00
|
|
|
DAEMON=amd
|
2004-09-09 02:55:20 +00:00
|
|
|
prog=amd
|
2010-02-24 14:00:23 +00:00
|
|
|
exec=/usr/sbin/amd
|
|
|
|
config=/etc/amd.conf
|
|
|
|
optconfig=/etc/sysconfig/amd
|
|
|
|
lockfile=/var/lock/subsys/$DAEMON
|
2004-09-09 02:55:14 +00:00
|
|
|
|
2010-02-24 14:00:23 +00:00
|
|
|
[ -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
|
2004-09-09 02:55:20 +00:00
|
|
|
echo -n $"Starting $prog: "
|
2010-02-24 14:00:23 +00:00
|
|
|
daemon $exec -F $config $AMDOPTS $OPTIONS $MOUNTPTS
|
|
|
|
retval=$?
|
2004-09-09 02:55:20 +00:00
|
|
|
echo
|
2010-02-24 14:00:23 +00:00
|
|
|
[ $retval -eq 0 ] && touch $lockfile
|
|
|
|
return $retval
|
2004-09-09 02:55:14 +00:00
|
|
|
}
|
|
|
|
|
2010-02-24 14:00:23 +00:00
|
|
|
stop () {
|
|
|
|
check
|
|
|
|
echo -n $"Stopping $prog: "
|
|
|
|
killproc $exec
|
2005-10-05 16:26:58 +00:00
|
|
|
delay=3
|
|
|
|
count=10
|
|
|
|
i=1
|
2010-02-24 14:00:23 +00:00
|
|
|
retval=1
|
2005-10-05 16:26:58 +00:00
|
|
|
maxcount=`expr $count + 1`
|
|
|
|
while [ $i != $maxcount ]; do
|
|
|
|
# run amq
|
|
|
|
/usr/sbin/amq > /dev/null 2>&1
|
2010-02-24 14:00:23 +00:00
|
|
|
if [ $? != 0 ]; then
|
2005-10-05 16:26:58 +00:00
|
|
|
# amq failed to run (because amd is dead)
|
2010-02-24 14:00:23 +00:00
|
|
|
retval=0
|
|
|
|
break
|
2005-10-05 16:26:58 +00:00
|
|
|
fi
|
|
|
|
sleep $delay
|
|
|
|
i=`expr $i + 1`
|
|
|
|
done
|
2010-02-24 14:00:23 +00:00
|
|
|
|
|
|
|
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
|
2004-09-09 02:55:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
2010-02-24 14:00:23 +00:00
|
|
|
rh_status_q && exit 0
|
|
|
|
$1
|
2004-09-09 02:55:14 +00:00
|
|
|
;;
|
2010-02-24 14:00:23 +00:00
|
|
|
stop)
|
|
|
|
rh_status_q || exit 0
|
|
|
|
$1
|
2004-09-09 02:55:14 +00:00
|
|
|
;;
|
|
|
|
restart)
|
2010-02-24 14:00:23 +00:00
|
|
|
$1
|
2004-09-09 02:55:14 +00:00
|
|
|
;;
|
|
|
|
reload)
|
2010-02-24 14:00:23 +00:00
|
|
|
rh_status_q || exit 7
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
force-reload)
|
|
|
|
force_reload
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
rh_status
|
|
|
|
;;
|
|
|
|
condrestart|try-restart)
|
|
|
|
rh_status_q || exit 0
|
|
|
|
restart
|
2004-09-09 02:55:14 +00:00
|
|
|
;;
|
|
|
|
*)
|
2010-02-24 14:00:23 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
|
|
|
exit 2
|
2004-09-09 02:55:14 +00:00
|
|
|
esac
|
2010-02-24 14:00:23 +00:00
|
|
|
exit $?
|
2004-09-09 02:55:14 +00:00
|
|
|
|