summaryrefslogtreecommitdiff
path: root/meta-google/recipes-google/nftables/files/nft-configure.sh
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2021-03-08 23:31:30 +0300
committerWilliam A. Kennington III <wak@google.com>2021-03-09 06:53:28 +0300
commitc20feb7b192779112e702b8081d63b3d9a610867 (patch)
treeef16e3c28f8e1ab19eaf5afa6bf5f8b16b769ac0 /meta-google/recipes-google/nftables/files/nft-configure.sh
parent0ce248846f907f3716625c268b61a9325b8762f4 (diff)
downloadopenbmc-c20feb7b192779112e702b8081d63b3d9a610867.tar.xz
meta-google: nftables-systemd: Parse rules in a useful order
We want to make sure rules get parsed in a sensible order, following a sorting order similar to systemd units. Change-Id: Ica06c953dba793d89d50c6b4cfc8e8a2eb1f58de Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'meta-google/recipes-google/nftables/files/nft-configure.sh')
-rw-r--r--meta-google/recipes-google/nftables/files/nft-configure.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/meta-google/recipes-google/nftables/files/nft-configure.sh b/meta-google/recipes-google/nftables/files/nft-configure.sh
new file mode 100644
index 000000000..a82c2826f
--- /dev/null
+++ b/meta-google/recipes-google/nftables/files/nft-configure.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+shopt -s nullglob
+declare -A basemap=()
+i=0
+for dir in /run/nftables /etc/nftables /usr/share/nftables; do
+ for file in "$dir"/*.rules; do
+ basemap["${file##*/}$i"]="$file"
+ done
+ let i+=1
+done
+rc=0
+for key in $(printf "%s\n" "${!basemap[@]}" | sort -r); do
+ echo "Executing ${basemap[$key]}" >&2
+ nft -f "${basemap[$key]}" || rc=$?
+done
+exit $rc