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
Signed-off-by: Joseph Liu <kwliu@nuvoton.com>
Signed-off-by: Tim Lee <timlee660101@gmail.com>
Change-Id: Icf01f880b5a5aa99aa89c05edf1d847e55f444d7
diff --git a/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save.bb b/meta-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save.bb
new file mode 100644
index 0000000..2416ef9
--- /dev/null
+++ b/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-olympus-nuvoton/recipes-olympus-nuvoton/network/olympus-nuvoton-iptable-save/phosphor-save-iptable-rules.service b/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-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