Add nft-reload.sh

This commit is contained in:
2025-08-19 10:06:33 +00:00
commit 6837104f90
+33
View File
@@ -0,0 +1,33 @@
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "You are not running this script as root, please do so!"
exit
fi
nftconfig="/etc/nft-reload.conf"
editor="nano"
function reload {
if $(nft -c -f /etc/nftables.conf) ; then
$nftconfig | bash
echo "Flushed firewall rules"
echo "Reloading firewall"
systemctl reload nftables.service
echo "Reloaded"
else
echo "Fuck you (that means you, Techit), fix your config"
fi
}
function createdir {
install -D /dev/null -m 711 $nftconfig
echo "Configuration file not found, created configuration file at $nftconfig"
echo $'#!/usr/sbin/nft -f\n# Place your flushes below this line ↓' > $nftconfig
echo "Make sure to remove all of the flushes in your /etc/nftables.conf before running this script again."
}
if [ -e "$nftconfig" ]; then
reload
else
createdir
fi