#!/usr/bin/env bash # # qdb/setup.sh --- wire up the qdb systemd *user* services. # # Run this as the user the bot should run as. That user must be a # member of group `venusia` (so the watcher can write quotes/, which # is group-venusia setgid). # # This only handles the systemd units. The Comic Chat render path has # separate, root-level dependencies (ruby, rmagick, /opt/spittoon) --- # see the "Comic Chat" section of README.txt. qdb works without them; # /comic just returns a graceful error until they are in place. # # The unit files in systemd/ are written for the canonical deployment # path (/var/gopher/applets/qdb). This script rewrites that path to # wherever the qdb directory actually lives, so it also works for an # out-of-tree checkout. set -eu HERE="$(cd "$(dirname "$0")" && pwd)" UNITS="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user" mkdir -p "$UNITS" for u in qdb-stunnel.service qdb-ii.service qdb-watch.service \ qdb-logprune.service qdb-logprune.timer; do sed "s#/var/gopher/applets/qdb#$HERE#g" "$HERE/systemd/$u" > "$UNITS/$u" echo "installed $UNITS/$u" done systemctl --user daemon-reload echo echo "Units installed and reloaded. Review them, then bring qdb online:" echo echo " systemctl --user enable --now qdb-ii qdb-watch" echo echo "Optional, also:" echo " systemctl --user enable --now qdb-logprune.timer # weekly log prune" echo " systemctl --user enable --now qdb-stunnel # only if IRC server is REMOTE" echo echo "Follow it connecting and joining ${QDB_IRC_CHAN:-#main}:" echo echo " journalctl --user -u qdb-ii -u qdb-watch -f" echo echo "If the bot should keep running after you log out:" echo echo " loginctl enable-linger \"\$USER\""