router/firewall-edit.sh
2021-07-10 14:46:26 -05:00

21 lines
557 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"
# we don't care about existing rules - just use ours, thanks
# sudo nft -s list ruleset >> "$f"
sudo 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" > "/tmp/nftables.txt"
cat "$my_config" >> "/tmp/nftables.conf"
sudo nft -f "/tmp/nftables.conf"
sudo cp "$my_config" "/etc/nftables.conf"
echo "Done loading!"
}