router/firewall-edit.bash
Daniel Flanagan 7ec4eebc65 Whee!
2022-02-04 10:45:06 -06:00

23 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!"
}