X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fplatforms%2Fsuse%2Fbacula.in;h=e8d344dc9b56ef0cf813201ecfe9b61d662b86ad;hb=dbf74791ad3def6973cb45aa916bff24e8137ade;hp=1c7545d33fbc7153a4733c73804558161c8fd4e2;hpb=98710e3c7daff367b4daedeb55b9b651cf89bccb;p=bacula%2Fbacula diff --git a/bacula/platforms/suse/bacula.in b/bacula/platforms/suse/bacula.in index 1c7545d33f..e8d344dc9b 100644 --- a/bacula/platforms/suse/bacula.in +++ b/bacula/platforms/suse/bacula.in @@ -1,7 +1,7 @@ #! /bin/sh # # bacula This shell script takes care of starting and stopping -# the bacula daemons. +# the bacula daemons. # # 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. @@ -12,12 +12,12 @@ # description: It comes by night and sucks the vital essence from your computers. # ### BEGIN INIT INFO -# Provides: bacula -# Required-Start: network mysql +# Provides: bacula +# Required-Start: network mysql # Required-Stop: -# Default-Start: 2 3 5 +# Default-Start: 3 5 # Default-Stop: -# Description: run bacula daemon(s) +# Description: run bacula daemon(s) ### END INIT INFO PSCMD="@PSCMD@" @@ -29,17 +29,17 @@ killproc() { RC=0 # Test syntax. if [ $# = 0 ]; then - echo "Usage: killproc {program} [signal]" - return 1 + echo "Usage: killproc {program} [signal]" + return 1 fi notset=0 # check for third arg to be kill level if [ "$3" != "" ] ; then - killlevel=$3 + killlevel=$3 else - notset=1 - killlevel="-9" + notset=1 + killlevel="-9" fi # Get base program name @@ -50,39 +50,39 @@ 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" - # 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 - fi + 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" + # 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 + fi else - failure "$base shutdown" + failure "$base shutdown" fi # Remove pid file if any. if [ "$notset" = "1" ]; then - rm -f ${PIDDIR}/$base.$2.pid + rm -f ${PIDDIR}/$base.$2.pid fi return $RC } @@ -92,8 +92,8 @@ pidofproc() { pid="" # Test syntax. if [ $# = 0 ] ; then - echo "Usage: pidofproc {program}" - return 1 + echo "Usage: pidofproc {program}" + return 1 fi # Get base program name @@ -101,11 +101,11 @@ pidofproc() { # First try PID file if [ -f ${PIDDIR}/$base.$2.pid ] ; then - pid=`head -1 ${PIDDIR}/$base.$2.pid` - if [ "$pid" != "" ] ; then - echo $pid - return 0 - fi + pid=`head -1 ${PIDDIR}/$base.$2.pid` + if [ "$pid" != "" ] ; then + echo $pid + return 0 + fi fi # Next try "pidof" @@ -125,8 +125,8 @@ pidofproc() { status() { # Test syntax. if [ $# = 0 ] ; then - echo "Usage: status {program}" - return 1 + echo "Usage: status {program}" + return 1 fi # Get base program name @@ -141,27 +141,27 @@ 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 # Next try the PID files if [ -f ${PIDDIR}/$base.$2.pid ] ; then - pid=`head -1 ${PIDDIR}/$base.$2.pid` - if [ "$pid" != "" ] ; then - echo "$base not running, but pid file exists" - return 1 - fi + pid=`head -1 ${PIDDIR}/$base.$2.pid` + if [ "$pid" != "" ] ; then + echo "$base not running, but pid file exists" + return 1 + fi fi # See if the subsys lock exists if [ -f ${SUBSYSDIR}/$base ] ; then - echo "$base not running, but subsys locked" - return 2 + echo "$base not running, but subsys locked" + return 2 fi echo "$base is stopped" return 3