summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2023-10-17 04:26:32 +0300
committerWilliam A. Kennington III <wak@google.com>2023-10-27 00:05:53 +0300
commitf0b88e250356922cbc8e52fd3cdfac1785e89bb1 (patch)
tree71642f1b0cdbe6e7fbbcec335e49ed16dced2598
parentd8122305894518478479d149af73c20e6af087c6 (diff)
downloadopenbmc-f0b88e250356922cbc8e52fd3cdfac1785e89bb1.tar.xz
meta-google: gbmc-ncsi-config: Optionally purge stale networkd configs
On many machines it's safe to purge all configurations that do not match the NCSI interface, to keep a tidy config directory and purge potentially problematic configs. Change-Id: I5f714516eb3718544f0787ac38eb69d485086b42 Signed-off-by: William A. Kennington III <wak@google.com>
-rw-r--r--meta-google/recipes-google/ncsi/files/gbmc-ncsi-purge.service.in10
-rw-r--r--meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb8
2 files changed, 18 insertions, 0 deletions
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-purge.service.in b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-purge.service.in
new file mode 100644
index 0000000000..bbbd9921c8
--- /dev/null
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-purge.service.in
@@ -0,0 +1,10 @@
+[Unit]
+Before=systemd-network.service
+After=gbmc-ncsi-old.service
+
+[Service]
+Type=oneshot
+ExecStart=find /etc/systemd/network -mindepth 1 ! -name 00-bmc-@NCSI_IF@.network -exec rm -vrf {} \; -prune
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb b/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb
index cb547b1be8..607f1b789c 100644
--- a/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb
+++ b/meta-google/recipes-google/ncsi/gbmc-ncsi-config.bb
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5
inherit systemd
GBMC_NCSI_IF_OLD ??= ""
+GBMC_NCSI_PURGE_ETC ??= ""
SRC_URI += " \
file://-bmc-gbmcbrncsidhcp.netdev \
@@ -26,6 +27,7 @@ SRC_URI += " \
file://gbmc-ncsi-alias.service.in \
file://50-gbmc-ncsi-clear-ip.sh.in \
file://gbmc-ncsi-old.service.in \
+ file://gbmc-ncsi-purge.service.in \
"
S = "${WORKDIR}"
@@ -54,6 +56,7 @@ SYSTEMD_SERVICE:${PN} += " \
gbmc-ncsi-set-nicenabled.service \
gbmc-ncsi-ip-from-ra.service \
${@'' if d.getVar('GBMC_NCSI_IF_OLD') == '' else 'gbmc-ncsi-old.service'} \
+ ${@'' if d.getVar('GBMC_NCSI_PURGE_ETC') == '' else 'gbmc-ncsi-purge.service'} \
"
do_install:append() {
@@ -137,6 +140,11 @@ do_install:append() {
>${D}${systemd_system_unitdir}/gbmc-ncsi-old.service
fi
+ if [ -n "${GBMC_NCSI_PURGE_ETC}" ]; then
+ sed -e "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-purge.service.in \
+ >${D}${systemd_system_unitdir}/gbmc-ncsi-purge.service
+ fi
+
sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-ip-from-ra.service.in \
>${WORKDIR}/gbmc-ncsi-ip-from-ra.service
install -m0644 ${WORKDIR}/gbmc-ncsi-ip-from-ra.service ${D}${systemd_system_unitdir}