X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sbin%2Fnetcardconfig;h=f602f79f5ae3560f8a40cca48237959625844f86;hb=63dae7f469dff849b7523d4c9212ce6015380dc5;hp=93120525127d7cb2801c53aa2645e7fa54448b80;hpb=605428c70101ba690a77582522f36c33b0d5ab60;p=grml-network.git diff --git a/sbin/netcardconfig b/sbin/netcardconfig index 9312052..f602f79 100755 --- a/sbin/netcardconfig +++ b/sbin/netcardconfig @@ -15,7 +15,7 @@ LANGUAGE=C LANG=C export PATH LANGUAGE LANG . /etc/grml/script-functions -check4root +check4root || exit 1 TMP=$(mktemp) @@ -156,6 +156,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)" @@ -325,10 +327,17 @@ configiface() { } } ' /etc/network/interfaces) - $DIALOG --inputbox "$MESSAGEW23 $ESSID" 15 50 "$WPASECRET" 2>"$TMP" || bailout 1 - - # make sure backslashes inside passphrase are handled correct - WPASECRET=$(sed -e 's/\\/\\/g' "$TMP") && rm -r "$TMP" + FIRST_RUN=0 # show the wpasecret input box at least once + while ( [ -z "$WPASECRET" ] || [ "$FIRST_RUN" ] ) ; 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 + FIRST_RUN="" + done + + rm -f "$TMP" case $WPA_DEV in hostap) @@ -389,8 +398,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 @@ -486,8 +495,19 @@ if [ -r /proc/net/dev ] ; then else LAN="" fi -[ -n "$WLAN" ] || WLAN=$(tail -n +3 /proc/net/wireless 2>/dev/null|awk -F: '{print $1}'|sort) -unset LAN_DEVICES WLAN_DEVICES FIREWIRE_DEVICES NETDEVICES + +if [ -z "$WLAN" ] ; then + WLAN_OLD=$(tail -n +3 /proc/net/wireless 2>/dev/null|awk -F: '{print $1}') + # /proc/net/wireless does not work e.g. with iwl3945 on kernel 2.6.33 anymore + WLAN_NEW=$(for i in /sys/class/net/* ; do ( [ -d $i/wireless ] || [ -d $i/phy80211 ] ) && basename $i ; done) + set -a WLAN_IWCONFIG + for DEV in $LAN ; do + iwconfig $DEV 2>/dev/null 1>&2 && WLAN_IWCONFIG+=($DEV) + done + WLAN=$(echo $WLAN_OLD $WLAN_NEW ${WLAN_IWCONFIG[@]} | tr ' ' '\n' | sort -u) +fi + +unset LAN_DEVICES WLAN_DEVICES FIREWIRE_DEVICES NETDEVICES WLAN_IWCONFIG while read dev mac; do #echo "Making NETDEVICES $NETDEVICESCOUNT $dev" @@ -565,8 +585,6 @@ 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