Skip to content

Commit cd19187

Browse files
committed
Adds systemd compatible service status check. Closes hestiacp#247.
1 parent a93a094 commit cd19187

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

bin/v-list-sys-services

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,16 @@ get_srv_state() {
2323
proc_name=${2-$1}
2424

2525
# Check service status
26-
status=$(service $srv status 2>/dev/null)
27-
rc=$?
28-
stopped=$(echo $status| grep stop)
26+
27+
# Check if systemd is used as init system
28+
if [[ $(systemctl) =~ -\.mount ]]; then
29+
$(systemctl -q is-active $srv)
30+
rc=$?
31+
else
32+
status=$(service $srv status 2>/dev/null)
33+
rc=$?
34+
stopped=$(echo $status| grep stop)
35+
fi
2936

3037
if [ "$rc" -eq 0 ] && [ -z "$stopped" ]; then
3138
state='running'

0 commit comments

Comments
 (0)