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