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