mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-06-18 19:29:21 +01:00
Added [ ATTN ] warning message. instead of printing failed when a daemon
was already running, or already stopped, it'll now print "already running [ attn ]" or "not running [ attn ]" in green characters git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@706 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
parent
4e909626af
commit
f45bf82dcf
@ -20,9 +20,12 @@ the following:
|
|||||||
#
|
#
|
||||||
|
|
||||||
COL=70
|
COL=70
|
||||||
|
WCOL=50
|
||||||
SET_COL="echo -en \\033[${COL}G"
|
SET_COL="echo -en \\033[${COL}G"
|
||||||
|
SET_WCOL="echo -en \\033[${WCOL}G"
|
||||||
NORMAL="echo -en \\033[0;39m"
|
NORMAL="echo -en \\033[0;39m"
|
||||||
SUCCESS="echo -en \\033[1;32m"
|
SUCCESS="echo -en \\033[1;32m"
|
||||||
|
WARNING="echo -en \\033[1;33m"
|
||||||
FAILURE="echo -en \\033[1;31m"
|
FAILURE="echo -en \\033[1;31m"
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -73,6 +76,14 @@ print_status()
|
|||||||
$NORMAL
|
$NORMAL
|
||||||
echo " ]"
|
echo " ]"
|
||||||
;;
|
;;
|
||||||
|
warning)
|
||||||
|
$SET_COL
|
||||||
|
echo -n "[ "
|
||||||
|
$WARNING
|
||||||
|
echo -n "ATTN"
|
||||||
|
$NORMAL
|
||||||
|
echo " ]"
|
||||||
|
;;
|
||||||
failure)
|
failure)
|
||||||
$SET_COL
|
$SET_COL
|
||||||
echo -n "["
|
echo -n "["
|
||||||
@ -140,14 +151,18 @@ loadproc()
|
|||||||
# parameters giving to this function from the script) and then check the
|
# parameters giving to this function from the script) and then check the
|
||||||
# return value
|
# return value
|
||||||
#
|
#
|
||||||
|
|
||||||
$*
|
$*
|
||||||
evaluate_retval
|
evaluate_retval
|
||||||
else
|
else
|
||||||
#
|
#
|
||||||
# The variable $pid was not empty, meaning it was already running. We
|
# The variable $pid was not empty, meaning it was already running. We'll
|
||||||
# print [FAILED] now
|
# print [ ATTN ] now
|
||||||
#
|
#
|
||||||
print_status failure
|
|
||||||
|
$SET_WCOL
|
||||||
|
echo -n "Already running"
|
||||||
|
print_status warning
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -215,15 +230,19 @@ killproc()
|
|||||||
# If $pid contains something from the previous for loop it means one or
|
# 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
|
# more PID's were found that belongs to the processes to be killed
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -n "$pid" ]
|
if [ -n "$pid" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
#
|
#
|
||||||
# If no kill level was specified we'll try -TERM first and then sleep
|
# If no kill level was specified we'll try -TERM first and then sleep
|
||||||
# for 2 seconds to allow the kill to be completed
|
# for 2 seconds to allow the kill to be completed
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ "$nolevel" = 1 ]
|
if [ "$nolevel" = 1 ]
|
||||||
then
|
then
|
||||||
/bin/kill -TERM $pid
|
/bin/kill -TERM $pid
|
||||||
|
|
||||||
#
|
#
|
||||||
# If after -TERM the PID still exists we'll wait 2 seconds before
|
# 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
|
# 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
|
# If after the -KILL it still exists it can't be killed for some reason
|
||||||
# and we'll print [FAILED]
|
# and we'll print [FAILED]
|
||||||
#
|
#
|
||||||
|
|
||||||
print_status failure
|
print_status failure
|
||||||
else
|
else
|
||||||
|
|
||||||
#
|
#
|
||||||
# It was killed, remove possible stale PID file in /var/run and
|
# It was killed, remove possible stale PID file in /var/run and
|
||||||
# print [ OK ]
|
# print [ OK ]
|
||||||
#
|
#
|
||||||
|
|
||||||
/bin/rm -f /var/run/$base.pid
|
/bin/rm -f /var/run/$base.pid
|
||||||
print_status success
|
print_status success
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
#
|
#
|
||||||
# A kill level was provided. Kill with the provided kill level and wait
|
# A kill level was provided. Kill with the provided kill level and wait
|
||||||
# for 2 seconds to allow the kill to be completed
|
# for 2 seconds to allow the kill to be completed
|
||||||
#
|
#
|
||||||
|
|
||||||
/bin/kill $killlevel $pid
|
/bin/kill $killlevel $pid
|
||||||
if /bin/ps h $pid > /dev/null 2>&1
|
if /bin/ps h $pid > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
@ -272,27 +296,35 @@ killproc()
|
|||||||
/bin/ps h $pid >/dev/null 2>&1
|
/bin/ps h $pid >/dev/null 2>&1
|
||||||
if [ $? = 0 ]
|
if [ $? = 0 ]
|
||||||
then
|
then
|
||||||
|
|
||||||
#
|
#
|
||||||
# If ps' return value is 0 it means it ran ok which indicates that the
|
# 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
|
# PID still exists. This means the process wasn't killed properly with
|
||||||
# the signal provided. Print [FAILED]
|
# the signal provided. Print [FAILED]
|
||||||
#
|
#
|
||||||
|
|
||||||
print_status failure
|
print_status failure
|
||||||
else
|
else
|
||||||
|
|
||||||
#
|
#
|
||||||
# If the return value was 1 or higher it means the PID didn't exist
|
# 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
|
# anymore which means it was killed successfully. Remove possible stale
|
||||||
# PID file and print [ OK ]
|
# PID file and print [ OK ]
|
||||||
#
|
#
|
||||||
|
|
||||||
/bin/rm -f /var/run/$base.pid
|
/bin/rm -f /var/run/$base.pid
|
||||||
print_status success
|
print_status success
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
else
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +364,6 @@ reloadproc()
|
|||||||
# killlevel variable to the value of $2 (the second parameter)
|
# killlevel variable to the value of $2 (the second parameter)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
if [ -n "$2" ]
|
if [ -n "$2" ]
|
||||||
then
|
then
|
||||||
killlevel=-$2
|
killlevel=-$2
|
||||||
@ -375,6 +406,7 @@ reloadproc()
|
|||||||
/bin/kill -SIGHUP $pid
|
/bin/kill -SIGHUP $pid
|
||||||
evaluate_retval
|
evaluate_retval
|
||||||
else
|
else
|
||||||
|
|
||||||
#
|
#
|
||||||
# Else we will use the provided signal
|
# Else we will use the provided signal
|
||||||
#
|
#
|
||||||
@ -383,12 +415,15 @@ reloadproc()
|
|||||||
evaluate_retval
|
evaluate_retval
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
|
||||||
#
|
#
|
||||||
# If $pid is empty no PID's have been found that belong to the process
|
# If $pid is empty no PID's have been found that belong to the process.
|
||||||
# and print [FAILED]
|
# Print [ ATTN ]
|
||||||
#
|
#
|
||||||
|
|
||||||
print_status failure
|
$SET_WCOL
|
||||||
|
echo -n "Not running"
|
||||||
|
print_status warning
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,10 +453,12 @@ statusproc()
|
|||||||
pid=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $1)
|
pid=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $1)
|
||||||
if [ -n "$pid" ]
|
if [ -n "$pid" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
#
|
#
|
||||||
# If $pid contains something, the process is running, print the contents
|
# If $pid contains something, the process is running, print the contents
|
||||||
# of the $pid variable
|
# of the $pid variable
|
||||||
#
|
#
|
||||||
|
|
||||||
echo "$1 running with Process ID $pid"
|
echo "$1 running with Process ID $pid"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user