34 lines
945 B
Bash
34 lines
945 B
Bash
#!/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
|
|
|