]> git.sur5r.net Git - bacula/bacula/blob - bacula/platforms/debian/bacula-dir.in
Allow custom variables and checks from debian/ubuntu startup scripts
[bacula/bacula] / bacula / platforms / debian / bacula-dir.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-dir
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@ Director daemon at boot time
18 # Description:       Enable @BACULA@ Director.
19 ### END INIT INFO
20 #
21
22 NAME="bacula-dir"
23 DESC="@BACULA@ Director"
24 DAEMON=@sbindir@/${NAME}
25 BUSER=@dir_user@
26 BGROUP=@dir_group@
27 BOPTIONS="-c @sysconfdir@/${NAME}.conf"
28 BPORT=@dir_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 if [ -f /etc/default/$NAME ]; then
39    . /etc/default/$NAME
40 fi
41
42 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
43
44 if [ "x${BUSER}" != "x" ]; then
45    USERGRP="--chuid ${BUSER}"
46    if [ "x${BGROUP}" != "x" ]; then
47       USERGRP="${USERGRP}:${BGROUP}"
48    fi
49 fi
50
51 case "$1" in
52    start)
53       echo -n "Starting ${DESC}: "
54       start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
55       RETVAL=$?
56       echo "${NAME}"
57       ;;
58    stop)
59       echo -n "Stopping ${DESC}: "
60       start-stop-daemon --oknodo --stop --quiet ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
61       RETVAL=$?
62       echo "${NAME}"
63       ;;
64    restart|force-reload)
65       $0 stop
66       sleep 5
67       $0 start
68       ;;
69    *)
70       echo "Usage: /etc/init.d/${NAME} {start|stop|restart|force-reload}" >&2
71       exit 1
72       ;;
73 esac
74 exit $RETVAL