tomservobot/contrib/openrc/init.d/tomservobot
2024-07-12 23:01:43 -04:00

36 lines
753 B
Text

#!/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 $?
}