Commit fd99030f authored by Vitaly Lipatov's avatar Vitaly Lipatov

serv status: improve running state detection

parent 04bc80ba
#!/bin/sh #!/bin/sh
# #
# Copyright (C) 2012, 2013, 2016 Etersoft # Copyright (C) 2012, 2013, 2016, 2017 Etersoft
# Copyright (C) 2012, 2013, 2016 Vitaly Lipatov <lav@etersoft.ru> # Copyright (C) 2012, 2013, 2016, 2017 Vitaly Lipatov <lav@etersoft.ru>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by # it under the terms of the GNU Affero General Public License as published by
...@@ -21,14 +21,18 @@ ...@@ -21,14 +21,18 @@
is_service_running() is_service_running()
{ {
local SERVICE="$1" local SERVICE="$1"
local OUTPUT
# TODO: real status can be checked only with grep output
case $SERVICETYPE in case $SERVICETYPE in
service-chkconfig|service-upstart) service-chkconfig|service-upstart)
if is_anyservice $1 ; then if is_anyservice $1 ; then
$SUDO anyservice $1 status >/dev/null 2>/dev/null OUTPUT="$($SUDO anyservice $1 status 2>/dev/null)" || return 1
return echo "$OUTPUT" | grep -q "is stopped" && return 1
return 0
fi fi
$SUDO service $1 status >/dev/null 2>/dev/null OUTPUT="$($SUDO service $1 status 2>/dev/null)" || return 1
echo "$OUTPUT" | grep -q "is stopped" && return 1
return 0
;; ;;
service-initd|service-update) service-initd|service-update)
$SUDO $INITDIR/$1 status >/dev/null 2>/dev/null $SUDO $INITDIR/$1 status >/dev/null 2>/dev/null
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment