From 8f95d74464affcb09466ed7ad6b26b67e31e12b5 Mon Sep 17 00:00:00 2001 From: celso Date: Fri, 13 Dec 2024 01:04:11 -0300 Subject: [PATCH] added makefile and corrected mistake in makeconf script --- Makefile | 25 +++++++++++++++++++++++++ makeconf.sh | 2 ++ 2 files changed, 27 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c90d557 --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +SRC = ./ +NFT = nftables.conf.nft + +all: + $(info run make makeconf to unify .nft files into nftables.conf) + $(info run make install to install nftables.conf in /etc and set as current ruleset) + $(info run make uninstall to replace /etc/nftables.conf with backup and set as current ruleset) + +makeconf: + $(info running makeconf.sh) + $(SRC)makeconf.sh + +install: makeconf + $(info backing up current nftables rules) + cp /etc/nftables.conf $(SRC)backup.conf || nft list ruleset > $(SRC)backup.conf + $(info installing new nftables rules) + cp $(SRC)$(NFT) /etc/nftables.conf + $(info reloading nftables rules) + nft -f /etc/nftables.conf + +uninstall: + $(info replacing nftables.conf with backup) + cp $(SRC)backup.conf /etc/nftables.conf + $(info reloading nftables rules) + nft -f /etc/nftables.conf diff --git a/makeconf.sh b/makeconf.sh index 4af902e..91b7a1b 100755 --- a/makeconf.sh +++ b/makeconf.sh @@ -24,6 +24,8 @@ done counter=${counter}-1 mv "${filename}""${counter}".nft nftables.conf +counter=${counter}-1 + while [ ${counter} -ge 0 ] do rm "${filename}""${counter}".nft