811809
#!/bin/sh
811809
#
811809
# bacula-dir Takes care of starting and stopping the Bacula Director.
811809
#
811809
# chkconfig: - 80 20
811809
# description: The Bacula Director is the daemon responsible for all the logic \
811809
#              regarding the backup infrastructure: database, file retention, \
811809
#              tape indexing, scheduling.
811809
811809
### BEGIN INIT INFO
811809
# Required-Start: $local_fs $network
811809
# Required-Stop: $local_fs $network
811809
# Default-Start: 3 4 5
811809
# Default-Stop: 0 1 2 6
811809
# Short-Description: Bacula Director Daemon.
811809
# Description: The Bacula Director is the daemon responsible for all the logic
811809
#              regarding the backup infrastructure: database, file retention,
811809
#              tape indexing, scheduling.
811809
### END INIT INFO
811809
811809
# Source function library.
811809
. /etc/rc.d/init.d/functions
811809
811809
exec="/usr/sbin/bacula-dir"
811809
prog="bacula-dir"
811809
CONFIG="/etc/bacula/bacula-dir.conf"
811809
OPTS="-c $CONFIG"
811809
811809
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
811809
811809
lockfile=/var/lock/subsys/$prog
811809
811809
if [ "$DIR_USER" != '' ]; then
811809
        OPTS="$OPTS -u $DIR_USER"
811809
fi
811809
811809
if [ "$DIR_GROUP" != '' ]; then
811809
        OPTS="$OPTS -g $DIR_GROUP"
811809
fi
811809
811809
start() {
811809
    [ -x $exec ] || exit 5
811809
    [ -f $config ] || exit 6
811809
    echo -n $"Starting $prog: "
811809
    daemon $prog $OPTS
811809
    retval=$?
811809
    echo
811809
    [ $retval -eq 0 ] && touch $lockfile
811809
    return $retval
811809
}
811809
811809
stop() {
811809
    echo -n $"Stopping $prog: "
811809
    killproc $prog
811809
    retval=$?
811809
    echo
811809
    [ $retval -eq 0 ] && rm -f $lockfile
811809
    return $retval
811809
}
811809
811809
restart() {
811809
    stop
811809
    sleep 1
811809
    start
811809
}
811809
811809
reload() {
811809
    restart
811809
}
811809
811809
force_reload() {
811809
    restart
811809
}
811809
811809
rh_status() {
811809
    # run checks to determine if the service is running or use generic status
811809
    status $prog
811809
}
811809
811809
rh_status_q() {
811809
    rh_status >/dev/null 2>&1
811809
}
811809
811809
811809
case "$1" in
811809
    start)
811809
        rh_status_q && exit 0
811809
        $1
811809
        ;;
811809
    stop)
811809
        rh_status_q || exit 0
811809
        $1
811809
        ;;
811809
    restart)
811809
        $1
811809
        ;;
811809
    reload)
811809
        rh_status_q || exit 7
811809
        $1
811809
        ;;
811809
    force-reload)
811809
        force_reload
811809
        ;;
811809
    status)
811809
        rh_status
811809
        ;;
811809
    condrestart|try-restart)
811809
        rh_status_q || exit 0
811809
        restart
811809
        ;;
811809
    *)
811809
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
811809
        exit 2
811809
esac
811809
exit $?