]> git.pld-linux.org Git - packages/bacula.git/blobdiff - bacula-dir.init
- no need to manually remove files on postun, ghost packaging does that already
[packages/bacula.git] / bacula-dir.init
index cabd42908664356e76b3489af6f3314d00a24f86..16e0654099e63bb800a2ac03ba56107511837fa2 100644 (file)
@@ -1,41 +1,82 @@
-#! /bin/sh
+#!/bin/sh
 #
-# bacula       This shell script takes care of starting and stopping
-#             the bacula Director daemon
+# bacula          This shell script takes care of starting and stopping
+#                 the bacula Director daemon
 #
-# chkconfig: 2345 92 99
+# chkconfig: 2345 92 08
 # description: It comes by night and sucks the vital essence from your computers.
 #
 
 # Source function library
 . /etc/rc.d/init.d/functions
 
+BACULA_DIR_USER="bacula"
+BACULA_DIR_GROUP="bacula"
+BACULA_DIR_OPTIONS=""
+[ -f /etc/sysconfig/bacula-dir ] && . /etc/sysconfig/bacula-dir
+
+start() {
+       # Check if the service is already running?
+       if [ -f /var/lock/subsys/bacula-dir ]; then
+               msg_already_running "Bacula Director"
+               return
+       fi
+
+       msg_starting "Bacula Director"
+       daemon /usr/sbin/bacula-dir -u  "$BACULA_DIR_USER" -g "$BACULA_DIR_GROUP" -c /etc/bacula/bacula-dir.conf $BACULA_DIR_OPTIONS
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bacula-dir
+}
+
+stop() {
+       if [ ! -f /var/lock/subsys/bacula-dir ]; then
+               msg_not_running "Bacula Director"
+               return
+       fi
+
+       # Stop daemons.
+       msg_stopping "Bacula Director"
+       killproc /usr/sbin/bacula-dir
+       rm -f /var/lock/subsys/bacula-dir
+}
+
+condrestart() {
+       if [ ! -f /var/lock/subsys/bacula-dir ]; then
+               msg_not_running  "Bacula Director"
+               RETVAL=$1
+               return
+       fi
+
+       stop
+       start
+}
+
 RETVAL=0
 case "$1" in
-    start)
-       msg_starting "Bacula Director"
-       daemon /usr/sbin/bacula-dir -u bacula -g bacula $2 -c /etc/bacula/bacula-dir.conf
-       RETVAL=$?
-       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bacula-dir
-       ;;
-    stop)
-       msg_stopping "Bacula Director"
-       killproc /usr/sbin//bacula-dir
-       RETVAL=$?
-       [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bacula-dir
-       ;;
-    restart)
-       $0 stop && sleep 5
-       $0 start
-       RETVAL=$?
-       ;;
-    status)
-       status /usr/sbin/bacula-dir
-       RETVAL=$?
-       ;;
-    *)
-       echo "Usage: $0 {start|stop|restart|status}"
-       exit 1
-       ;;
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart)
+       stop
+       sleep 5
+       start
+       ;;
+  try-restart)
+       condrestart 0
+       ;;
+  force-reload)
+       condrestart 7
+       ;;
+  status)
+       status bacula-dir
+       RETVAL=$?
+       ;;
+*)
+       msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+       exit 3
+       ;;
 esac
 exit $RETVAL
This page took 0.104919 seconds and 4 git commands to generate.