Skip to content
Snippets Groups Projects
Commit 2c5c43fa authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

doplneny exit stavy do funkce status; prejmenovany funkce start, stop, status

parent 1dbe3da4
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,7 @@ LOCK_FILE="/var/lock/warden-server"
SCRIPTNAME=`basename "$0"`
# check if daemon is present and executable
test -x $DAEMON || exit 0
test -x $DAEMON || exit 1
if [ $UID -ne 0 ]; then
echo "You must be root for runnnig this script!"
......@@ -63,8 +63,7 @@ usage() {
}
check_status() {
/bin/ps axo pid,comm | grep -q "warden-server*"; RET_VAL=`echo $?`
if [ $RET_VAL -eq 0 ]; then
if /bin/ps axo pid,comm | grep -q "warden-server*"; then
STATUS=1 # true - warden is running
else
STATUS=0 # false - warden is not running
......@@ -76,7 +75,7 @@ get_pid() {
return $PID
}
warden_start() {
start() {
check_status
if [ $STATUS -eq 1 ]; then
get_pid PID
......@@ -90,7 +89,7 @@ warden_start() {
fi
}
warden_stop() {
stop() {
check_status
if [ $STATUS -eq 1 ]; then
logger -s "Stopping Warden server daemon ..."
......@@ -98,7 +97,7 @@ warden_stop() {
PID=`cat $PID_FILE`
kill -1 $PID
rm -f $LOCK_FILE
logger -s "Warden server daemon is stopped (pid $PID)."
logger -s "Warden server daemon (pid $PID) is stopped."
else
echo "Unable to stop Warden server daemon. Try to use: $SCRIPTNAME force-stop"
fi
......@@ -107,17 +106,19 @@ warden_stop() {
fi
}
warden_status() {
status() {
check_status
if [ $STATUS -eq 1 ]; then
get_pid PID
echo "Warden daemon is running (pid $PID)."
exit 0
else
echo "Warden daemon is NOT running."
exit 1
fi
}
warden_force_stop() {
force_stop() {
check_status
if [ $STATUS -eq 1 ]; then
logger -s "Force stopping Warden server daemon ..."
......@@ -134,16 +135,16 @@ warden_force_stop() {
case $1 in
status)
warden_status
status
;;
start)
warden_start
start
;;
stop)
warden_stop
stop
;;
force-stop)
warden_force_stop
force_stop
;;
restart)
$0 stop
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment