3f3924
#!/bin/sh
3f3924
#
3f3924
# bacula-sd Takes care of starting and stopping the Bacula Storage Daemon.
3f3924
#
3f3924
# chkconfig: - 80 20
3f3924
# description: The Bacula Storage Daemon is the daemon responsible for saving \
3f3924
#              backed up data on the various File Daemon to the appropriate \
3f3924
#              storage devices.
3f3924
3f3924
### BEGIN INIT INFO
3f3924
# Required-Start: $local_fs $network
3f3924
# Required-Stop: $local_fs $network
3f3924
# Default-Start: 3 4 5
3f3924
# Default-Stop: 0 1 2 6
3f3924
# Short-Description: Bacula Storage Daemon.
3f3924
# Description: The Bacula Storage Daemon is the daemon responsible for saving
3f3924
#              backed up data on the various File Daemon to the appropriate
3f3924
#              storage devices.
3f3924
### END INIT INFO
3f3924
3f3924
# Source function library.
3f3924
. /etc/init.d/functions
3f3924
3f3924
exec="/usr/sbin/bacula-sd"
3f3924
prog="bacula-sd"
3f3924
CONFIG="/etc/bacula/bacula-sd.conf"
3f3924
OPTS="-c $CONFIG"
3f3924
3f3924
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
3f3924
3f3924
lockfile=/var/lock/subsys/$prog
3f3924
3f3924
if [ "$SD_USER" != '' ]; then
3f3924
        OPTS="$OPTS -u $SD_USER"
3f3924
fi
3f3924
3f3924
if [ "$SD_GROUP" != '' ]; then
3f3924
        OPTS="$OPTS -g $SD_GROUP"
3f3924
fi
3f3924
3f3924
start() {
3f3924
    [ -x $exec ] || exit 5
3f3924
    [ -f $config ] || exit 6
3f3924
    echo -n $"Starting $prog: "
3f3924
    daemon $prog $OPTS
3f3924
    retval=$?
3f3924
    echo
3f3924
    [ $retval -eq 0 ] && touch $lockfile
3f3924
    return $retval
3f3924
}
3f3924
3f3924
stop() {
3f3924
    echo -n $"Stopping $prog: "
3f3924
    killproc $prog
3f3924
    retval=$?
3f3924
    echo
3f3924
    [ $retval -eq 0 ] && rm -f $lockfile
3f3924
    return $retval
3f3924
}
3f3924
3f3924
restart() {
3f3924
    stop
3f3924
    sleep 2
3f3924
    start
3f3924
}
3f3924
3f3924
reload() {
3f3924
    restart
3f3924
}
3f3924
3f3924
force_reload() {
3f3924
    restart
3f3924
}
3f3924
3f3924
rh_status() {
3f3924
    # run checks to determine if the service is running or use generic status
3f3924
    status $prog
3f3924
}
3f3924
3f3924
rh_status_q() {
3f3924
    rh_status >/dev/null 2>&1
3f3924
}
3f3924
3f3924
3f3924
case "$1" in
3f3924
    start)
3f3924
        rh_status_q && exit 0
3f3924
        $1
3f3924
        ;;
3f3924
    stop)
3f3924
        rh_status_q || exit 0
3f3924
        $1
3f3924
        ;;
3f3924
    restart)
3f3924
        $1
3f3924
        ;;
3f3924
    reload)
3f3924
        rh_status_q || exit 7
3f3924
        $1
3f3924
        ;;
3f3924
    force-reload)
3f3924
        force_reload
3f3924
        ;;
3f3924
    status)
3f3924
        rh_status
3f3924
        ;;
3f3924
    condrestart|try-restart)
3f3924
        rh_status_q || exit 0
3f3924
        restart
3f3924
        ;;
3f3924
    *)
3f3924
        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
3f3924
        exit 2
3f3924
esac
3f3924
exit $?