Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- [ -z "$1" ] && echo "iface" && exit 0
- iface="$1"
- dhclient $iface -x
- pkill wpa_supplicant
- ifconfig $iface down
- ifconfig $iface up
- echo -n "Enter SSID: "
- read essid
- channel="auto"
- mode="managed"
- #tests for encryption key
- while true; do
- read -r -s -p "$essid: Enter password: " key
- if [ ${#key} -lt 8 ] || [ ${#key} -gt 32 ]; then
- echo "The password must be 8-32 characters"
- :
- else
- break
- fi
- done
- skey=$(wpa_passphrase "$essid" $key 2>/dev/null | sed -n 's/^[ \t]psk=//gp')
- echo "ctrl_interface=/var/run/wpa_supplicant
- ap_scan=1
- network={
- ssid=\"$essid\"
- scan_ssid=1
- proto=WPA RSN
- key_mgmt=WPA-PSK
- pairwise=CCMP TKIP
- group=CCMP TKIP
- psk=$skey
- }" > /etc/wpa_supplicant/wpa_supplicant.conf
- if [[ -z `cat /etc/network/interfaces | grep $iface` ]]; then
- wpa_supplicant -B -Dwext -i $iface -c /etc/wpa_supplicant/wpa_supplicant.conf
- dhclient $iface
- else
- ifup $iface
- fi
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement