01-03-2024, 04:03 PM
(This post was last modified: 01-03-2024, 09:03 PM by Tim Curtis.
Edit Reason: eta
)
I verified the code in worker.php that extracts the country code from pi-imager generated wpa_supplicant.conf file and then updates cfg_network table works correctly.
What doesn't seem right is the wpa_supplicant.conf file generated by the Pi Imager. It has country = US even though /boot/firstrun.sh shows country = GB which I specified in the imager.
Here's my test
1. Prep image using Pi-Imager 1.8.4
2. Set WiFi country to something other than US
3. Write the image
4. Insert USB-uSD dongle into a moOde Pi
# Save firstrun.sh file and examine it, verify country code
5. sudo cp /media/boot/firstrun.sh ./
# Add debug line to worker.php
6. sudo nano /media/rootfs/var/www/daemon/worker.php and add the bolded line
// Pi Imager: Import SSID/PSK/Country
if (file_exists('/etc/wpa_supplicant/wpa_supplicant.conf')) {
$moodeHeader = sysCmd('cat /etc/wpa_supplicant/wpa_supplicant.conf 2>&1 | grep "This file is automatically generated"');
sysCmd('cp /etc/wpa_supplicant/wpa_supplicant.conf /home/pi/');
7. Boot a Pi with the modified uSD card
8. SSH
# Examine country code
9. sudo cat ./wpa_supplicant.conf
What doesn't seem right is the wpa_supplicant.conf file generated by the Pi Imager. It has country = US even though /boot/firstrun.sh shows country = GB which I specified in the imager.
Here's my test
1. Prep image using Pi-Imager 1.8.4
2. Set WiFi country to something other than US
3. Write the image
4. Insert USB-uSD dongle into a moOde Pi
# Save firstrun.sh file and examine it, verify country code
5. sudo cp /media/boot/firstrun.sh ./
# Add debug line to worker.php
6. sudo nano /media/rootfs/var/www/daemon/worker.php and add the bolded line
// Pi Imager: Import SSID/PSK/Country
if (file_exists('/etc/wpa_supplicant/wpa_supplicant.conf')) {
$moodeHeader = sysCmd('cat /etc/wpa_supplicant/wpa_supplicant.conf 2>&1 | grep "This file is automatically generated"');
sysCmd('cp /etc/wpa_supplicant/wpa_supplicant.conf /home/pi/');
7. Boot a Pi with the modified uSD card
8. SSH
# Examine country code
9. sudo cat ./wpa_supplicant.conf