X-Git-Url: http://git.grml.org/?a=blobdiff_plain;f=sbin%2Fnetcardconfig;h=d79ceb6c7d704a414773765e77128f173991d803;hb=45b8379191095cf50ac2e58569e1820957a2cae5;hp=83cac2b0b23d2f56914cdd864e0df28878dd1883;hpb=956aca8cbb34395a8d4baeee044ce93f245c4365;p=grml-network.git diff --git a/sbin/netcardconfig b/sbin/netcardconfig index 83cac2b..d79ceb6 100755 --- a/sbin/netcardconfig +++ b/sbin/netcardconfig @@ -56,7 +56,7 @@ writeiwline() { for mod in /sys/module/rt2??0/ ; do if [ -d "$mod" ]; then - IWPREUPLINE="$IWPREUPLINE pre-up /sbin/ifconfig $DV up\n" + IWPREUPLINE="$IWPREUPLINE pre-up /sbin/ip link set $DV up\n" break fi done @@ -93,7 +93,7 @@ generate_udev_entry() { # 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 + for interface in $(ip -oneline link | awk '!/ lo: / {print $2}' | sed 's/:$//; s/@.*//') ; 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 @@ -158,7 +158,7 @@ remauto(){ scanwlan(){ i=0 - ifconfig "$DV" up + ip link set "$DV" up iwlist "$DV" scanning | grep "ESSID\|Quality" | sed -e "s/^.*ESSID:\"\|\"$//g" | tac > "$TMP" while read -r line do @@ -419,6 +419,17 @@ configiface() { writeiwline fi + # Configure VLAN on this interface? + if $DIALOG --defaultno --yesno "$MESSAGE16" 8 45; then + $DIALOG --inputbox "$MESSAGE17 $DV" 10 45 2>"$TMP" || bailout 1 + read -r VLAN <"$TMP" ; rm -f "$TMP" + if [ -n "$VLAN" ]; then + modprobe 8021q # avoid warning that VLAN support isn't present yet + PDV=$DV + DV="vlan$VLAN" + fi + fi + if $DIALOG --yesno "$MESSAGE2" 8 45; then if [ -w /etc/network/interfaces ]; then rm -f "$TMP" @@ -426,7 +437,7 @@ configiface() { /^\W$/{if(blank==0){lastblank=1}else{lastblank=0}{blank=1}} /\w/{blank=0;lastblank=0} {if(!(found+lastblank)){print}} - END{print "iface '"$DV"' inet dhcp"}' \ + END{print "iface '"$DV"' inet dhcp";if("'"$PDV"'"!=""){print "\tvlan-raw-device '"$PDV"'"}}' \ /etc/network/interfaces >"$TMP" echo -e "$IWOURLINE" >> "$TMP" #echo -e "\n\n" >> $TMP @@ -470,7 +481,7 @@ configiface() { if [ -w /etc/network/interfaces ]; then awk '/iface/{if(/'"$DV"'/){found=1}else{found=0}} {if(!found){print}} - 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("'"$IWOURLINE"'"!=""){print "'"$IWOURLINE"'"};print "\n"}' \ + 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"}' \ /etc/network/interfaces >"$TMP" cat "$TMP" >/etc/network/interfaces @@ -501,6 +512,8 @@ MESSAGE10="Please enter Nameserver(s)" MESSAGE13="Setup wireless options?" MESSAGE14="Failed to bring up the interface, would you like to reconfigure it?" MESSAGE15="Interface enabled, do you want it auto enabled at boot?" +MESSAGE16="Configure VLAN on this interface?" +MESSAGE17="Please enter VLAN id for" MESSAGEW4="Enter the ESSID for" MESSAGEW5="\n\n\n(empty for 'any', not recommended !)\n" MESSAGEW6="Enter the NWID (cell identifier)\nfor" @@ -539,7 +552,7 @@ if [ -z "${WLAN[*]}" ] ; then 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) + iwconfig "${DEV}" 2>/dev/null 1>&2 && WLAN_IWCONFIG+=("${DEV}") done WLAN=( $(echo "${WLAN_OLD[@]}" "${WLAN_NEW[@]}" "${WLAN_IWCONFIG[@]}" | tr ' ' '\n' | sort -u) ) fi @@ -569,10 +582,10 @@ while read -r dev mac; do ((NETDEVICESCOUNT++)) done < <(ip link show | awk ' !/^\s/{sub(/:/,"",$2);IFACE=$2} /link.ether/{if (IFACE !~/^vmnet/) print IFACE" "$2}') for dev in $LAN; do - if [ "$(ethtool -i $dev 2>/dev/null|awk '/^bus-info:/{print $2}')" == "ieee1394" ]; then + if [ "$(ethtool -i "${dev}" 2>/dev/null|awk '/^bus-info:/{print $2}')" == "ieee1394" ]; then isauto="0" - grep auto /etc/network/interfaces | grep -q $dev && isauto="1" - NETDEVICES[$NETDEVICESCOUNT]="$dev A::$isauto D::$(ethtool -i $dev 2>/dev/null|awk '/^driver:/{print $2}') W::0 F::1" + grep auto /etc/network/interfaces | grep -q "${dev}" && isauto="1" + NETDEVICES[$NETDEVICESCOUNT]="${dev} A::${isauto} D::$(ethtool -i "${dev}" 2>/dev/null|awk '/^driver:/{print $2}') W::0 F::1" ((NETDEVICESCOUNT++)) fi done