From 5b1ae08fec1b45559b3bbe4c1e7be13ec0651ba6 Mon Sep 17 00:00:00 2001 From: Ionut Biru Date: Wed, 16 Nov 2011 13:07:36 +0200 Subject: [PATCH] lib-ui-interactive: revamp for iproute2 syntax Signed-off-by: Ionut Biru --- src/core/libs/lib-ui-interactive.sh | 43 ++++++++++++++++++++-------------- 1 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh index 7e60c95..bb2fbf7 100644 --- a/src/core/libs/lib-ui-interactive.sh +++ b/src/core/libs/lib-ui-interactive.sh @@ -797,7 +797,7 @@ If any previous configuration you've done until now (like fancy filesystems) req interactive_runtime_network() { notify "If you wish to load your ethernet modules manually, please do so now in an another terminal." local ifaces - ifaces=$(ifconfig -a |grep "Link encap:Ethernet"|sed 's/ \+Link encap:Ethernet \+HWaddr \+/ /g') + ifaces=$(ip -o link show|grep ether| awk '{print $2, " ", $13}' | sed 's/: / /g') [ -z "$ifaces" ] && show_warning "No network interfaces?" "Cannot find any ethernet interfaces. This usually means udev was\nunable to load the module and you must do it yourself. Switch to\nanother VT, load the appropriate module, and run this step again." && return 1 @@ -816,7 +816,7 @@ interactive_runtime_network() { show_warning "Dhcpcd problem" "Failed to run dhcpcd. See $LOG for details." return 1 fi - if ! ifconfig $INTERFACE | grep -q 'inet addr:' + if ! ip -o addr show dev $INTERFACE | grep -q inet then show_warning "Dhcpcd problem" "DHCP request failed. dhcpcd returned 0 but no ip configured for $INTERFACE" return 1 @@ -847,24 +847,31 @@ interactive_runtime_network() { USERHAPPY=1 fi done - echo "running: ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up" >$LOG - if ! ifconfig $INTERFACE $IPADDR netmask $SUBNET broadcast $BROADCAST up >$LOG 2>&1 + + echo "running: ip link set dev $INTERFACE up" >$LOG + if ! ip link set dev $INTERFACE up + then + show_warning "ip link problem" "Failed to bring the interface $INTERFACE up" + return 1 + fi + echo "running: ip addr add $IPADDR/${SUBNET:-24} broadcast ${BROADCAST:-+} dev $INTERFACE" >$LOG + if ! ip addr add $IPADDR/${SUBNET:-24} broadcast ${BROADCAST:-+} dev $INTERFACE >$LOG 2>&1 then - show_warning "Ifconfig problem" "Failed to setup interface $INTERFACE" + show_warning "ip addr problem" "Failed to setup interface $INTERFACE" return 1 - fi - if [ -n "$GW" ]; then - route add default gw $GW >$LOG 2>&1 || notify "Failed to setup your gateway." || return 1 - fi - if [ -z "$PROXY_HTTP" ]; then - unset http_proxy - else - export http_proxy=$PROXY_HTTP - fi - if [ -z "$PROXY_FTP" ]; then - unset ftp_proxy - else - export ftp_proxy=$PROXY_FTP + fi + if [ -n "$GW" ]; then + ip route add default via $GW >$LOG 2>&1 || notify "Failed to setup your gateway." || return 1 + fi + if [ -z "$PROXY_HTTP" ]; then + unset http_proxy + else + export http_proxy=$PROXY_HTTP + fi + if [ -z "$PROXY_FTP" ]; then + unset ftp_proxy + else + export ftp_proxy=$PROXY_FTP fi echo "nameserver $DNS" >/etc/resolv.conf fi -- 1.7.7.3