2 # Filename: grml-network
3 # Purpose: configuration script for network
4 # Authors: Michael Prokop <mika@grml.org>, Marcel Wichern 2006, Klaus Knopper 2002, Niall Walsh + Stefan Lippers-Hollmann 2004-2007
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 ################################################################################
8 # Changes have been merged from Kanotix's and Sidux's netcardconfig:
9 # http://kanotix.com/files/debian/pool/main/n/netcardconfig-kanotix/
10 # http://svn.berlios.de/wsvn/fullstory/configure-networkcard/trunk/
11 ################################################################################
13 PATH="/bin:/sbin:/usr/bin:/usr/sbin"
15 export PATH LANGUAGE LANG
17 . /etc/grml/script-functions
27 # This function produces the IWOURLINE for interfaces
30 if [ -n "$NWID" ]; then
31 IWOURLINE="$IWOURLINE\twireless-nwid $NWID\n"
34 if [ -n "$MODE" ]; then
35 IWOURLINE="$IWOURLINE\twireless-mode $MODE\n"
38 if [ -n "$CHANNEL" ]; then
39 IWOURLINE="$IWOURLINE\twireless-channel $CHANNEL\n"
42 if [ -n "$FREQ" ]; then
43 IWOURLINE="$IWOURLINE\twireless-freq $FREQ\n"
46 if [ -n "$KEY" ]; then
47 if [ "$PUBKEY" -eq 1 ]; then
48 # Store the key in interfaces in wireless-key
49 IWOURLINE="$IWOURLINE\twireless-key $KEY\n"
51 # Store the key in /etc/network/wep.$DV which is root readable only
52 # Use pre-up in interfaces to read and set it
53 echo "$KEY" > "/etc/network/wep.$DV" && chmod 600 "/etc/network/wep.$DV" && IWOURLINE="$IWOURLINE\tpre-up KEY=\$(cat /etc/network/wep.$DV) && iwconfig $DV key \$KEY\n"
57 for mod in /sys/module/rt2??0/ ; do
58 if [ -d "$mod" ]; then
59 IWPREUPLINE="$IWPREUPLINE\tpre-up /sbin/ip link set $DV up\n"
64 if [ -n "$IWCONFIG" ]; then
65 IWPREUPLINE="$IWPREUPLINE\tiwconfig $IWCONFIG\n"
68 if [ -n "$IWSPY" ]; then
69 IWPREUPLINE="$IWPREUPLINE\tiwspy $IWSPY\n"
72 if [ -n "$IWPRIV" ]; then
73 IWPREUPLINE="$IWPREUPLINE\tiwpriv $IWPRIV\n"
76 # execute ESSID last, but make sure that it is written as first option
77 if [ -n "$ESSID" ]; then
78 IWOURLINE="$IWOURLINE\twireless-essid $ESSID\n"
81 if [ "$WPAON" -gt 0 ]; then
82 IWOURLINE="$IWOURLINE\twpa-ssid $ESSID\n\twpa-psk $WPASECRET\n"
85 IWOURLINE="$IWOURLINE $IWPREUPLINE"
86 #echo "DEBUG: for interfaces $IWOURLINE"
89 generate_udev_entry() {
91 mkdir -p /etc/udev/scripts
92 echo "# Auto generated script from netcardconfig on $(date)
93 # Executing this script generates an entry in /etc/udev/rules.d/z25_persistent-net.rules
94 # for you, please check z25_persistent-net.rules for existing entries before
95 # running this script (once more)." > /etc/udev/scripts/netcardconfig
96 for interface in $(ip -oneline link | awk '!/ lo: / {print $2}' | sed 's/:$//; s/@.*//') ; do
97 echo -n "INTERFACE=$interface /lib/udev/write_net_rules " >> /etc/udev/scripts/netcardconfig && \
98 if which udevadm >/dev/null 2>&1; then
99 udevadm info -a -p "/sys/class/net/$interface" | awk -F'==' '/address/ {print $2}' >> /etc/udev/scripts/netcardconfig
101 udevinfo -a -p "/sys/class/net/$interface" | awk -F'==' '/address/ {print $2}' >> /etc/udev/scripts/netcardconfig
104 # send errors to /dev/null as well because the sed line inside the /lib/udev/write_net_rules
105 # script outputs a sed warning which might unsettle users
106 chmod +x /etc/udev/scripts/netcardconfig && /etc/udev/scripts/netcardconfig 1>/dev/null 2>&1
109 disable_config_dhcp() {
110 if grep -q CONFIG_DHCP /etc/grml/autoconfig ; then
111 sed -i "s|^CONFIG_DHCP.*|CONFIG_DHCP='no'|" /etc/grml/autoconfig
122 for PART in $DEVICE; do
123 if [ $PARTCOUNT -eq 0 ]; then
126 echo "$PART" | grep -q A::1 && isauto=1
127 echo "$PART" | grep -q F::1 && isfirewire=1
128 echo "$PART" | grep -q W::1 && iswireless=1
129 [ -z "$driver" ] && driver=$(echo "$PART"|awk 'BEGIN {FS="::"} /^D:/{print $2}')
130 [ -z "$mac" ] && mac=$(echo "$PART"|awk 'BEGIN {FS="::"} /^M:/{print $2}')
138 [ $isfirewire -gt 0 ] && MY_DEVICE_NAME="$NET_DEVICE_NAME_FW"
139 [ -z "$MY_DEVICE_NAME" ] && [ $iswireless -gt 0 ] && MY_DEVICE_NAME="$NET_DEVICE_NAME_W"
140 [ -z "$MY_DEVICE_NAME" ] && MY_DEVICE_NAME="$NET_DEVICE_NAME"
141 MY_DEVICE_NAME="$DEVICENAME $MY_DEVICE_NAME $mac $driver"
142 [ $isauto -gt 0 ] && MY_DEVICE_NAME="$MY_DEVICE_NAME $NET_DEVICE_NAME_AUTO"
143 MY_DEVICE_NAME="${MY_DEVICE_NAME// /__}"
147 if ! grep -E "^auto .*$DV" /etc/network/interfaces >/dev/null; then
148 awk '{if(/^auto/){if(done==0){print $0 " '"$DV"'";done=1}else{print}}else{print}}END{if(done==0){print "auto '"$DV"'"}}' "/etc/network/interfaces" > "$TMP"
149 cat "$TMP" > /etc/network/interfaces
154 if grep -e "^auto .*$DV" /etc/network/interfaces >/dev/null; then
155 perl -pi -e 's/^(auto.*)'"$DV"'(.*)$/$1$2/;' /etc/network/interfaces
162 iwlist "$DV" scanning | grep "ESSID\|Quality" | sed -e "s/^.*ESSID:\"\|\"$//g" | tac > "$TMP"
174 if [[ -n "${METHOD}" ]] && [[ "${METHOD}" != 'dhcp' ]]; then
187 [ ! -r /etc/network/interfaces ] && touch /etc/network/interfaces
188 DEVICE=${NETDEVICES[$DV]}
191 ifdown "${DV}" --force
194 if "${INTERACTIVE}" ; then
195 # Setup wireless options?
196 if [ $iswireless -gt 0 ] && $DIALOG --yesno "$MESSAGE13" 8 45; then
197 WLDEVICECOUNT="$(LANG=C LC_MESSAGEWS=C iwconfig "$DV" 2>/dev/null | wc -l)"
212 if [ -f /etc/network/interfaces ]; then
213 awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}}
214 /essid/{if(found){for(i=NF;i>=2;i--)essid=$i "~" essid}}
215 /nwid/{if(found){nwid=$NF}}
216 /mode/{if(found){mode=$NF}}
217 /channel/{if(found){channel=$NF}}
218 /freq/{if(found){freq=$NF}}
219 /sens/{if(found){sens=$NF}}
220 /rate/{if(found){rate=$NF}}
221 /rts/{if(found){rts=$NF}}
222 /frag/{if(found){frag=$NF}}
223 /iwconfig/{if(!/KEY/){if(found){iwconfig=$NF}}}
224 /iwspy/{if(found){iwspy=$NF}}
225 /iwpriv/{if(found){iwpriv=$NF}}
226 /wireless[-_]key/{if(found){gsub(/^\W*wireless[-_]key\W*/,"");key=$0}}
228 if (!(length(essid))){essid="~~~"}
229 if (!(length(nwid))){nwid="~~~"}
230 if (!(length(mode))){mode="~~~"}
231 if (!(length(channel))){channel="~~~"}
232 if (!(length(freq))){freq="~~~"}
233 if (!(length(sens))){sens="~~~"}
234 if (!(length(rate))){rate="~~~"}
235 if (!(length(rts))){rts="~~~"}
236 if (!(length(frag))){frag="~~~"}
237 if (!(length(iwconfig))){iwconfig="~~~"}
238 if (!(length(iwspy))){iwspy="~~~"}
239 if (!(length(iwpriv))){iwpriv="~~~"}
240 if (!(length(key))){key="~~~"}
241 print essid" "nwid" "mode" "channel" "freq" "sens" "rate" "rts" "frag" "iwconfig" "iwspy" "iwpriv" "key
242 }' /etc/network/interfaces >"$TMP"
244 read -r ESSID NWID MODE CHANNEL FREQ SENS RATE RTS FRAG IWCONFIG IWSPY IWPRIV KEY<"$TMP"
246 [[ "$ESSID" =~ ^~~~$ ]] && ESSID=""
247 [[ "$NWID" =~ ^~~~$ ]] && NWID=""
248 [[ "$MODE" =~ ^~~~$ ]] && MODE=""
249 [[ "$CHANNEL" =~ ^~~~$ ]] && CHANNEL=""
250 [[ "$FREQ" =~ ^~~~$ ]] && FREQ=""
251 [[ "$SENS" =~ ^~~~$ ]] && SENS=""
252 [[ "$RATE" =~ ^~~~$ ]] && RATE=""
253 [[ "$RTS" =~ ^~~~$ ]] && RTS=""
254 [[ "$FRAG" =~ ^~~~$ ]] && FRAG=""
255 [[ "$IWCONFIG" =~ ^~~~$ ]] && IWCONFIG=""
256 [[ "$IWSPY" =~ ^~~~$ ]] && IWSPY=""
257 [[ "$IWPRIV" =~ ^~~~$ ]] && IWPRIV=""
258 [[ "$KEY" =~ ^~~~$ ]] && KEY=""
260 # shellcheck disable=SC2088
261 ESSID=$(echo $ESSID | tr '~' " " | sed 's/ *$//')
263 if [ -z "$KEY" ]; then
264 KEY=$(cat "/etc/network/wep.$DV" 2>/dev/null)
266 if [ -z "$KEY" ]; then
275 #echo "DEBUG:E:$ESSID N:$NWID M:$MODE C:$CHANNEL F:$FREQ S:$SENS R:$RATE K:$KEY R:$RTS F:$FRAG I:$IWCONFIG I:$IWSPY I:$IWPRIV"
279 # ask to scan or manually set wireless network
280 if $DIALOG --yesno "$MESSAGEWSCAN1" 8 45 ; then
283 while [ $RESCAN -eq 1 ]
286 $DIALOG --extra-button --extra-label "Rescan" --menu "$MESSAGEWSCAN2" 20 70 15 "${WARRAY[@]}" 2>"$TMP"
299 read -r ESSID <"$TMP" ; rm -f "$TMP"
300 [ -z "$MODE" ] && MODE="Managed"
304 $DIALOG --inputbox "$MESSAGEW4 $DEVICENAME $MESSAGEW5" 15 50 "$ESSID" 2>"$TMP" || bailout 1
305 read -r ESSID <"$TMP" ; rm -f "$TMP"
306 [ -z "$ESSID" ] && ESSID="any"
308 $DIALOG --inputbox "$MESSAGEW6 $DEVICENAME $MESSAGEW7" 15 50 "$NWID" 2>"$TMP" || bailout 1
309 read -r NWID <"$TMP" ; rm -f "$TMP"
311 $DIALOG --inputbox "$MESSAGEW8 $DEVICENAME $MESSAGEW9" 15 50 "$MODE" 2>"$TMP" || bailout 1
312 read -r MODE <"$TMP" ; rm -f "$TMP"
313 [ -z "$MODE" ] && MODE="Managed"
315 $DIALOG --inputbox "$MESSAGEW10 $DEVICENAME $MESSAGEW11" 15 50 "$CHANNEL" 2>"$TMP" || bailout 1
316 read -r CHANNEL <"$TMP" ; rm -f "$TMP"
318 if [ -z "$CHANNEL" ]; then
319 $DIALOG --inputbox "$MESSAGEW12 $DEVICENAME $MESSAGEW13" 15 50 "$FREQ" 2>"$TMP" || bailout 1
320 read -r FREQ <"$TMP" ; rm -f "$TMP"
332 ipw2200|ipw2100|ipw3945)
343 if [ -z "$WPA_DEV" ]; then
344 if [ -d "/proc/net/ndiswrapper/$DV" ]; then
346 elif [ -d "/proc/net/hostap/$DV" ]; then
348 elif [ "$WLDEVICECOUNT" -eq 1 ]; then
349 if [ -e /proc/driver/atmel ]; then
357 if [ -n "$WPA_DEV" ]; then
358 if $DIALOG --yesno "$MESSAGEW22" 15 50; then
361 # bssid 00:11:22:33:44:55
362 # priority [0]|Integer
363 # proto [WPA RSN] WPA|RSN
364 # key_mgmt [WPA-PSK WPA-EAP]|NONE|WPA-PSK|WPA-EAP|IEEE8021X
365 # pairwise [CCMP TKIP]|CCMP|TKIP|NONE
366 # group [CCMP TKIP WEP105 WEP40]|CCMP|TKIP|WEP105|WEP40
367 # eapol_flags [3]|1|2
383 if (gsub(/^\W*wpa-psk\W*/,"")){
390 ' /etc/network/interfaces)
391 FIRST_RUN=0 # show the wpasecret input box at least once
392 while ( [ -z "$WPASECRET" ] || [ "$FIRST_RUN" ] ) ; do
393 $DIALOG --inputbox "$MESSAGEW23 $ESSID" 15 50 "$WPASECRET" 2>"$TMP" || bailout 1
394 read -r WPASECRET <"$TMP"
395 if [ -z "$WPASECRET" ] ; then
396 $DIALOG --msgbox "Sorry, empty password not allowed, please retry." 0 0 || bailout 1
415 # No need for a wep key if we are using wpa
416 if [ ! $WPAON -eq 1 ]; then
417 $DIALOG --inputbox "$MESSAGEW14 $DEVICENAME $MESSAGEW15" 15 50 "$KEY" 2>"$TMP" || bailout 1
418 read -r KEY <"$TMP" ; rm -f "$TMP"
420 if [ -n "$KEY" ] && [ "$PUBKEY" -eq 0 ]; then
421 if ! $DIALOG --yesno "$MESSAGEW25 $DEVICENAME $MESSAGEW26" 15 50; then
427 $DIALOG --inputbox "$MESSAGEW16 $DEVICENAME $MESSAGEW17" 15 50 "$IWCONFIG" 2>"$TMP" || bailout 1
428 read -r IWCONFIG <"$TMP" ; rm -f "$TMP"
430 $DIALOG --inputbox "$MESSAGEW18 $DEVICENAME $MESSAGEW19" 15 50 "$IWSPY" 2>"$TMP" || bailout 1
431 read -r IWSPY <"$TMP" ; rm -f "$TMP"
433 $DIALOG --inputbox "$MESSAGEW20 $DEVICENAME $MESSAGEW21" 15 50 "$IWPRIV" 2>"$TMP" || bailout 1
434 read -r IWPRIV <"$TMP" ; rm -f "$TMP"
437 if [ "$iswireless" = "1" ] ; then
441 fi # Setup wireless options?
443 # Configure VLAN on this interface?
444 if $DIALOG --defaultno --yesno "$MESSAGE16" 8 45; then
445 $DIALOG --inputbox "$MESSAGE17 $DV" 10 45 2>"$TMP" || bailout 1
446 read -r VLAN <"$TMP" ; rm -f "$TMP"
447 if [ -n "$VLAN" ]; then
448 modprobe 8021q # avoid warning that VLAN support isn't present yet
453 fi # INTERACTIVE=true
455 # Use DHCP broadcast?
456 if ("${INTERACTIVE}" && "${DIALOG}" --yesno "${MESSAGE2}" 8 45) || \
457 (! "${INTERACTIVE}" && [[ "${METHOD}" == 'dhcp' ]]) ; then
458 if [ -w /etc/network/interfaces ]; then
460 awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}}
461 /^\W$/{if(blank==0){lastblank=1}else{lastblank=0}{blank=1}}
462 /\w/{blank=0;lastblank=0}
463 {if(!(found+lastblank)){print}}
464 END{print "iface '"$DV"' inet dhcp";if("'"$PDV"'"!=""){print "\tvlan-raw-device '"$PDV"'"}}' \
465 /etc/network/interfaces >"$TMP"
468 # write wireless configuration only when we are dealing with a wireless device,
469 # it might be set from a previous configuration run of a wireless device
470 # while the currently configured network device isn't a wireless device
471 echo -e "$IWOURLINE" >> "$TMP"
474 #echo -e "\n\n" >> $TMP
475 cat "$TMP" >/etc/network/interfaces
477 # Add an "auto" entry
481 if "${INTERACTIVE}" ; then
482 if [ -f /etc/network/interfaces ]; then
483 awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}}
484 /address/{if(found){address=$NF}}
485 /netmask/{if(found){netmask=$NF}}
486 /broadcast/{if(found){broadcast=$NF}}
487 /gateway/{if(found){gateway=$NF}}
488 /dns-nameservers/{if(found){dnsnameservers=$NF}}
489 END{print address" "netmask" "broadcast" "gateway" "dnsnameservers}' /etc/network/interfaces >"$TMP"
490 read -r IP NM BC DG NS <"$TMP"
494 $DIALOG --inputbox "$MESSAGE6 $DV" 10 45 "${IP:-192.168.0.1}" 2>"$TMP" || bailout 1
495 read -r IP <"$TMP" ; rm -f "$TMP"
497 $DIALOG --inputbox "$MESSAGE7 $DV" 10 45 "${NM:-255.255.255.0}" 2>"$TMP" || bailout 1
498 read -r NM <"$TMP" ; rm -f "$TMP"
500 $DIALOG --inputbox "$MESSAGE8 $DV" 10 45 "${BC:-${IP%.*}.255}" 2>"$TMP" || bailout 1
501 read -r BC <"$TMP" ; rm -f "$TMP"
503 $DIALOG --inputbox "$MESSAGE9" 10 45 "${DG:-${IP%.*}.1}" 2>"$TMP"
504 read -r DG <"$TMP" ; rm -f "$TMP"
506 if [ -f "/etc/resolv.conf" ]; then
507 NS="$(awk '/^nameserver/{printf "%s ",$2}' /etc/resolv.conf)"
510 $DIALOG --inputbox "$MESSAGE10" 10 45 "${NS:-$DG}" 2>"$TMP"
511 read -r NS <"$TMP" ; rm -f "$TMP"
514 if [ -w /etc/network/interfaces ]; then
519 # ensure we don't leak the IWOURLINE into the
520 # following awk command line, if we are configuring
521 # a device without wireless capabilities
526 awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}}
528 END{print "\niface '"$DV"' inet static\n\taddress '"$IP"'\n\tnetmask '"$NM"'\n\tnetwork '"${IP%.*}.0"'";if("'"$BC"'"!=""){print "\tbroadcast '"$BC"'"};if("'"$DG"'"!=""){print "\tgateway '"$DG"'"};if("'"$NS"'"!=""){print "\tdns-nameservers '"$NS"'"};if("'"$PDV"'"!=""){print "\tvlan-raw-device '"$PDV"'"};if("'"$IWOURLINE"'"!=""){print "'"$IWOURLINE"'"};print "\n"}' \
529 /etc/network/interfaces >"$TMP"
531 cat "$TMP" >/etc/network/interfaces
534 # Add an "auto" entry
538 fi # Use DHCP broadcast?
544 # get persistent interface names across reboots
546 # make sure we don't run the dhcp stuff when using /etc/network/interfaces
552 NET_DEVICE_NAME="Network_device"
553 NET_DEVICE_NAME_W="Wireless_device"
554 NET_DEVICE_NAME_FW="Firewire_device"
555 NET_DEVICE_NAME_AUTO="Auto"
556 MESSAGE0="No supported network cards found."
557 MESSAGE1="Please select network device"
558 MESSAGE2="Use DHCP broadcast?"
559 MESSAGE6="Please enter IP Address for"
560 MESSAGE7="Please enter Network Mask for"
561 MESSAGE8="Please enter Broadcast Address for"
562 MESSAGE9="Please enter Default Gateway"
563 MESSAGE10="Please enter Nameserver(s)"
564 MESSAGE13="Setup wireless options?"
565 MESSAGE14="Failed to bring up the interface, would you like to reconfigure it?"
566 MESSAGE15="Interface enabled, do you want it auto enabled at boot?"
567 MESSAGE16="Configure VLAN on this interface?"
568 MESSAGE17="Please enter VLAN id for"
569 MESSAGEW4="Enter the ESSID for"
570 MESSAGEW5="\n\n\n(empty for 'any', not recommended !)\n"
571 MESSAGEW6="Enter the NWID (cell identifier)\nfor"
572 MESSAGEW7=", if needed\n\n\n"
573 MESSAGEW8="Enter the mode for"
574 MESSAGEW9="\n\n(Managed(=default), Ad-Hoc, Master,\nRepeater, Secondary, auto)\n"
575 MESSAGEW10="Enter channel number for"
576 MESSAGEW11="\n\n(0 bis 16, empty for auto or if you want to\n enter the frequency next)\n"
577 MESSAGEW12="Enter the frequency for"
578 MESSAGEW13="\n\n(e.g 2.412G, empty for auto)"
579 MESSAGEW14="Enter the encryption key\nfor"
580 MESSAGEW15="\n\n(empty for cleartext, not recommended !!)"
581 MESSAGEW16="Enter additional parameters for\n'iwconfig"
582 MESSAGEW17="' if needed, e.g.\n\n\nsens -80 rts 512 frag 512 rate 5.5M"
583 MESSAGEW18="Enter additional parameters for\n'iwspy"
584 MESSAGEW19="' if needed\n\n\n"
585 MESSAGEW20="Enter additional parameters for\n'iwpriv"
586 MESSAGEW21="' if needed\n\n\n"
587 MESSAGEW22="Enable WPA support?"
588 MESSAGEW23="Enter the WPA passphrase (passphrase must be 8..63 characters) for"
589 MESSAGEW25="Would you like to store your wep key in it's own private file ("
590 MESSAGEW26=")? If you say no, your wep key will be stored in /etc/network/interfaces and will be readable by any account on your system. You may want to 'chmod 600 /etc/network/interfaces' if you answer no to this question"
591 MESSAGEWSCAN1="Scan for available wireless networks?"
592 MESSAGEWSCAN2="Please choose a wireless network from below:"
594 NET_DEV="${NET_DEV:-}"
595 METHOD="${METHOD,,:-}"
597 NETMASK="${NETMASK:-}"
598 GATEWAY="${GATEWAY:-}"
603 if [ -r /proc/net/dev ] ; then
604 LAN=$(tail -n +3 /proc/net/dev | awk -F: '{print $1}'| sed "s/\s*//" | grep -v -e ^lo -e ^vmnet | sort)
609 if [[ -n "${NET_DEV}" ]] && [[ -n "${METHOD}" ]]; then
610 if [[ "${METHOD}" != 'dhcp' ]]; then
612 if [[ -z "${IPADDR}" ]]; then
613 echo "Mandatory parameter IPADDR for method ${METHOD} missing" >&2
616 if [[ -z "${NETMASK}" ]]; then
617 echo "Mandatory parameter NETMASK for method ${METHOD} missing" >&2
620 if [[ "${missed}" -gt 0 ]]; then
621 echo "Can not proceed, exiting..." >&2
630 if [ -z "${WLAN[*]}" ] ; then
631 WLAN_OLD=( $(tail -n +3 /proc/net/wireless 2>/dev/null|awk -F: '{print $1}') )
632 # /proc/net/wireless does not work e.g. with iwl3945 on kernel 2.6.33 anymore
633 WLAN_NEW=( $(for i in /sys/class/net/* ; do ( [ -d "$i/wireless" ] || [ -d "$i/phy80211" ] ) && basename "$i" ; done) )
636 iwconfig "${DEV}" 2>/dev/null 1>&2 && WLAN_IWCONFIG+=("${DEV}")
638 WLAN=( $(echo "${WLAN_OLD[@]}" "${WLAN_NEW[@]}" "${WLAN_IWCONFIG[@]}" | tr ' ' '\n' | sort -u) )
641 unset LAN_DEVICES WLAN_DEVICES FIREWIRE_DEVICES NETDEVICES WLAN_IWCONFIG
643 while read -r dev mac; do
644 #echo "Making NETDEVICES $NETDEVICESCOUNT $dev"
645 iswlan=$(echo "$dev" "${WLAN[@]}"|tr ' ' '\n'|sort|uniq -d)
647 grep auto /etc/network/interfaces | grep -q "$dev" && isauto="1"
648 driver=$(ethtool -i "$dev" 2>/dev/null|awk '/^driver:/{print $2}')
649 if [ "$driver" ]; then
650 if [ "$iswlan" ]; then
651 NETDEVICES[$NETDEVICESCOUNT]="$dev A::$isauto M::$mac D::$driver W::1 F::0"
653 NETDEVICES[$NETDEVICESCOUNT]="$dev A::$isauto M::$mac D::$driver W::0 F::0"
656 if [ "$iswlan" ]; then
657 NETDEVICES[$NETDEVICESCOUNT]="$dev A::$isauto M::$mac W::1 F::0"
659 NETDEVICES[$NETDEVICESCOUNT]="$dev A::$isauto M::$mac W::0 F::0"
662 #echo "Made to ${NETDEVICES[$NETDEVICESCOUNT]}"
663 ((NETDEVICESCOUNT++))
664 done < <(ip link show | awk ' !/^\s/{sub(/:/,"",$2);IFACE=$2} /link.ether/{if (IFACE !~/^vmnet/) print IFACE" "$2}')
666 if [ "$(ethtool -i "${dev}" 2>/dev/null|awk '/^bus-info:/{print $2}')" == "ieee1394" ]; then
668 grep auto /etc/network/interfaces | grep -q "${dev}" && isauto="1"
669 NETDEVICES[$NETDEVICESCOUNT]="${dev} A::${isauto} D::$(ethtool -i "${dev}" 2>/dev/null|awk '/^driver:/{print $2}') W::0 F::1"
670 ((NETDEVICESCOUNT++))
674 #NETDEVICES="$(cat /proc/net/dev | awk -F: '/eth.:|lan.:|tr.:|wlan.:|ath.:|ra.:/{print $1}')"
676 if [ -z "${NETDEVICES[*]}" ]; then
677 $DIALOG --msgbox "$MESSAGE0" 15 45
681 count="$NETDEVICESCOUNT"
683 if [ "$count" -gt 1 ]; then
686 while [ $mycount -lt $count ]; do
687 DEVICE=${NETDEVICES[$mycount]}
688 #echo "$mycount is $DEVICE"
690 #echo "name: $DEVICENAME auto: $isauto fw: $isfirewire mac: $mac driver: $driver"
692 DEVICELIST=( "${DEVICELIST[@]}" "$mycount" "$MY_DEVICE_NAME" )
699 EXITMENU=( $EXITKEY Exit )
701 # main program loop until they bailout
703 # first get the device
704 if [ "$count" -gt 1 ]; then
705 if "${INTERACTIVE}" ; then
707 $DIALOG --menu "$MESSAGE1" 18 60 12 "${DEVICELIST[@]}" "${EXITMENU[@]}" 2>"$TMP" || bailout
708 read -r DV <"$TMP" ; rm -f "$TMP"
710 # we have interface name so we need to find its number in NETDEVICES
713 for DV in "${!NETDEVICES[@]}"; do
714 if [[ "${NETDEVICES[$DV]}" =~ ^"${NET_DEV} " ]]; then
719 if ! "${found}"; then
720 echo "There is no interface ${NET_DEV} in the system" >&2
724 [[ -z "${IFACEDONE}" ]] || bailout
726 [ "$DV" = "$EXITKEY" ] && bailout
730 # they have asked to stop configuring the interface so exit
731 [ -z "$IFACEDONE" ] || bailout
735 while [ -n "$DV" ] && [ -z "$IFACEDONE" ]; do
736 configiface "${METHOD}" "${IPADDR}" "${NETMASK}" "${GATEWAY}" "${DNS}"
738 if "${INTERACTIVE}" ; then
739 $DIALOG --yesno "$MESSAGE14" 15 50 || IFACEDONE="DONE"
741 echo "${MESSAGE14}" >&2
745 if "${INTERACTIVE}" ; then
746 if $DIALOG --yesno "$MESSAGE15" 12 50 ; then
759 ## END OF FILE #################################################################