Blob Blame History Raw
#!/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
#

# We require the /etc/amd.conf file, but supply it in the package, so it
# should always be there.
[ -f /etc/amd.conf ] || exit $?
[ -f /etc/sysconfig/amd ] || exit $?

# Source function library.
. /etc/init.d/functions

# Recover AMDOPTS from /etc/sysconfig/amd.
if [ -f /etc/sysconfig/amd ] ; then
	. /etc/sysconfig/amd
fi

RETVAL=0
prog=amd
amd=/usr/sbin/amd

start() {
	echo -n $"Starting $prog: "
	daemon $amd -F /etc/amd.conf $AMDOPTS $OPTIONS $MOUNTPTS
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/amd
	return $RETVAL
}

stop() {
        echo -n $"Stopping $prog: "
        killproc $amd -TERM
        # this part is from wait4amd2die
        delay=3
        count=10
        i=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)
                        rm -f /var/lock/subsys/amd /var/run/amd.pid
                        echo
                        return 0
                fi
                sleep $delay
                i=`expr $i + 1`
        done
        failure $"amd shutdown"
        echo
        echo "amd is still up"
        return 1
}

# See how we were called.
case "$1" in
  start)
        start
	;;
  stop)
        stop
	;;
  status)
	status $amd
	RETVAL=$?
	;;
  restart)
	stop
	start
	;;
  condrestart)
        if [ -f /var/lock/subsys/amd ]; then
	    stop
	    start
	fi
	;;
  reload)
	action $"Reloading $prog:" killall -HUP $amd
	;;
  *)
 	echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}"
	exit 1
esac

exit $RETVAL