I'm an avid IRC user, and I'm using XMPP to idle on Tails' chatrooms. Since protocols tend to only work when one is connected, they're both running inside a tmux session, acting as a bouncer. But now that my hypervisor is automatically rebooting to apply security updates, and during power cuts via nut, I needed a way to automatically restart the bouncer. Since it's running in an Alpine Linux container, here is my solution in the form of an OpenRC service script, because I couldn't find one on the internet:
#!/sbin/openrc-run
USER=jvoisin
name="chat"
command_user="$USER"
command=/usr/bin/tmux
command_args="new-session -s chat -d '/usr/bin/weechat' \; new-window '/usr/bin/profanity' \; select-window -t -1"
pidfile="/run/$SVCNAME.pid"
depend() {
need net
use dns
}
stop() {
su "$USER" -c 'tmux kill-session chat'
}