#!/bin/bash # search for possible wireless device # if more then one let user make selection # give warning with choice to exit when no selection has been made. # search for wireless networks # show and let user make selection # give warning with choice to exit when no selection has been made. # ask for password # repeat when it does not work # give warning with choice to exit when no selection has been made. sudo ifconfig wlan0 up open=$(sudo iwlist wlan0 scanning | grep ESSID* | zenity --list --title "Wireless networks in range" --text "Select your wireless network:" --width 800 --height 600 --column "Files") password=$(zenity --entry --title "wireless password" --text "Enter Wireless password:" --width=200 --height=100) sudo /etc/init.d/networking stop [ -e /etc/network/interfaces ] && sudo mv --verbose /etc/network/interfaces /etc/network/interfaces.backup sudo touch /etc/network/interfaces echo auto lo | sudo tee -a /etc/network/interfaces echo iface lo inet loopback | sudo tee -a /etc/network/interfaces echo | sudo tee -a /etc/network/interfaces echo auto wlan0 | sudo tee -a /etc/network/interfaces echo iface wlan0 inet dhcp | sudo tee -a /etc/network/interfaces echo pre-up /sbin/wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf | sudo tee -a /etc/network/interfaces echo post-down killall -q wpa_supplicant | sudo tee -a /etc/network/interfaces echo | sudo tee -a /etc/network/interfaces open=${open/ESSID:/} open=${open/\"/} open=${open/\"/} open=${open/ /} echo wpa_passphrase $open $password wpa_passphrase "$open" "$password" > $HOME/.wpa-supplicant-home.conf sudo rm --verbose /etc/wpa_supplicant.conf sudo ln --symbolic --verbose $HOME/.wpa-supplicant-home.conf /etc/wpa_supplicant.conf sudo /etc/init.d/networking restart exit