]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/platforms/debian/bacula-dir.in
Allow custom variables and checks from debian/ubuntu startup scripts
[bacula/bacula] / bacula / platforms / debian / bacula-dir.in
index 19a342ddefa8335d0a6e10be4c0c4a7df1728f98..73253dce8e0590ff45472861a3f6c88bce4e0f4c 100644 (file)
@@ -8,9 +8,19 @@
 #
 #  For Bacula release @VERSION@ (@DATE@) -- @DISTNAME@
 #
+### BEGIN INIT INFO
+# Provides:         bacula-dir
+# Required-Start:    $network
+# Required-Stop:     $network
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start @BACULA@ Director daemon at boot time
+# Description:      Enable @BACULA@ Director.
+### END INIT INFO
+#
 
 NAME="bacula-dir"
-DESC="Bacula Director"
+DESC="@BACULA@ Director"
 DAEMON=@sbindir@/${NAME}
 BUSER=@dir_user@
 BGROUP=@dir_group@
@@ -25,24 +35,30 @@ if [ -n "`getent services ${NAME}`" ]; then
    BPORT=`getent services ${NAME} | awk '{ gsub("/tcp","",$2); print $2; }'`
 fi
 
+if [ -f /etc/default/$NAME ]; then
+   . /etc/default/$NAME
+fi
+
 PIDFILE=@piddir@/${NAME}.${BPORT}.pid
 
 if [ "x${BUSER}" != "x" ]; then
-   BOPTIONS="${BOPTIONS} -u ${BUSER}"
-fi
-if [ "x${BGROUP}" != "x" ]; then
-   BOPTIONS="${BOPTIONS} -g ${BGROUP}"
+   USERGRP="--chuid ${BUSER}"
+   if [ "x${BGROUP}" != "x" ]; then
+      USERGRP="${USERGRP}:${BGROUP}"
+   fi
 fi
 
 case "$1" in
    start)
       echo -n "Starting ${DESC}: "
-      start-stop-daemon --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- ${BOPTIONS}
+      start-stop-daemon --start --quiet --pidfile ${PIDFILE} ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
+      RETVAL=$?
       echo "${NAME}"
       ;;
    stop)
       echo -n "Stopping ${DESC}: "
-      start-stop-daemon --oknodo --stop --quiet --exec ${DAEMON} -- ${BOPTIONS}
+      start-stop-daemon --oknodo --stop --quiet ${USERGRP} --exec ${DAEMON} -- ${BOPTIONS}
+      RETVAL=$?
       echo "${NAME}"
       ;;
    restart|force-reload)
@@ -55,4 +71,4 @@ case "$1" in
       exit 1
       ;;
 esac
-exit 0
+exit $RETVAL