nixos/networking: check interface state files exist before acting on them
Fix #89158
This commit is contained in:
parent
d9f9fcfd16
commit
8f16f66b27
1 changed files with 14 additions and 10 deletions
|
@ -232,18 +232,22 @@ let
|
|||
'';
|
||||
preStop = ''
|
||||
state="/run/nixos/network/routes/${i.name}"
|
||||
while read cidr; do
|
||||
echo -n "deleting route $cidr... "
|
||||
ip route del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
|
||||
done < "$state"
|
||||
rm -f "$state"
|
||||
if [ -e "$state" ]; then
|
||||
while read cidr; do
|
||||
echo -n "deleting route $cidr... "
|
||||
ip route del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
|
||||
done < "$state"
|
||||
rm -f "$state"
|
||||
fi
|
||||
|
||||
state="/run/nixos/network/addresses/${i.name}"
|
||||
while read cidr; do
|
||||
echo -n "deleting address $cidr... "
|
||||
ip addr del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
|
||||
done < "$state"
|
||||
rm -f "$state"
|
||||
if [ -e "$state" ]; then
|
||||
while read cidr; do
|
||||
echo -n "deleting address $cidr... "
|
||||
ip addr del "$cidr" dev "${i.name}" >/dev/null 2>&1 && echo "done" || echo "failed"
|
||||
done < "$state"
|
||||
rm -f "$state"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue