From 6837104f9057505a1a8af5ad2da8fac4c17729f5 Mon Sep 17 00:00:00 2001 From: diskette Date: Tue, 19 Aug 2025 10:06:33 +0000 Subject: [PATCH] Add nft-reload.sh --- nft-reload.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 nft-reload.sh diff --git a/nft-reload.sh b/nft-reload.sh new file mode 100644 index 0000000..60d12ad --- /dev/null +++ b/nft-reload.sh @@ -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 +