From 0c11064839678de568b21763c9960b2690e4529d Mon Sep 17 00:00:00 2001 From: zachir Date: Tue, 25 Apr 2023 12:49:45 -0500 Subject: add systemd support to servicectl --- servicectl | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'servicectl') diff --git a/servicectl b/servicectl index c26d5f2..698d3e4 100755 --- a/servicectl +++ b/servicectl @@ -19,7 +19,7 @@ reverse_array () { ## FIND INIT -INIT="$(readlink $(type init) )" +INIT="$(basename $(readlink $(type init)))" if `type s6-rc >/dev/null 2>&1`; then S6=y else @@ -27,8 +27,9 @@ else fi case "$INIT" in - "openrc-init") OPENRC=y ; unset RUNIT DINIT ;; - "runit-init") RUNIT=y ; unset OPENRC DINIT ;; + "openrc-init") OPENRC=y ; unset DINIT RUNIT SYSTEMD ;; + "runit-init") RUNIT=y ; unset DINIT OPENRC SYSTEMD ;; + "systemd") SYSTEMD=y ; unset DINIT OPENRC RUNIT ;; "*") print "Unknown init!\n" esac @@ -62,6 +63,8 @@ start_service () { else $ROOTCMD sv start $1 fi + elif [ -n "$SYSTEMD" ]; then + $ROOTCMD systemctl start $1 fi } @@ -77,6 +80,8 @@ stop_service () { else $ROOTCMD sv stop $1 fi + elif [ -n "$SYSTEMD" ]; then + $ROOTCMD systemctl stop $1 fi } @@ -92,6 +97,8 @@ enable_service () { else print "enabling runit services manually not presently supported; use rsm\n" fi + elif [ -n "$SYSTEMD" ]; then + $ROOTCMD systemctl enable $1 fi } @@ -107,6 +114,8 @@ disable_service () { else print "disabling runit services manually not presently supported; use rsm\n" fi + elif [ -n "$SYSTEMD" ]; then + $ROOTCMD systemctl disable $1 fi } @@ -122,6 +131,8 @@ status_service () { else print "getting status of runit services manually not presently supported; use rsm\n" fi + elif [ -n "$SYSTEMD" ]; then + $ROOTCMD systemctl status fi } -- cgit v1.2.3