diff --git a/debian/changelog b/debian/changelog index e18c4bf..057ba15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +raspi-config (20180406+1) stretch; urgency=medium + + * Fix Wi-Fi country setting + + -- Serge Schneider Fri, 06 Apr 2018 14:28:02 +0100 + raspi-config (20180406) stretch; urgency=medium * Set Wi-Fi country while connecting to SSID diff --git a/raspi-config b/raspi-config index d625c25..d722198 100755 --- a/raspi-config +++ b/raspi-config @@ -428,25 +428,33 @@ get_wifi_country() { } do_wifi_country() { + IFACE="$(list_wlan_interfaces | head -n 1)" + if [ -z "$IFACE" ]; then + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "No wireless interface found" 20 60 + fi + return 1 + fi + + if ! wpa_cli -i "$IFACE" status > /dev/null 2>&1; then + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "Could not communicate with wpa_supplicant" 20 60 + fi + return 1 + fi + oIFS="$IFS" if [ "$INTERACTIVE" = True ]; then IFS="/" value=$(cat /usr/share/zoneinfo/iso3166.tab | tail -n +26 | tr '\t' '/' | tr '\n' '/') COUNTRY=$(whiptail --menu "Select the country in which the Pi is to be used" 20 60 10 ${value} 3>&1 1>&2 2>&3) + IFS=$oIFS else COUNTRY=$1 true fi if [ $? -eq 0 ];then - if [ -e /etc/wpa_supplicant/wpa_supplicant.conf ]; then - if grep -q "^country=" /etc/wpa_supplicant/wpa_supplicant.conf ; then - sed -i --follow-symlinks "s/^country=.*/country=$COUNTRY/g" /etc/wpa_supplicant/wpa_supplicant.conf - else - sed -i --follow-symlinks "1i country=$COUNTRY" /etc/wpa_supplicant/wpa_supplicant.conf - fi - else - echo "country=$COUNTRY" > /etc/wpa_supplicant/wpa_supplicant.conf - fi + wpa_cli -i "$IFACE" set country "$COUNTRY" if ! iw reg set "$COUNTRY" 2> /dev/null; then ASK_TO_REBOOT=1 fi @@ -456,8 +464,8 @@ do_wifi_country() { if [ "$INTERACTIVE" = True ]; then whiptail --msgbox "Wi-fi country set to $COUNTRY" 20 60 1 fi + wpa_cli -i "$IFACE" save_config > /dev/null 2>&1 fi - IFS=$oIFS } get_hostname() {