Imported Debian patch 2.5.2p1-3
[debian/amanda] / server-src / amcleanup.sh.in
index 2590932ca0841ff3a5e242260392da00337c70b7..cd60001ff165eb6c96526577bbda7eec227763d0 100644 (file)
@@ -48,25 +48,26 @@ else
 fi
 
 if test -h /proc/1/exe ; then
-       if test $# -eq 1 ; then
-               KILL_ENABLE=0
-               conf=$1
-               shift;
-       elif test $# -eq 2 && test "$1" == "-k" ; then
+       if test $# -ge 2 && test "$1" = "-k" ; then
                KILL_ENABLE=1
                conf=$2
                shift
                shift
+       elif test $# -ge 1 ; then
+               KILL_ENABLE=0
+               conf=$1
+               shift;
        else
                echo "Usage: amcleanup [-k] conf"
                exit 1
        fi
 else
-       if test $# -ne 1 ; then
+       if test $# -lt 1 ; then
                echo "Usage: amcleanup conf"
                exit 1
        else
                conf=$1
+               shift
                KILL_ENABLE=0
        fi
 fi
@@ -182,9 +183,9 @@ if test ${KILL_ENABLE} -eq 1 ; then
                while test ${KEEP_CHECKING} -ne 0 ; do
                        PIDS_THIS_PASS=0
                        for search_user in ${dumpuser} root ; do
-                               if test "${search_user}" == "${dumpuser}" ; then
+                               if test "${search_user}" = "${dumpuser}" ; then
                                        PROCESS_NAMES=${USER_PROCESS_NAMES}
-                               elif test "${search_user}" == "root" ; then
+                               elif test "${search_user}" = "root" ; then
                                        PROCESS_NAMES=${ROOT_PROCESS_NAMES}
                                fi
                                for search_pid in [0-9]* ; do
@@ -192,7 +193,7 @@ if test ${KILL_ENABLE} -eq 1 ; then
                                                ls -l /proc/${search_pid}/exe 2>/dev/null | grep ${search_name} >/dev/null
                                                match_name=$?
                                                pid_uid="`cat /proc/${search_pid}/status 2>/dev/null | grep Uid | awk '//{split($_,i); print i[2]}'`"
-                                               if test ${match_name} -eq 0  && test "${pid_uid}" == "${search_user}" ; then
+                                               if test ${match_name} -eq 0  && test "${pid_uid}" = "${search_user}" ; then
                                                        echo "amcleanup: Process ${search_name} found running at pid #${search_pid}."
                                                        kill_pid=${search_pid}
                                                        kill_name=${search_name}
@@ -207,11 +208,11 @@ if test ${KILL_ENABLE} -eq 1 ; then
                                        if test ! -z "${kill_pid}" ; then
                                                if test -d /proc/${kill_pid} ; then
                                                        echo "amcleanup: Sending process ${kill_pid} the TERM signal."
-                                                       kill -15 -- ${kill_pid}
+                                                       kill TERM -- ${kill_pid}
                                                        sleep 5
                                                        if test -d /proc/${kill_pid} ; then
                                                                echo "amcleanup: Sending process  ${kill_pid} the KILL signal."
-                                                               kill -9 -- ${kill_pid}
+                                                               kill KILL -- ${kill_pid}
                                                        fi
                                                        sleep 5
                                                        if test -d /proc/${kill_pid} ; then