Suggest x.x.x.1 as default gatway and DNS server; create /etc/udev/scripts/
[grml-network.git] / sbin / netcardconfig
index 75225f0..4e453d0 100755 (executable)
@@ -4,7 +4,7 @@
 # Authors:       Michael Prokop <mika@grml.org>, Marcel Wichern 2006, Klaus Knopper 2002, Niall Walsh + Stefan Lippers-Hollmann 2004-2007
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Don Mär 15 20:36:48 CET 2007 [mika]
+# Latest change: Mit Mai 30 10:26:39 CEST 2007 [mika]
 ################################################################################
 # Changes have been merged from Kanotix's and Sidux's netcardconfig:
 # http://kanotix.com/files/debian/pool/main/n/netcardconfig-kanotix/
@@ -84,6 +84,7 @@ writeiwline() {
 
 generate_udev_entry() {
   interface=''
+  mkdir -p /etc/udev/scripts
   echo "# Auto generated script from netcardconfig on $(date)
 # Executing this script generates an entry in /etc/udev/rules.d/z25_persistent-net.rules
 # for you, please check z25_persistent-net.rules for existing entries before
@@ -92,7 +93,15 @@ generate_udev_entry() {
       echo -n "INTERFACE=$interface /lib/udev/write_net_rules " >> /etc/udev/scripts/netcardconfig && \
       udevinfo -a -p /sys/class/net/$interface | awk -F'==' '/address/ {print $2}' >> /etc/udev/scripts/netcardconfig
   done
-  chmod +x /etc/udev/scripts/netcardconfig && /etc/udev/scripts/netcardconfig 1>/dev/null
+  # send errors to /dev/null as well because the sed line inside the /lib/udev/write_net_rules
+  # script outputs a sed warning which might unsettle users
+  chmod +x /etc/udev/scripts/netcardconfig && /etc/udev/scripts/netcardconfig 1>/dev/null 2>&1
+}
+
+disable_config_dhcp() {
+  if grep -q CONFIG_DHCP /etc/grml/autoconfig ; then
+     sed -i "s|^CONFIG_DHCP.*|CONFIG_DHCP='no'|" /etc/grml/autoconfig
+  fi
 }
 
 device2props() {
@@ -392,14 +401,14 @@ configiface() {
     $DIALOG --inputbox "$MESSAGE8 $DV" 10 45 "${BC:-${IP%.*}.255}" 2>"$TMP" || bailout 1
     read BC <"$TMP" ; rm -f "$TMP"
 
-    $DIALOG --inputbox "$MESSAGE9" 10 45 "${DG:-${IP%.*}.254}" 2>"$TMP"
+    $DIALOG --inputbox "$MESSAGE9" 10 45 "${DG:-${IP%.*}.1}" 2>"$TMP"
     read DG <"$TMP" ; rm -f "$TMP"
 
     if [ -f "/etc/resolv.conf" ]; then
       NS="$(awk '/^nameserver/{printf "%s ",$2}' /etc/resolv.conf)"
     fi
 
-    $DIALOG --inputbox "$MESSAGE10" 10 45 "${NS:-${IP%.*}.254}" 2>"$TMP"
+    $DIALOG --inputbox "$MESSAGE10" 10 45 "${NS:-$DG}" 2>"$TMP"
     read NS <"$TMP" ; rm -f "$TMP"
 
     if [ -w /etc/network/interfaces ]; then
@@ -557,6 +566,8 @@ while (true); do
          addauto
          # get persistent interface names across reboots
          generate_udev_entry
+        # make sure we don't run the dhcp stuff when using /etc/network/interfaces
+        disable_config_dhcp
       else
          remauto
       fi