Add OpenRC script

This commit is contained in:
Josh W 2024-07-12 22:28:09 -04:00
parent 520097460b
commit 4dde8d94cb

View file

@ -0,0 +1,29 @@
#!/sbin/openrc-run
supervisor=supervise-daemon
name="tomservobot"
description="A custom bot for the local Matrix instance"
pidfile="/var/run/$name.pid"
user="tomservo"
script_args="./main.py"
script_exec="/srv/tomservobot/.venv/bin/python"
workdir="/srv/tomservobot/src"
depend() {
need net synapse
}
start() {
ebegin "Starting Tom Servo Bot"
cd $workdir || exit 1
start-stop-daemon --start --user "$user" --make-pidfile --pidfile "$pidfile" --chdir "$workdir" --exec "$script_exec" -- $script_args >> /var/log/tomservobot/bot.log 2>&1 &
eend $?
}
stop() {
ebegin "Stopping Tom Servo Bot"
start-stop-daemon --stop --pidfile "$pidfile"
eend $?
}