mirror of
				https://github.com/brain-hackers/brain-config.git
				synced 2025-11-04 14:38:36 +09:00 
			
		
		
		
	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:
		
							
								
								
									
										6
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								debian/changelog
									
									
									
									
										vendored
									
									
								
							@@ -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
 | 
					raspi-config (20180406) stretch; urgency=medium
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  * Set Wi-Fi country while connecting to SSID
 | 
					  * Set Wi-Fi country while connecting to SSID
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										28
									
								
								raspi-config
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								raspi-config
									
									
									
									
									
								
							@@ -428,25 +428,33 @@ get_wifi_country() {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
do_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"
 | 
					  oIFS="$IFS"
 | 
				
			||||||
  if [ "$INTERACTIVE" = True ]; then
 | 
					  if [ "$INTERACTIVE" = True ]; then
 | 
				
			||||||
    IFS="/"
 | 
					    IFS="/"
 | 
				
			||||||
    value=$(cat /usr/share/zoneinfo/iso3166.tab | tail -n +26 | tr '\t' '/' | tr '\n' '/')
 | 
					    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)
 | 
					    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
 | 
					  else
 | 
				
			||||||
    COUNTRY=$1
 | 
					    COUNTRY=$1
 | 
				
			||||||
    true
 | 
					    true
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  if [ $? -eq 0 ];then
 | 
					  if [ $? -eq 0 ];then
 | 
				
			||||||
    if [ -e /etc/wpa_supplicant/wpa_supplicant.conf ]; then
 | 
					    wpa_cli -i "$IFACE" set country "$COUNTRY"
 | 
				
			||||||
        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
 | 
					 | 
				
			||||||
    if ! iw reg set "$COUNTRY" 2> /dev/null; then
 | 
					    if ! iw reg set "$COUNTRY" 2> /dev/null; then
 | 
				
			||||||
        ASK_TO_REBOOT=1
 | 
					        ASK_TO_REBOOT=1
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
@@ -456,8 +464,8 @@ do_wifi_country() {
 | 
				
			|||||||
    if [ "$INTERACTIVE" = True ]; then
 | 
					    if [ "$INTERACTIVE" = True ]; then
 | 
				
			||||||
        whiptail --msgbox "Wi-fi country set to $COUNTRY" 20 60 1
 | 
					        whiptail --msgbox "Wi-fi country set to $COUNTRY" 20 60 1
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					    wpa_cli -i "$IFACE" save_config > /dev/null 2>&1
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  IFS=$oIFS
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
get_hostname() {
 | 
					get_hostname() {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user