From 27d962dc7d9ea61f6079d19790d729a35bce9cf2 Mon Sep 17 00:00:00 2001 From: spl Date: Tue, 23 Feb 2016 17:17:26 +0000 Subject: [PATCH] Added wi-fi country setting to raspi-config --- raspi-config | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/raspi-config b/raspi-config index 74acb01..a659cd0 100755 --- a/raspi-config +++ b/raspi-config @@ -272,6 +272,25 @@ do_change_timezone() { dpkg-reconfigure tzdata } +do_configure_wifi_country() { + oIFS="$IFS" + 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) + if [ $? -eq 0 ];then + if grep -q "^country=" /etc/wpa_supplicant/wpa_supplicant.conf ; then + sed -i "s/^country=.*/country=$COUNTRY/g" /etc/wpa_supplicant/wpa_supplicant.conf + else + sed -i "1i country=$COUNTRY" /etc/wpa_supplicant/wpa_supplicant.conf + fi + if [ "$INTERACTIVE" = True ]; then + whiptail --msgbox "Wi-fi country set to $COUNTRY" 20 60 1 + fi + ASK_TO_REBOOT=1 + fi + IFS=$oIFS +} + do_change_hostname() { if [ "$INTERACTIVE" = True ]; then whiptail --msgbox "\ @@ -1213,6 +1232,7 @@ do_internationalisation_menu() { "I1 Change Locale" "Set up language and regional settings to match your location" \ "I2 Change Timezone" "Set up timezone to match your location" \ "I3 Change Keyboard Layout" "Set the keyboard layout to match your keyboard" \ + "I4 Change Wi-fi Country" "Set the legal channels used in your country" \ 3>&1 1>&2 2>&3) RET=$? if [ $RET -eq 1 ]; then @@ -1222,6 +1242,7 @@ do_internationalisation_menu() { I1\ *) do_change_locale ;; I2\ *) do_change_timezone ;; I3\ *) do_configure_keyboard ;; + I4\ *) do_configure_wifi_country ;; *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; esac || whiptail --msgbox "There was an error running option $FUN" 20 60 1 fi