49 lines
1.1 KiB
Bash
49 lines
1.1 KiB
Bash
|
#!/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
|
||
|
}
|