Fix Wi-Fi country setting

If country is set without running reconfiguring wpa_supplicant, the setting if wpa_cli saves over the config.
This commit is contained in:
Serge Schneider 2018-04-06 14:28:32 +01:00
parent 557ed06d31
commit 8cd873813d
2 changed files with 24 additions and 10 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
raspi-config (20180406+1) stretch; urgency=medium
* Fix Wi-Fi country setting
-- Serge Schneider <serge@raspberrypi.org> Fri, 06 Apr 2018 14:28:02 +0100
raspi-config (20180406) stretch; urgency=medium
* Set Wi-Fi country while connecting to SSID

View File

@ -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() {