--- a/net-setup +++ a/net-setup @@ -188,6 +188,24 @@ config_wireless() { fi } +config_wpa() { + cd /tmp/setup.opts + dialog --visit-items --title "SSID" \ + --inputbox "Please enter your SSID" \ + 20 50 2> ${iface}.SSID + SSID=$(tail -n 1 ${iface}.SSID) + dialog --visit-items --title "WPA(2)-PSK" \ + --inputbox "Please enter your WPA Preshared key in ASCII form. This should be between 8 and 63 characters" \ + 20 50 2> ${iface}.WPAKEY + WPA_KEY=$(tail -n 1 ${iface}.WPAKEY) + if [ -n "${WPA_KEY}" ] + then + mkdir -p /etc/wpa_supplicant + wpa_passphrase "${SSID}" "${WPA_KEY}" > /etc/wpa_supplicant/wpa_supplicant.conf + wpa_supplicant -B -i${iface} -c /etc/wpa_supplicant/wpa_supplicant.conf -Dnl80211,wext + fi +} + config_ip() { cd /tmp/setup.opts dialog --visit-items --title "TCP/IP setup" \ @@ -279,6 +297,18 @@ write_wireless_conf() { fi } +write_wpa_conf() { + cd /tmp/setup.opts + SSID=$(tail -n 1 ${iface}.SSID) + if [ -n "${SSID}" ] + then + echo "" >> /etc/conf.d/net + echo "# This wireless configuration file was built by net-setup" > /etc/conf.d/net + echo "modules_${iface}=\"wpa_supplicant\"" + echo "wpa_supplicant_${iface}=\"-Dnl80211,wext\"" + fi +} + write_net_conf() { cd /tmp/setup.opts echo "" > /etc/conf.d/net @@ -336,16 +366,22 @@ done dialog --visit-items --title "Network setup" \ --menu "This script is designed to setup both wired and wireless network settings. All questions below apply to the ${iface} interface only. Choose one option:" \ - 20 60 7 1 "My network is wireless" 2 "My network is wired" 2> ${iface}.WIRED_WIRELESS + 20 60 7 1 "My network is wired" 2 "My network is wireless (Open/WEP)" \ + 3 "My network is wireless (WPA-PSK/WPA2-PSK)" 2> ${iface}.WIRED_WIRELESS WIRED_WIRELESS=$(tail -n 1 ${iface}.WIRED_WIRELESS) case ${WIRED_WIRELESS} in 1) + config_ip + ;; + 2) config_wireless config_ip write_wireless_conf ;; - 2) + 3) + config_wpa config_ip + write_wpa_conf ;; esac write_net_conf