+runctl.sh
This commit is contained in:
parent
3d3b71378b
commit
a86cdb9341
1 changed files with 48 additions and 0 deletions
48
runctl/runctl.sh
Executable file
48
runctl/runctl.sh
Executable file
|
@ -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 <option> <service>"
|
||||||
|
echo ""
|
||||||
|
echo "Options :"
|
||||||
|
echo " start / stop / status / enable / disable"
|
||||||
|
echo ""
|
||||||
|
echo "Exemples :"
|
||||||
|
echo " runctl enable syncthing"
|
||||||
|
echo " runctl status mpd"
|
||||||
|
echo " runctl start sshd"
|
||||||
|
echo ""
|
||||||
|
esac
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
Loading…
Reference in a new issue