summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-04-25 12:49:45 -0500
committerzachir <zachir@librem.one>2023-04-25 12:49:45 -0500
commit0c11064839678de568b21763c9960b2690e4529d (patch)
tree8076ba1f3e27caaccbbcc191402401cc1dc666f0
parent0535ace55b73046787fb1972539279cdea9341ed (diff)
add systemd support to servicectl
-rwxr-xr-xservicectl17
1 files changed, 14 insertions, 3 deletions
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
}