#!/usr/bin/env bash # TODO: diff with existing before just overwriting what's here in git? my_config="$(dirname "$(realpath "$0")")/nftables.conf" t="/tmp/nftables.conf" # we don't care about existing rules - just use ours, thanks # sudo nft -s list ruleset >> "$f" sudo -E $EDITOR "$my_config" cat "$my_config" echo "Do you want to load this config? [y/N]" read -r l [[ $l == "y" ]] && { printf "flush ruleset\n\n" > "$t" cat "$my_config" >> "$t" sudo nft -f "$t" sudo cp "$my_config" "/etc/nftables.conf" rm "$t" echo "Done loading!" }