973edf
#!/bin/sh
973edf
#
973edf
# atd Starts/stop the "at" daemon
973edf
#
973edf
# chkconfig:   345 95 5
973edf
# description: Runs commands scheduled by the "at" command at the time \
973edf
#    specified when "at" was run, and runs batch commands when the load \
973edf
#    average is low enough.
973edf
973edf
### BEGIN INIT INFO
973edf
# Provides: atd at batch
973edf
# Required-Start: $local_fs
973edf
# Required-Stop: $local_fs
973edf
# Default-Start: 345
973edf
# Default-Stop: 95
973edf
# Short-Description: Starts/stop the "at" daemon
973edf
# Description:      Runs commands scheduled by the "at" command at the time 
973edf
#    specified when "at" was run, and runs batch commands when the load 
973edf
#    average is low enough.
973edf
### END INIT INFO
973edf
973edf
# Source function library.
973edf
. /etc/rc.d/init.d/functions
973edf
973edf
exec=/usr/sbin/atd
973edf
prog="atd"
973edf
config=/etc/sysconfig/atd
973edf
973edf
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
973edf
973edf
lockfile=/var/lock/subsys/$prog
973edf
973edf
start() {
973edf
    [ -x $exec ] || exit 5
973edf
    [ -f $config ] || exit 6
973edf
    echo -n $"Starting $prog: "
973edf
    daemon $exec $OPTS && success || failure
973edf
    retval=$?
973edf
    echo
973edf
    [ $retval -eq 0 ] && touch $lockfile
973edf
    return $retval
973edf
}
973edf
973edf
stop() {
973edf
    echo -n $"Stopping $prog: "
973edf
    if [ -n "`pidfileofproc $exec`" ] ; then
973edf
        killproc $exec
973edf
		RETVAL=3
973edf
    else
973edf
        failure $"Stopping $prog"
973edf
    fi
973edf
    retval=$?
973edf
    echo
973edf
    [ $retval -eq 0 ] && rm -f $lockfile
973edf
    return $retval
973edf
}
973edf
973edf
restart() {
973edf
    stop
973edf
    start
973edf
}
973edf
973edf
reload() {
973edf
    restart
973edf
}
973edf
973edf
force_reload() {
973edf
    restart
973edf
}
973edf
973edf
rh_status() {
973edf
    # run checks to determine if the service is running or use generic status
973edf
    status $prog
973edf
}
973edf
973edf
rh_status_q() {
973edf
    rh_status >/dev/null 2>&1
973edf
}
973edf
973edf
973edf
case "$1" in
973edf
    start)
973edf
        rh_status_q && exit 0
973edf
        $1
973edf
        ;;
973edf
    stop)
973edf
        rh_status_q || exit 0
973edf
        $1
973edf
        ;;
973edf
    restart)
973edf
        $1
973edf
        ;;
973edf
    reload)
973edf
        rh_status_q || exit 7
973edf
        $1
973edf
        ;;
973edf
    force-reload)
973edf
        force_reload
973edf
        ;;
973edf
    status)
973edf
        rh_status
973edf
        ;;
973edf
    condrestart|try-restart)
973edf
        rh_status_q || exit 0
973edf
        restart
973edf
        ;;
973edf
    *)
973edf
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
973edf
        exit 2
973edf
esac
973edf
exit $?