22 lines
830 B
Shell
22 lines
830 B
Shell
|
|
#!/usr/bin/env bash
|
||
|
|
# Install the Garage inbound guard on rpi. Idempotent; safe to re-run.
|
||
|
|
#
|
||
|
|
# sudo ./install-garage-firewall.sh
|
||
|
|
#
|
||
|
|
# Verifies the table afterwards instead of trusting `systemctl start`'s exit 0.
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||
|
|
|
||
|
|
install -D -m 0644 "$here/garage-firewall.nft" /etc/nftables.d/garage_guard.nft
|
||
|
|
install -D -m 0644 "$here/garage-firewall.service" /etc/systemd/system/garage-firewall.service
|
||
|
|
|
||
|
|
systemctl daemon-reload
|
||
|
|
systemctl enable --now garage-firewall.service
|
||
|
|
|
||
|
|
# Prove it loaded rather than assuming: the table must exist and carry both the
|
||
|
|
# accept and the drop rule.
|
||
|
|
nft list table inet garage_guard >/dev/null
|
||
|
|
nft list table inet garage_guard | grep -q 'dport { 3900, 3901, 3902, 3903 }'
|
||
|
|
echo "OK: garage_guard loaded"
|
||
|
|
nft list table inet garage_guard
|