|
@@ -20,9 +20,12 @@ the following:
|
|
|
#
|
|
|
|
|
|
COL=70
|
|
|
+WCOL=50
|
|
|
SET_COL="echo -en \\033[${COL}G"
|
|
|
+SET_WCOL="echo -en \\033[${WCOL}G"
|
|
|
NORMAL="echo -en \\033[0;39m"
|
|
|
SUCCESS="echo -en \\033[1;32m"
|
|
|
+WARNING="echo -en \\033[1;33m"
|
|
|
FAILURE="echo -en \\033[1;31m"
|
|
|
|
|
|
#
|
|
@@ -73,6 +76,14 @@ print_status()
|
|
|
$NORMAL
|
|
|
echo " ]"
|
|
|
;;
|
|
|
+ warning)
|
|
|
+ $SET_COL
|
|
|
+ echo -n "[ "
|
|
|
+ $WARNING
|
|
|
+ echo -n "ATTN"
|
|
|
+ $NORMAL
|
|
|
+ echo " ]"
|
|
|
+ ;;
|
|
|
failure)
|
|
|
$SET_COL
|
|
|
echo -n "["
|
|
@@ -140,14 +151,18 @@ loadproc()
|
|
|
# parameters giving to this function from the script) and then check the
|
|
|
# return value
|
|
|
#
|
|
|
+
|
|
|
$*
|
|
|
evaluate_retval
|
|
|
else
|
|
|
#
|
|
|
-# The variable $pid was not empty, meaning it was already running. We
|
|
|
-# print [FAILED] now
|
|
|
+# The variable $pid was not empty, meaning it was already running. We'll
|
|
|
+# print [ ATTN ] now
|
|
|
#
|
|
|
- print_status failure
|
|
|
+
|
|
|
+ $SET_WCOL
|
|
|
+ echo -n "Already running"
|
|
|
+ print_status warning
|
|
|
fi
|
|
|
|
|
|
}
|
|
@@ -215,15 +230,19 @@ killproc()
|
|
|
# If $pid contains something from the previous for loop it means one or
|
|
|
# more PID's were found that belongs to the processes to be killed
|
|
|
#
|
|
|
+
|
|
|
if [ -n "$pid" ]
|
|
|
then
|
|
|
+
|
|
|
#
|
|
|
# If no kill level was specified we'll try -TERM first and then sleep
|
|
|
# for 2 seconds to allow the kill to be completed
|
|
|
#
|
|
|
+
|
|
|
if [ "$nolevel" = 1 ]
|
|
|
then
|
|
|
/bin/kill -TERM $pid
|
|
|
+
|
|
|
#
|
|
|
# If after -TERM the PID still exists we'll wait 2 seconds before
|
|
|
# trying to kill it with -KILL. If the PID still exist after that, wait
|
|
@@ -250,20 +269,25 @@ killproc()
|
|
|
# If after the -KILL it still exists it can't be killed for some reason
|
|
|
# and we'll print [FAILED]
|
|
|
#
|
|
|
+
|
|
|
print_status failure
|
|
|
else
|
|
|
+
|
|
|
#
|
|
|
# It was killed, remove possible stale PID file in /var/run and
|
|
|
# print [ OK ]
|
|
|
#
|
|
|
+
|
|
|
/bin/rm -f /var/run/$base.pid
|
|
|
print_status success
|
|
|
fi
|
|
|
else
|
|
|
+
|
|
|
#
|
|
|
# A kill level was provided. Kill with the provided kill level and wait
|
|
|
# for 2 seconds to allow the kill to be completed
|
|
|
#
|
|
|
+
|
|
|
/bin/kill $killlevel $pid
|
|
|
if /bin/ps h $pid > /dev/null 2>&1
|
|
|
then
|
|
@@ -272,27 +296,35 @@ killproc()
|
|
|
/bin/ps h $pid >/dev/null 2>&1
|
|
|
if [ $? = 0 ]
|
|
|
then
|
|
|
+
|
|
|
#
|
|
|
# If ps' return value is 0 it means it ran ok which indicates that the
|
|
|
# PID still exists. This means the process wasn't killed properly with
|
|
|
# the signal provided. Print [FAILED]
|
|
|
#
|
|
|
+
|
|
|
print_status failure
|
|
|
else
|
|
|
+
|
|
|
#
|
|
|
# If the return value was 1 or higher it means the PID didn't exist
|
|
|
# anymore which means it was killed successfully. Remove possible stale
|
|
|
# PID file and print [ OK ]
|
|
|
#
|
|
|
+
|
|
|
/bin/rm -f /var/run/$base.pid
|
|
|
print_status success
|
|
|
fi
|
|
|
fi
|
|
|
else
|
|
|
+
|
|
|
#
|
|
|
-# The PID didn't exist so we can't attempt to kill it. Print [FAILED]
|
|
|
+# The PID didn't exist so we can't attempt to kill it. Print [ ATTN ]
|
|
|
#
|
|
|
- print_status failure
|
|
|
+
|
|
|
+ $SET_WCOL
|
|
|
+ echo -n "Not running"
|
|
|
+ print_status warning
|
|
|
fi
|
|
|
}
|
|
|
|
|
@@ -332,7 +364,6 @@ reloadproc()
|
|
|
# killlevel variable to the value of $2 (the second parameter)
|
|
|
#
|
|
|
|
|
|
-
|
|
|
if [ -n "$2" ]
|
|
|
then
|
|
|
killlevel=-$2
|
|
@@ -375,6 +406,7 @@ reloadproc()
|
|
|
/bin/kill -SIGHUP $pid
|
|
|
evaluate_retval
|
|
|
else
|
|
|
+
|
|
|
#
|
|
|
# Else we will use the provided signal
|
|
|
#
|
|
@@ -383,12 +415,15 @@ reloadproc()
|
|
|
evaluate_retval
|
|
|
fi
|
|
|
else
|
|
|
+
|
|
|
#
|
|
|
-# If $pid is empty no PID's have been found that belong to the process
|
|
|
-# and print [FAILED]
|
|
|
+# If $pid is empty no PID's have been found that belong to the process.
|
|
|
+# Print [ ATTN ]
|
|
|
#
|
|
|
|
|
|
- print_status failure
|
|
|
+ $SET_WCOL
|
|
|
+ echo -n "Not running"
|
|
|
+ print_status warning
|
|
|
fi
|
|
|
}
|
|
|
|
|
@@ -418,10 +453,12 @@ statusproc()
|
|
|
pid=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $1)
|
|
|
if [ -n "$pid" ]
|
|
|
then
|
|
|
+
|
|
|
#
|
|
|
# If $pid contains something, the process is running, print the contents
|
|
|
# of the $pid variable
|
|
|
#
|
|
|
+
|
|
|
echo "$1 running with Process ID $pid"
|
|
|
return 0
|
|
|
fi
|