summaryrefslogtreecommitdiff
path: root/setnet.sh
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2017-01-06 19:03:51 +0000
committerKatolaZ <katolaz@freaknet.org>2017-01-06 19:03:51 +0000
commit7376d8543ed76b47b0e4d0ede4ee215e093549d9 (patch)
treec94605016f77e04d1cddb8e3c45f4ed94476bfff /setnet.sh
parent9d819b2b4a7269b5d9e27c1a93b46661a34ae542 (diff)
replaced iwconfig with iw -- better diagnostics for dhclient
Diffstat (limited to 'setnet.sh')
-rwxr-xr-xsetnet.sh44
1 files changed, 25 insertions, 19 deletions
diff --git a/setnet.sh b/setnet.sh
index 00f33da..d63f5c4 100755
--- a/setnet.sh
+++ b/setnet.sh
@@ -47,7 +47,7 @@ DIALOG="dialog --backtitle \"${TOPSTR}\" "
## the script will exit
##
-HARD_DEPS="ip dhclient dialog iwconfig"
+HARD_DEPS="ip dhclient dialog iw sed grep cat awk which"
##
## Suggested dependencies. The script will issue a warning if any of
@@ -376,7 +376,9 @@ DEVNAME=$1
fi
DEVMAC=$(ip link show "${DEVNAME}" | tail -n +2 | sed -r 's/^\ +//g' | cut -d " " -f 2)
- DEVCONF="MAC: ${DEVMAC}\n"
+ DEV_STATUS=$(ip -o link | cut -d " " -f 2,9 | grep -E "^${DEVNAME}: " | cut -d " " -f 2)
+
+ DEVCONF="MAC: ${DEVMAC}\nLINK STATUS: ${DEV_STATUS}\n"
log "show_device_conf" "NET_FAMILIES: \"${NET_FAMILIES}\""
@@ -470,11 +472,16 @@ ${DEV_IP}\n${DEV_NET}\n${DEV_NETMASK}\n${DEV_GW}\n${DEV_DNS1}\n${DEV_DNS2}'\
config_ethernet_dhcp(){
##local
-DEVNAME=$1
-
- eval "${DIALOG} --msgbox 'Running \"dhclient ${DEVNAME}\"' ${INFO_HEIGHT} ${INFO_WIDTH}"
- dhclient -r ${DEVNAME}
- dhclient ${DEVNAME}
+ DEVNAME=$1
+
+ ##eval "${DIALOG} --msgbox 'Running \"dhclient ${DEVNAME}\"' ${INFO_HEIGHT} ${INFO_WIDTH}"
+ dhclient -r ${DEVNAME} 2>/dev/null
+ dhclient -v ${DEVNAME} 2>&1 |
+ eval "${DIALOG} --clear --title 'Running dhclient...' \
+ --programbox ${WINDOW_HEIGHT} ${WINDOW_WIDTH}" 2>${TMPFILE}
+ if [ $! -ne 0 ];then
+ log "config_ethernet_dhcp" "dhclient aborted"
+ fi
show_device_conf ${DEVNAME}
}
@@ -1012,19 +1019,18 @@ configure_device(){
##local
DEVNAME=$1
- ## Check if the network device is a wifi -- WEAK
- IS_WIFI=$(iwconfig ${DEVNAME} 2>/dev/null | grep -c "IEEE 802.11")
+ ## Check if the network device is a wifi -- this should be more robust...
+ iw ${DEVNAME} info 2>&1 >/dev/null
- case ${IS_WIFI} in
- 0)
- config_ethernet ${DEVNAME}
- ;;
- *)
- config_wifi ${DEVNAME}
- ;;
- esac
-
-
+ case $? in
+ 0)
+ config_wifi ${DEVNAME}
+ ;;
+ *)
+ config_ethernet ${DEVNAME}
+ ;;
+ esac
+
}