Add System V Init script and systemd unit, update README.md

This commit is contained in:
eleksir
2024-04-29 14:11:55 +03:00
parent 887643f62d
commit 3e532f46aa
3 changed files with 86 additions and 0 deletions

View File

@@ -48,6 +48,18 @@ Note2: MacOS has too tight (or intrusive) security measures, so running somethin
task. Reniced can be run via sudo as daemon or backbround process (say, in tmux). On linux systems usually there is no task. Reniced can be run via sudo as daemon or backbround process (say, in tmux). On linux systems usually there is no
such obstacle and if reniced run from user with id=0, its config should be placed at **/etc/reniced.yaml** such obstacle and if reniced run from user with id=0, its config should be placed at **/etc/reniced.yaml**
## Install as systemd service
Supplied systemd unit is ready to install in system as-is and should work ok. It expect to see reniced at
**/usr/sbin/reniced** and assume that reniced runs as foreground task - in config file "daemon" setting either absent or
set to false.
## Install as System V Init service
Unlike supplpied systemd unit, supplied System V Init script assumes reniced runs as daemon (in config file "daemon"
setting must be set to true). Script also expects to find pid-file at **/var/run/reniced.pid** and executable itself at
**/usr/sbin/reniced**.
## Special "thanks" ## Special "thanks"
To security assholes that disrupt workflows and make this world worse. To security assholes that disrupt workflows and make this world worse.

64
contrib/reniced.init Normal file
View File

@@ -0,0 +1,64 @@
#!/bin/bash
# Start/stop/restart reniced.
### BEGIN INIT INFO
# Provides: reniced
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the reniced service.
# Description: Service that periodically checks and changes runtime niceness of given (by name) processes.
### END INIT INFO
# Start reniced:
_start() {
echo -n "Starting Reniced daemon: /usr/sbin/reniced"
/usr/sbin/reniced
echo
}
# Stop reniced:
_stop() {
echo -n "Stopping Reniced daemon..."
if [ -r /var/run/reniced.pid ]; then
kill -HUP "$(cat /var/run/reniced.pid)"
rm -f "/var/run/reniced.pid"
else
killall -HUP -q reniced
fi
echo
}
# Restart renicedd:
_restart() {
_stop
sleep 1
_start
}
# Check if reniced is running
_status() {
if [ -e /var/run/reniced.pid ]; then
echo "reniced is running as pid $(cat /run/reniced.pid)."
else
echo "reniced is stopped."
exit 1
fi
}
case "$1" in
'start')
_start
;;
'stop')
_stop
;;
'restart')
_restart
;;
'status')
_status
;;
*)
echo "usage $0 start|stop|restart|status"
esac

10
contrib/reniced.service Normal file
View File

@@ -0,0 +1,10 @@
[Unit]
Description=Reniced Service
[Service]
ExecStart=/usr/sbin/reniced
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target