[Fuego] [PATCH] Add the function get_service_status to get status of service.
Wang Mingyu
wangmy at cn.fujitsu.com
Tue Feb 19 03:13:57 UTC 2019
Add the variable service_status to store the status of the service.
Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
scripts/fuego_board_function_lib.sh | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/scripts/fuego_board_function_lib.sh b/scripts/fuego_board_function_lib.sh
index 4c29bf3..41b94ba 100644
--- a/scripts/fuego_board_function_lib.sh
+++ b/scripts/fuego_board_function_lib.sh
@@ -11,6 +11,7 @@
init_manager="init_manager-not-set"
logger_service="logger_service-not-set"
+service_status="unknown"
# set_init_manager:
# detects and sets the init_manager variable, which indicates which
@@ -43,8 +44,29 @@ detect_logger_service() {
exec_service_on_target() {
if [ "$init_manager" = "systemd" ]
then
- systemctl $2 $1
+ systemctl $2 $1
else
- /etc/init.d/$1 $2
+ service $1 $2
fi
}
+
+# get_service_status:
+# get status of service
+# returns: status of service
+get_service_status() {
+ if [ "$init_manager" = "systemd" ]
+ then
+ service_status=$(systemctl is-active $1)
+ else
+ if service $1 status | grep "is running"
+ then
+ service_status="active"
+ else
+ if service $1 status | grep "is stopped"
+ then
+ service_status="inactive"
+ fi
+ fi
+ fi
+ echo $service_status
+}
--
1.8.3.1
More information about the Fuego
mailing list