router/firewall-edit.sh
2022-01-31 11:40:03 -06:00

22 lines
545 B
Bash
Executable file

#!/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 nvim "$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!"
}