diff options
author | Michele Guerini Rocco <rnhmjoj@users.noreply.github.com> | 2020-06-12 15:31:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 15:31:57 +0200 |
commit | a2fd1ba544eb53c14b89d09ac3efc426e7efcf94 (patch) | |
tree | 6318920a7ed257b4b54655af3bd6164546bacd3e /nixos/modules/tasks | |
parent | 80643891c0ddf7fe9bb8f2fe345324d5539b2dd9 (diff) | |
parent | 8f16f66b27c6abcfaa04244f9e715376035dcfcb (diff) | |
download | nixlib-a2fd1ba544eb53c14b89d09ac3efc426e7efcf94.tar nixlib-a2fd1ba544eb53c14b89d09ac3efc426e7efcf94.tar.gz nixlib-a2fd1ba544eb53c14b89d09ac3efc426e7efcf94.tar.bz2 nixlib-a2fd1ba544eb53c14b89d09ac3efc426e7efcf94.tar.lz nixlib-a2fd1ba544eb53c14b89d09ac3efc426e7efcf94.tar.xz nixlib-a2fd1ba544eb53c14b89d09ac3efc426e7efcf94.tar.zst nixlib-a2fd1ba544eb53c14b89d09ac3efc426e7efcf94.zip |
Merge pull request #89159 from datafoo/fix-issue-89158
nixos/networking: check interface state files exist before acting on them
Diffstat (limited to 'nixos/modules/tasks')
-rw-r--r-- | nixos/modules/tasks/network-interfaces-scripted.nix | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/nixos/modules/tasks/network-interfaces-scripted.nix b/nixos/modules/tasks/network-interfaces-scripted.nix index d895c58bab03..2e87197176b6 100644 --- a/nixos/modules/tasks/network-interfaces-scripted.nix +++ b/nixos/modules/tasks/network-interfaces-scripted.nix @@ -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 ''; }; |