From a86cdb93416c154cfbf108add370cea4dfc7a517 Mon Sep 17 00:00:00 2001 From: T0MuX Date: Mon, 15 Apr 2024 06:05:24 +0200 Subject: [PATCH] +runctl.sh --- runctl/runctl.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 runctl/runctl.sh diff --git a/runctl/runctl.sh b/runctl/runctl.sh new file mode 100755 index 0000000..a699594 --- /dev/null +++ b/runctl/runctl.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# This Snippet can be used as a script, placed in ~/.local/bin, or as a snippet in your ~/.bashrc + +# Snippet Runit +runctl() { + if [ ! -d /etc/runit/sv/$2 ] + then + echo "Service $2 doesn't exist." + else + case $1 in + start) + echo Starting $2 ... + sudo sv start $2;; + stop) + echo Stopping $2 ... + sudo sv stop $2 ...;; + status) + if [ ! -d /run/runit/service/$2 ] + then echo "Service $2 is not enabled." + else sudo sv status $2 + fi;; + enable) + echo Enabling $2 ... + if [ -d /run/runit/service/$2 ] + then echo "Service $2 is already enabled." + else sudo ln -s /etc/runit/sv/$2 /run/runit/service/ + fi;; + disable) + echo Disabling $2 ... + sudo rm -rf /run/runit/service/$2;; + *) + echo "runctl is a bash snippet to easily manipulate runit services." + echo "" + echo "Usage :" + echo " runctl