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