summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2023-02-09 21:23:46 -0600
committerzachir <zachir@librem.one>2023-02-09 21:23:46 -0600
commit8f3224ef57423bad6a2fc9dbe38ced628591a6ca (patch)
tree8b20ba07490d20377a579c71a612e81159c4e3ce
parentb443dc867bfb6dd1619665b45fa9918aad08783d (diff)
add runit support
-rwxr-xr-xservicectl49
1 files changed, 45 insertions, 4 deletions
diff --git a/servicectl b/servicectl
index df96506..c26d5f2 100755
--- a/servicectl
+++ b/servicectl
@@ -20,15 +20,26 @@ reverse_array () {
## FIND INIT
INIT="$(readlink $(type init) )"
-if `type s6-rc >/dev/null`; then
+if `type s6-rc >/dev/null 2>&1`; then
S6=y
else
unset S6
fi
-if [ "$INIT" = "openrc-init" ]; then
- OPENRC=y
- unset RUNIT DINIT
+case "$INIT" in
+ "openrc-init") OPENRC=y ; unset RUNIT DINIT ;;
+ "runit-init") RUNIT=y ; unset OPENRC DINIT ;;
+ "*") print "Unknown init!\n"
+esac
+
+## CHECK INIT HELPER
+
+if [ -n "$RUNIT" ]; then
+ if `type rsm >/dev/null 2>&1`; then
+ RSM=y
+ else
+ unset RSM
+ fi
fi
## CHECK PRIVS
@@ -45,6 +56,12 @@ start_service () {
fi
if [ -n "$OPENRC" ]; then
$ROOTCMD rc-service $1 start
+ elif [ -n "$RUNIT" ]; then
+ if [ -n "$RSM" ]; then
+ $ROOTCMD rsm start $1
+ else
+ $ROOTCMD sv start $1
+ fi
fi
}
@@ -54,6 +71,12 @@ stop_service () {
fi
if [ -n "$OPENRC" ]; then
$ROOTCMD rc-service $1 stop
+ elif [ -n "$RUNIT" ]; then
+ if [ -n "$RSM" ]; then
+ $ROOTCMD rsm stop $1
+ else
+ $ROOTCMD sv stop $1
+ fi
fi
}
@@ -63,6 +86,12 @@ enable_service () {
fi
if [ -n "$OPENRC" ]; then
$ROOTCMD rc-update add $1 default
+ elif [ -n "$RUNIT" ]; then
+ if [ -n "$RSM" ]; then
+ $ROOTCMD rsm enable $1
+ else
+ print "enabling runit services manually not presently supported; use rsm\n"
+ fi
fi
}
@@ -72,6 +101,12 @@ disable_service () {
fi
if [ -n "$OPENRC" ]; then
$ROOTCMD rc-update del $1 default
+ elif [ -n "$RUNIT" ]; then
+ if [ -n "$RSM" ]; then
+ $ROOTCMD rsm disable $1
+ else
+ print "disabling runit services manually not presently supported; use rsm\n"
+ fi
fi
}
@@ -81,6 +116,12 @@ status_service () {
fi
if [ -n "$OPENRC" ]; then
$ROOTCMD rc-service status
+ elif [ -n "$RUNIT" ]; then
+ if [ -n "$RSM" ]; then
+ $ROOTCMD rsm status
+ else
+ print "getting status of runit services manually not presently supported; use rsm\n"
+ fi
fi
}