]> git.ipfire.org Git - people/mfischer/ipfire-2.x.git/commitdiff
dhcpcd.exe: Only set gateway when we have received one
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 1 Dec 2022 17:23:04 +0000 (17:23 +0000)
committerPeter Müller <peter.mueller@ipfire.org>
Sat, 17 Dec 2022 17:20:46 +0000 (17:20 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/networking/dhcpcd.exe

index c083b8d9671e4c40569ef371c83ce162a88573ab..b557bcb1218f3fa5b553fe64e8c3df6f34f17ca9 100644 (file)
@@ -54,10 +54,12 @@ dhcpcd_up()
        #Get IP Address
        echo -n "$new_ip_address"  > /var/ipfire/red/local-ipaddress
 
-       #Get default gateway
-       grep -v -E "\<gateway\>" /etc/hosts > /tmp/hosts
-       echo "$new_routers      gateway"  >> /tmp/hosts
-       mv /tmp/hosts /etc/hosts
+       # Get default gateway
+       if [ -n "${new_routers}" ]; then
+               grep -v -E "\<gateway\>" /etc/hosts > /tmp/hosts
+               echo "$new_routers      gateway"  >> /tmp/hosts
+               mv /tmp/hosts /etc/hosts
+       fi
 
        if [ $update ]; then
                [ -e "/var/ipfire/red/active" ] || touch /var/ipfire/red/active