added .gitignore and a script to unify .nft files into nftables.conf
This commit is contained in:
parent
ee2fe873f3
commit
419683e54d
|
@ -0,0 +1 @@
|
|||
nftables.conf
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
# ${1} is original filename
|
||||
# ${2} is counter (use n for empty)
|
||||
# ${3} is file to replace from
|
||||
replace(){
|
||||
local pattern=$(sed ':a;N;$!ba;s/\n/Ñ/g;s/\(\/\|\.\)/\\\1/g' "${3}")
|
||||
if [ ${2} != "0" ]
|
||||
then
|
||||
local new_content="$(sed "1,/include/{s/include \"[a-z\.\/]\+\"/${pattern}/}" "${1}""$(bc -l <<< "${2} - 1")".nft | sed 's/Ñ/\n/g')";
|
||||
echo "${new_content}" > "${1}${2}".nft
|
||||
else
|
||||
local new_content="$(sed "1,/include/{s/include \"[a-z\.\/]\+\"/${pattern}/}" "${1}".nft | sed 's/Ñ/\n/g')";
|
||||
echo "${new_content}" > "${1}${2}".nft
|
||||
fi
|
||||
}
|
||||
|
||||
filename=filter
|
||||
declare -i counter=0
|
||||
for i in $(grep include filter.nft | awk '{print $2}' | tr -d \")
|
||||
do replace "${filename}" "${counter}" "${i}"
|
||||
counter+=1
|
||||
done
|
||||
|
||||
counter=${counter}-1
|
||||
mv "${filename}""${counter}".nft nftables.conf
|
||||
while [ ${counter} -ge 0 ]
|
||||
do
|
||||
rm "${filename}""${counter}".nft
|
||||
counter=${counter}-1
|
||||
done
|
Loading…
Reference in New Issue