Merge pull request #316911 from NixOS/backport-312317-to-release-24.05

[Backport release-24.05] nixos/network-interfaces: prevent failure when a network address already exists
This commit is contained in:
Michele Guerini Rocco 2024-06-03 17:58:46 +02:00 committed by GitHub
commit 92706b2141
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -203,10 +203,10 @@ let
''
echo "${cidr}" >> $state
echo -n "adding address ${cidr}... "
if out=$(ip addr add "${cidr}" dev "${i.name}" 2>&1); then
if out=$(ip addr replace "${cidr}" dev "${i.name}" 2>&1); then
echo "done"
elif ! echo "$out" | grep "File exists" >/dev/null 2>&1; then
echo "'ip addr add "${cidr}" dev "${i.name}"' failed: $out"
else
echo "'ip addr replace "${cidr}" dev "${i.name}"' failed: $out"
exit 1
fi
''