X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fscripts%2Fbacula-ctl-dir.in;fp=bacula%2Fscripts%2Fbacula-ctl-dir.in;h=ab1eaaca12451a1e7cb8397dc057f2624e324396;hb=9fb3ae02b78da24e7edd75e744477d3bdada1753;hp=745651c8a348b3bf87131d0d074d2705cb359173;hpb=16e984355f65340e5da81d192c57f2d00b3c2c57;p=bacula%2Fbacula diff --git a/bacula/scripts/bacula-ctl-dir.in b/bacula/scripts/bacula-ctl-dir.in index 745651c8a3..ab1eaaca12 100644 --- a/bacula/scripts/bacula-ctl-dir.in +++ b/bacula/scripts/bacula-ctl-dir.in @@ -2,8 +2,7 @@ # # Bacula(R) - The Network Backup Solution # -# Copyright (C) 2000-2015 Kern Sibbald -# Copyright (C) 2000-2014 Free Software Foundation Europe e.V. +# Copyright (C) 2000-2016 Kern Sibbald # # The original author of Bacula is Kern Sibbald, with contributions # from many others, a complete list can be found in the file AUTHORS. @@ -19,7 +18,7 @@ # Bacula(R) is a registered trademark of Kern Sibbald. # # bacula-ctl-dir This shell script takes care of starting and stopping -# the bacula Director daemon +# the bacula Director 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. @@ -53,7 +52,7 @@ DIR_PORT=@dir_port@ DIR_USER=@dir_user@ DIR_GROUP=@dir_group@ Bacula="@BACULA@" -PIDOF=@PIDOF@ +PIDOF=@PIDOF@ # A function to stop a program. killproc() { @@ -82,31 +81,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" @@ -134,8 +133,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 @@ -174,12 +173,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 @@ -187,8 +186,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 @@ -219,29 +218,29 @@ fi case "$1" in start) [ -x ${BACDIRBIN}/bacula-dir ] && { - echo "Starting the $Bacula Director daemon" - OPTIONS='' - if [ "${DIR_USER}" != '' ]; then - OPTIONS="${OPTIONS} -u ${DIR_USER}" - fi + echo "Starting the $Bacula Director daemon" + OPTIONS='' + if [ "${DIR_USER}" != '' ]; then + OPTIONS="${OPTIONS} -u ${DIR_USER}" + fi - if [ "${DIR_GROUP}" != '' ]; then - OPTIONS="${OPTIONS} -g ${DIR_GROUP}" - fi + if [ "${DIR_GROUP}" != '' ]; then + OPTIONS="${OPTIONS} -g ${DIR_GROUP}" + fi - if [ "x${VALGRIND_DIR}" = "x1" ]; then - valgrind --leak-check=full ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf - else - ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf - fi - sleep 1 + if [ "x${VALGRIND_DIR}" = "x1" ]; then + valgrind --leak-check=full ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf + else + ${BACDIRBIN}/bacula-dir $2 $3 ${OPTIONS} -v -c ${BACDIRCFG}/bacula-dir.conf + fi + sleep 1 } ;; stop) [ -x ${BACDIRBIN}/bacula-dir ] && { - echo "Stopping the $Bacula Director daemon" - killproc ${BACDIRBIN}/bacula-dir ${DIR_PORT} $2 + echo "Stopping the $Bacula Director daemon" + killproc ${BACDIRBIN}/bacula-dir ${DIR_PORT} $2 } ;;