meta-google: gbmc-ncsi-config: Remove override if empty
Currently this will make no difference in configuration, but it will be
useful once we implement our DHCP process and need to contend with
multiple configurations.
Change-Id: Ia93530e67cdb88fcbe90ef2b6dfbd5a239469ff7
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
index b04f2aa..78af419 100644
--- a/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
+++ b/meta-google/recipes-google/ncsi/files/gbmc-ncsi-br-pub-addr.sh.in
@@ -36,14 +36,14 @@
done
fi
- local contents='[Network]'$'\n'
+ local contents=
if (( ${#pfx_bytes[@]} != 0 )); then
pfx_bytes[8]=0xfd
local stateless_pfx="$(ip_bytes_to_str pfx_bytes)"
pfx_bytes[9]=0x01
local ncsi_pfx="$(ip_bytes_to_str pfx_bytes)"
- local here=
- read -r -d '' here <<EOF
+ read -r -d '' contents <<EOF
+[Network]
Address=$ncsi_pfx/128
IPv6PrefixDelegation=yes
[IPv6PrefixDelegation]
@@ -60,13 +60,16 @@
Type=unreachable
Metric=1024
EOF
- contents+="$here"$'\n'
fi
local file
for file in /run/systemd/network/{00,}-bmc-gbmcbr.network.d/50-public.conf; do
mkdir -p -m 755 "$(dirname "$file")"
- printf '%s' "$contents" >"$file"
+ if [ -z "$contents" ]; then
+ rm -f "$file"
+ else
+ printf '%s' "$contents" >"$file"
+ fi
done
# Ensure that systemd-networkd performs a reconfiguration as it doesn't