catcrafts.net/deploy/catcrafts-credits.service

44 lines
2.1 KiB
SYSTEMD
Raw Normal View History

2026-08-20 23:33:50 +02:00
# Read the bank and hand the incoming credits to the server.
#
# A USER unit, on the machine where nostrod holds the bunq connection, NOT on
# the web host. The web host cannot call bunq at all (the key is IP-restricted
# at the key level and bunq enforces it on every request), and it should not be
2026-08-20 23:33:50 +02:00
# able to: a bunq key can initiate payments, because bunq offers no read-only
# scope. So the server only ever reads a file.
#
# This unit holds no key either. tools/pull-and-ship-credits.sh asks nostrod
# (https://forgejo.catcrafts.net/Catcrafts/Nostro) over the system bus, and
# nostrod lets a program look at the accounts without ever handing it the key.
2026-08-20 23:33:50 +02:00
#
# Install:
# mkdir -p ~/.config/systemd/user
# cp deploy/catcrafts-credits.{service,timer} ~/.config/systemd/user/
# systemctl --user daemon-reload
# systemctl --user enable --now catcrafts-credits.timer
#
# WHO MAY LOOK. As nostrod ships, a program may look without a password only
# while you are logged in at this machine (an active local session, which a
# user unit counts as part of). So as installed above, this pulls while you are
# logged in and is refused otherwise: with nobody logged in, or on a machine
# you only reach over SSH. To have it run regardless, add the polkit rule in
# deploy/README.md ("Who may look"), and then, so the unit runs with nobody
# logged in at all:
# loginctl enable-linger "$USER"
# Lingering without the rule only produces a refused pull every hour.
2026-08-20 23:33:50 +02:00
#
# Watch: journalctl --user -u catcrafts-credits -f
[Unit]
Description=Pull bank credits from nostrod and ship them to catcrafts.net
2026-08-20 23:33:50 +02:00
Documentation=file:deploy/README.md
# Pointless without a route to the bank or to the server.
After=network-online.target
[Service]
Type=oneshot
WorkingDirectory=%h/repos/catcrafts.net
ExecStart=%h/repos/catcrafts.net/tools/pull-and-ship-credits.sh
# A failed pull must not look like a successful one. The script ships nothing
# when it could not read the account, and never overwrites the remote with an
# empty file, so a failure here leaves the server settling from the last good
# copy rather than from nothing.
2026-08-20 23:33:50 +02:00
SuccessExitStatus=0