meta-quanta: olympus-nuvoton: iptable: save rules while bmc rebooting

The iptable needs to be preserved in order keep the rules.

Tested: Verified for Olympus platform

(From meta-quanta rev: ae01a4669bc1653ed81998573f25b8dc62a4794b)

Signed-off-by: Joseph Liu <kwliu@nuvoton.com>
Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: Ic9b226f21a2526994bdf353701d0ca7b7d053d8a
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
diff --git a/meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save.bb b/meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save.bb
new file mode 100644
index 0000000..2416ef9
--- /dev/null
+++ b/meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save.bb
@@ -0,0 +1,17 @@
+SUMMARY = "Iptable Save"
+DESCRIPTION = "Save iptable rules"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit allarch systemd
+
+SRC_URI = "file://phosphor-save-iptable-rules.service"
+SYSTEMD_SERVICE_${PN} = "phosphor-save-iptable-rules.service"
+
+S = "${WORKDIR}"
+do_install() {
+    install -d ${D}${systemd_unitdir}/system/
+    install -m 0644 ${WORKDIR}/phosphor-save-iptable-rules.service \
+        ${D}${systemd_unitdir}/system
+}
diff --git a/meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save/phosphor-save-iptable-rules.service b/meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save/phosphor-save-iptable-rules.service
new file mode 100644
index 0000000..9c340bd
--- /dev/null
+++ b/meta-quanta/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save/phosphor-save-iptable-rules.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Save iptable rules
+DefaultDependencies=no
+After=shutdown.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=true
+ExecStart=/bin/sh -c "iptables-save > /etc/iptables/iptables.rules"
+
+[Install]
+WantedBy=shutdown.target