Continuous-deployment helpers for running bitnsbot on a Raspberry Pi (or any
systemd Linux host). The runtime package is self-contained under
/opt/bitnsbot:
| Path | What |
|---|---|
/opt/bitnsbot/bitnsbot |
the binary |
/opt/bitnsbot/bitnsbot.conf |
config (name=value; chmod 600 — holds secrets) |
/opt/bitnsbot/bitnsbot.db |
bbolt database (created on first run) |
/opt/bitnsbot/update.sh |
copy of the auto-update script (run by cron) |
/opt/bitnsbot/deploy.env |
records REPO_DIR / BUILD_USER for updates |
The source checkout stays where you cloned it (e.g. /home/pi/bitnsbot); the
scripts build there, as the checkout's owner, and only copy the binary into
/opt.
-
Go,
git, andsystemdon the host; the repo cloned (default assumption:/home/pi/bitnsbot, owned bypi). -
originreachable forgit fetch. The public GitHub repo works over HTTPS with no credentials; for a private remote, givepia read-only deploy key. -
A Bitcoin Core systemd unit named
bitcoind.service(the bot's unit is orderedAfter=bitcoind.service). If yours has a different name, edit thatAfter=line in/etc/systemd/system/bitnsbot.service— an unknown unit name there is simply ignored, so a wrong name costs ordering, not startup. -
Bitcoin Core itself needs three things set in
bitcoin.conffor the bot to use everything it can:txindex=1 # /info on any transaction rest=1 # the address index is built over REST zmqpubhashblock=tcp://127.0.0.1:28332 # new-block notifications zmqpubrawtx=tcp://127.0.0.1:28333 # mempool notifications for watchesNone are strictly required to start: without ZMQ the bot answers commands but never notifies, and without
rest=1address history stays unavailable.
sudo ./scripts/install.sh # build + test, install service + cron, start
sudo ./scripts/uninstall.sh # stop + remove service and cron (keeps data)
sudo ./scripts/uninstall.sh --purge # also delete /opt/bitnsbot and the loginstall.sh builds and tests first and installs nothing if either fails. On
the first run it drops a config template at /opt/bitnsbot/bitnsbot.conf and
does not start the service — edit that file (at least bot-token), then:
sudo systemctl start bitnsbotinstall.sh schedules /etc/cron.d/bitnsbot to run update.sh every 5 minutes.
Each run:
git fetch origin master; ifHEADalready equalsorigin/master, it exits silently (so the cron log only grows on real updates).- Otherwise checks out
master, fast-forwards toorigin/master, then builds and runs the full test suite. - Only if both pass does it atomically swap in the new binary and
systemctl restart bitnsbot. A failed build or test leaves the running binary untouched and logs the failure.
A flock guards against overlapping runs (a build+test can take longer than the
5-minute interval). Logs go to /var/log/bitnsbot-update.log.
Follow along with:
journalctl -u bitnsbot -f # the service
tail -f /var/log/bitnsbot-update.log # auto-updates- Updates only ever fast-forward
mastertoorigin/master. If the Pi's checkout is ahead of or has diverged fromorigin/master(e.g. you made local commits), the update is skipped — nothing is fast-forwarded, discarded, or redeployed. - Changing these scripts themselves requires re-running
install.sh(cron runs the copy in/opt, not the one in the repo). - Override defaults with env vars, e.g.
sudo BUILD_USER=someone ./scripts/install.sh.