commit da3c60d3129a408c3743c24df8e2e0cc115d555e
parent a1a46ed0807a08cf3d92d493e85fb224cdef2f10
Author: clamiax <smoppy@gmail.com>
Date: Fri, 14 Aug 2015 11:12:21 +0200
When needed, autoset nameservers and bypass a sdhcp bug
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/iwpick b/iwpick
@@ -2,6 +2,9 @@
# Connects to a network
# Requires: wpa_supplicant, sdhcp, iwconfig
+NS1=208.67.222.222
+NS2=208.67.220.220
+
connect() {
iface=$1
essid=$2
@@ -25,6 +28,10 @@ connect() {
rm $tmp
fi
+ # sdhcp wait forever if $iface have no IP address. Workaround this.
+ t=$(ifconfig wlan0 |grep inet: |cut -d: -f2 |cut -d' ' -f1)
+ [ -z $t ] && echo 192.168.0.2 $iface
+
sdhcp -d $iface >/dev/null
}
@@ -85,6 +92,11 @@ main() {
done
connect "$iface" "$essid" "$key"
+
+ # If no DNS are set, then use our own
+ f=/etc/resolv.conf
+ t=$(grep ^[^#] $f |wc -l)
+ [ $t -eq 0 ] && printf "nameserver %s\nnameserver %s\n" $NS1 $NS2 >> $f
}
main "$@"