nixos/network-interfaces: prevent failure when a network address already exists
The original code tests output of `ip addr add` command to detect if an adress already exists. The error message was changed in the past and the test no longer works. The patch replaces `ip addr add` with `ip addr replace`. The new command replaces an existing address or creates a new one if there isn't any. fixes 306841
This commit is contained in:
@@ -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
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user