]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/debian/bacula-sd.in
LSBize Debian init scripts
[bacula/bacula] / bacula / platforms / debian / bacula-sd.in
1 #! /bin/sh
2 #
3 # bacula  This shell script takes care of starting and stopping
4 #         the bacula Director daemon on Debian/Ubuntu/Kubuntu 
5 #         systems. 
6 #
7 #   Kern E. Sibbald - 21 March 2008
8 #
9 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
10 #
11 ### BEGIN INIT INFO
12 # Provides:          bacula-sd
13 # Required-Start:    $network
14 # Required-Stop:     $network
15 # Default-Start:     2 3 4 5
16 # Default-Stop:      0 1 6
17 # Short-Description: Start $BACULA Storage daemon at boot time
18 # Description:       Enable $BACULA Storage daemon.
19 ### END INIT INFO
20
21
22 NAME="bacula-sd"
23 DESC="$Bacula Storage Daemon"
24 DAEMON=@sbindir@/${NAME}
25 BUSER=@sd_user@
26 BGROUP=@sd_group@
27 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
28 BPORT=@sd_port@
29
30 PATH=/sbin:/bin:/usr/sbin:/usr/bin
31
32 test -f $DAEMON || exit 0
33
34 if [ -n "`getent services ${NAME}`" ]; then
35    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
36 fi
37
38 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
39
40 if [ "x${BUSER}" != "x" ]; then
41    BOPTIONS="${BOPTIONS} -u ${BUSER}"
42 fi
43 if [ "x${BGROUP}" != "x" ]; then
44    BOPTIONS="${BOPTIONS} -g ${BGROUP}"
45 fi
46
47 case "$1" in
48    start)
49       echo -n "Starting ${DESC}: "
50       start-stop-daemon --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- ${BOPTIONS}
51       echo "${NAME}"
52       ;;
53    stop)
54       echo -n "Stopping ${DESC}: "
55       start-stop-daemon --oknodo --stop --quiet --exec ${DAEMON} -- ${BOPTIONS}
56       echo "${NAME}"
57       ;;
58    restart|force-reload)
59       $0 stop
60       sleep 5
61       $0 start
62       ;;
63    *)
64       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
65       exit 1
66       ;;
67 esac
68 exit 0