]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/scripts/bacula-ctl-fd.in
Backport from Bacula Enterprise
[bacula/bacula] / bacula / scripts / bacula-ctl-fd.in
index 3393ce633bfad690f3d19f0a4cb185b9c97ff2d4..c359eaea614ebde9843244ecd9bd0d841daed8e4 100644 (file)
@@ -1,7 +1,25 @@
 #! /bin/sh
 #
+#   Bacula(R) - The Network Backup Solution
+#
+#   Copyright (C) 2000-2015 Kern Sibbald
+#   Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
+#
+#   The original author of Bacula is Kern Sibbald, with contributions
+#   from many others, a complete list can be found in the file AUTHORS.
+#
+#   You may use this file and others of this release according to the
+#   license defined in the LICENSE file, which includes the Affero General
+#   Public License, v3.0 ("AGPLv3") and some additional permissions and
+#   terms pursuant to its AGPLv3 Section 7.
+#
+#   This notice must be preserved when any source code is 
+#   conveyed and/or propagated.
+#
+#   Bacula(R) is a registered trademark of Kern Sibbald.
+#
 # bacula-ctl-fd This shell script takes care of starting and stopping
-#              the bacula File daemon.
+#               the bacula File daemon.
 #
 #   This is pretty much watered down version of the RedHat script
 #   that works on Solaris as well as Linux, but it won't work everywhere.
@@ -32,7 +50,7 @@ FD_PORT=@fd_port@
 FD_USER=@fd_user@
 FD_GROUP=@fd_group@
 Bacula="@BACULA@"
-PIDOF=@PIDOF@  
+PIDOF=@PIDOF@   
 
 # A function to stop a program.
 killproc() {
@@ -61,31 +79,31 @@ killproc() {
    # Kill it.
    if [ "$pid" != "" ] ; then
       if [ "$notset" = "1" ] ; then
-        if ${PS} -p "$pid">/dev/null 2>&1; then
-            # TERM first, then KILL if not dead
-            kill -TERM $pid 2>/dev/null
-            sleep 1
-            if ${PS} -p "$pid" >/dev/null 2>&1 ; then
-                sleep 1
-                if ${PS} -p "$pid" >/dev/null 2>&1 ; then
-                    sleep 3
-                    if ${PS} -p "$pid" >/dev/null 2>&1 ; then
-                        kill -KILL $pid 2>/dev/null
-                    fi
-                fi
-            fi
-         fi
-         ${PS} -p "$pid" >/dev/null 2>&1
-         RC=$?
-         [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
+         if ${PS} -p "$pid">/dev/null 2>&1; then
+             # TERM first, then KILL if not dead
+             kill -TERM $pid 2>/dev/null
+             sleep 1
+             if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+                 sleep 1
+                 if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+                     sleep 3
+                     if ${PS} -p "$pid" >/dev/null 2>&1 ; then
+                         kill -KILL $pid 2>/dev/null
+                     fi
+                 fi
+             fi
+          fi
+          ${PS} -p "$pid" >/dev/null 2>&1
+          RC=$?
+          [ $RC -eq 0 ] && failure "$base shutdown" || success "$base shutdown"
       #    RC=$((! $RC))
       # use specified level only
       else
-        if ${PS} -p "$pid" >/dev/null 2>&1; then
-           kill $killlevel $pid 2>/dev/null
-           RC=$?
-           [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
-        fi
+         if ${PS} -p "$pid" >/dev/null 2>&1; then
+            kill $killlevel $pid 2>/dev/null
+            RC=$?
+            [ $RC -eq 0 ] && success "$base $killlevel" || failure "$base $killlevel"
+         fi
       fi
    else
       failure "$base shutdown"
@@ -113,8 +131,8 @@ pidofproc() {
    if [ -f ${PIDDIR}/$base.$2.pid ] ; then
       pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
       if [ "$pid" != "" ] ; then
-        echo $pid
-        return 0
+         echo $pid
+         return 0
       fi
    fi
 
@@ -153,12 +171,12 @@ status() {
       return 0
    else
       pid=`${PSCMD} | ${AWK} 'BEGIN { prog=ARGV[1]; ARGC=1 } 
-           { if ((prog == $2) || (("(" prog ")") == $2) ||
-                (("[" prog "]") == $2) ||
-                ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
+            { if ((prog == $2) || (("(" prog ")") == $2) ||
+                 (("[" prog "]") == $2) ||
+                 ((prog ":") == $2)) { print $1 ; exit 0 } }' $1`
       if [ "$pid" != "" ] ; then
-        echo "$base (pid $pid) is running..."
-        return 0
+         echo "$base (pid $pid) is running..."
+         return 0
       fi
    fi
 
@@ -166,8 +184,8 @@ status() {
    if [ -f ${PIDDIR}/$base.$2.pid ] ; then
       pid=`head -n 1 ${PIDDIR}/$base.$2.pid`
       if [ "$pid" != "" ] ; then
-        echo "$base dead but pid file exists"
-        return 1
+         echo "$base dead but pid file exists"
+         return 1
       fi
    fi
    # See if the subsys lock exists
@@ -198,29 +216,29 @@ fi
 case "$1" in
    start)
       [ -x ${BACFDBIN}/bacula-fd ] && {
-        echo "Starting the $Bacula File daemon"
-        OPTIONS=''
-        if [ "${FD_USER}" != '' ]; then
-           OPTIONS="${OPTIONS} -u ${FD_USER}"
-        fi
-
-        if [ "${FD_GROUP}" != '' ]; then
-           OPTIONS="${OPTIONS} -g ${FD_GROUP}"
-        fi
-
-        if [ "x${VALGRIND_FD}" = "x1" ]; then
-           valgrind --leak-check=full ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
-        else
-           ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
-        fi
+         echo "Starting the $Bacula File daemon"
+         OPTIONS=''
+         if [ "${FD_USER}" != '' ]; then
+            OPTIONS="${OPTIONS} -u ${FD_USER}"
+         fi
+
+         if [ "${FD_GROUP}" != '' ]; then
+            OPTIONS="${OPTIONS} -g ${FD_GROUP}"
+         fi
+
+         if [ "x${VALGRIND_FD}" = "x1" ]; then
+            valgrind --leak-check=full ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
+         else
+            ${BACFDBIN}/bacula-fd $2 $3 ${OPTIONS} -v -c ${BACFDCFG}/bacula-fd.conf
+         fi
       }
       ;;
 
    stop)
       # Stop the FD first so that SD will fail jobs and update catalog
       [ -x ${BACFDBIN}/bacula-fd ] && {
-        echo "Stopping the $Bacula File daemon"
-        killproc ${BACFDBIN}/bacula-fd ${FD_PORT}
+         echo "Stopping the $Bacula File daemon"
+         killproc ${BACFDBIN}/bacula-fd ${FD_PORT} $2
       }
       ;;