Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Further ,wifi refinements

Still not 100%
  • Loading branch information...
commit 3f63642b9fd67d318e340e34f54a3d67837a9e45 1 parent f176222
@rking rking authored rking@sharpsaw.org committed
Showing with 16 additions and 8 deletions.
  1. +16 −8 bin/,wifi
View
24 bin/,wifi
@@ -1,25 +1,33 @@
#!/bin/zsh
## Wifi startup sequence (using dhcpcd and possibly using wpa_supplicant)
actually_set_up() {
- sudo ifconfig $if down
- sudo killall -q dhcpcd wpa_supplicant || true
- sudo ifconfig $if up
sudo iw dev $if connect $essid
- if sudo grep "ssid=.$essid" $wpa_supplicant_conf_path; then
+ if grep "ssid=.$essid" $wpa_supplicant_conf_path; then
sudo wpa_supplicant -B -Dnl80211 -i$if -c$wpa_supplicant_conf_path
else
- : wpa_passphrase $essid
- : Consider piping that into sudo tee -a $wpa_supplicant_conf_path
+ printf "Enter passphrase (or blank for none): "
+ read pass
+ if [ -n "$pass" ]; then
+ echo $pass | wpa_passphrase $essid
+ else
+ echo "# No passphrase for ssid=\"$essid\""
+ fi >> $wpa_supplicant_conf_path
fi
sudo dhcpcd $if
+ ping -c1 4.2.2.2
+ until ping -c1 a.de; do sleep 1; echo Retrying ping, waiting on dhcpcd; done
[ -e $ntp ] && sudo $ntp start &
- ping -c1 4.2.2.2; ping -c2 a.de
}
set -e
wpa_supplicant_conf_path=$HOME/.wpasupp
ntp=/etc/init.d/ntp-client
if=${IF:-wlan0}
essid=$1
+
+sudo ifconfig $if down
+sudo killall -q dhcpcd wpa_supplicant || true
+sudo ifconfig $if up
+
if [ -n "$essid" ]; then
actually_set_up
else
@@ -28,6 +36,6 @@ else
echo
echo "\e[35mAvailable essids\e[0m:"
sudo iw $if scan | grep 'freq\|signal\|SSID' |
- sed 's/SSID: \(.*\)/^ that is [32m\1[0m\n/'
+ sed 's/SSID: \(.*\)/^ that is [32;1m\1[0m\n/'
fi
Please sign in to comment.
Something went wrong with that request. Please try again.