From cd19187fc5d6f51f07c146f69a5191f302deab99 Mon Sep 17 00:00:00 2001 From: Henri Schumacher Date: Fri, 5 Dec 2014 01:44:03 +0100 Subject: [PATCH] Adds systemd compatible service status check. Closes #247. --- bin/v-list-sys-services | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bin/v-list-sys-services b/bin/v-list-sys-services index ee1aa1ab4..22157799f 100755 --- a/bin/v-list-sys-services +++ b/bin/v-list-sys-services @@ -23,9 +23,16 @@ get_srv_state() { proc_name=${2-$1} # Check service status - status=$(service $srv status 2>/dev/null) - rc=$? - stopped=$(echo $status| grep stop) + + # Check if systemd is used as init system + if [[ $(systemctl) =~ -\.mount ]]; then + $(systemctl -q is-active $srv) + rc=$? + else + status=$(service $srv status 2>/dev/null) + rc=$? + stopped=$(echo $status| grep stop) + fi if [ "$rc" -eq 0 ] && [ -z "$stopped" ]; then state='running'