Remove deprecated functions
[grml-network.git] / sbin / netcardconfig
index 03784a9..b2d19e0 100755 (executable)
@@ -15,7 +15,7 @@ LANGUAGE=C LANG=C
 export PATH LANGUAGE LANG
 
 . /etc/grml/script-functions
-check4root
+check4root || exit 1
 
 TMP=$(mktemp)
 
@@ -81,32 +81,6 @@ writeiwline() {
   #echo "DEBUG: for interfaces $IWOURLINE"
 }
 
-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
-# running this script (once more)." > /etc/udev/scripts/netcardconfig
-  for interface in `ifconfig | awk '/^[a-z]/ &&!/^lo/{ print $1} '` ; do
-      echo -n "INTERFACE=$interface /lib/udev/write_net_rules " >> /etc/udev/scripts/netcardconfig && \
-      if which udevadm >/dev/null 2>&1; then
-        udevadm info -a -p /sys/class/net/$interface | awk -F'==' '/address/ {print $2}' >> /etc/udev/scripts/netcardconfig
-      else
-        udevinfo -a -p /sys/class/net/$interface | awk -F'==' '/address/ {print $2}' >> /etc/udev/scripts/netcardconfig
-      fi
-  done
-  # 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() {
   PARTCOUNT=0
   isauto=0
@@ -156,6 +130,8 @@ configiface() {
   DEVICE=${NETDEVICES[$DV]}
   device2props
   DV=$DEVICENAME
+  ifdown $DV
+  sleep 3
   # wireless config
   WLDEVICE="$(LANG=C LC_MESSAGEWS=C iwconfig $DV 2>/dev/null | awk '/802\.11|READY|ESSID/{print $1}')"
   WLDEVICECOUNT="$(LANG=C LC_MESSAGEWS=C iwconfig $DV 2>/dev/null | wc -l)"
@@ -263,9 +239,6 @@ configiface() {
     IWDRIVER=$driver
 
     case $IWDRIVER in
-      ath_pci)
-        WPA_DEV="madwifi"
-        ;;
       ipw2200|ipw2100|ipw3945)
         WPA_DEV="wext"
         ;;
@@ -325,7 +298,13 @@ configiface() {
                           }
                   }
                   ' /etc/network/interfaces)
-          $DIALOG --inputbox "$MESSAGEW23 $ESSID" 15 50 "$WPASECRET" 2>"$TMP" || bailout 1
+          while [ -z "$WPASECRET" ] ; do
+            $DIALOG --inputbox "$MESSAGEW23 $ESSID" 15 50 "$WPASECRET" 2>"$TMP" || bailout 1
+            read WPASECRET <"$TMP"
+            if [ -z "$WPASECRET" ] ; then
+              $DIALOG --msgbox "Sorry, empty password not allowed, please retry." 0 0 || bailout 1
+            fi
+          done
 
           # make sure backslashes inside passphrase are handled correct
           WPASECRET=$(sed -e 's/\\/\\/g' "$TMP") && rm -r "$TMP"
@@ -389,8 +368,8 @@ configiface() {
         /netmask/{if(found){netmask=$NF}}
         /broadcast/{if(found){broadcast=$NF}}
         /gateway/{if(found){gateway=$NF}}
-        /dns-nameservers/{if(found){dns-nameservers=$NF}}
-        END{print address" "netmask" "broadcast" "gateway" "dns-nameservers}' /etc/network/interfaces >"$TMP"
+        /dns-nameservers/{if(found){dnsnameservers=$NF}}
+        END{print address" "netmask" "broadcast" "gateway" "dnsnameservers}' /etc/network/interfaces >"$TMP"
       read IP NM BC DG <"$TMP"
       rm -f "$TMP"
     fi
@@ -572,17 +551,11 @@ while (true); do
   IFACEDONE=""
   while [ -n "$DV" -a -z "$IFACEDONE" ]; do
     configiface
-    ifdown $DV
-    sleep 3
     if ! ifup $DV; then
       $DIALOG --yesno "$MESSAGE14" 15 50 || IFACEDONE="DONE"
     else
       if $DIALOG --yesno "$MESSAGE15" 12 50 ; then
          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