commit:     2210b434bdf7bc04af91582c0e306b480f530560
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 18 17:25:18 2019 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Thu Jul 18 17:25:18 2019 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=2210b434

initrd.scripts: kill_network(): Don't try to kill network when interfacec is 
missing

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 defaults/initrd.scripts | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 9e70c00..5e1029c 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -1713,6 +1713,12 @@ kill_network() {
                kill $(cat "${GK_NET_DHCP_PIDFILE}")
        fi
 
+       if [ ! -d "/sys/class/net/${GK_NET_IFACE}" ]
+       then
+               warn_msg "Interface ${GK_NET_IFACE} not found. Already down?"
+               return
+       fi
+
        # If we are too quick and interface is still configuring IPv6
        # waiting for DAD to complete due to received IPv6 RA, we have to
        # wait.
@@ -1752,7 +1758,7 @@ kill_network() {
                ip addr flush dev "${GK_NET_IFACE}"
                ip route flush dev "${GK_NET_IFACE}"
                ip link set "${GK_NET_IFACE}" down
-               if grep -q "down" "/sys/class/net/${GK_NET_IFACE}/operstate"
+               if grep -q "down" "/sys/class/net/${GK_NET_IFACE}/operstate" 
2>/dev/null
                then
                        break
                fi

Reply via email to