You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

41 lines
1.2 KiB

  1. #!/bin/bash -e
  2. install -v -d "${ROOTFS_DIR}/etc/wpa_supplicant"
  3. install -v -m 600 files/wpa_supplicant.conf "${ROOTFS_DIR}/etc/wpa_supplicant/"
  4. on_chroot << EOF
  5. SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_wait 0
  6. SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_netconf 1
  7. EOF
  8. if [ -v WPA_COUNTRY ]; then
  9. on_chroot <<- EOF
  10. SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_wifi_country "${WPA_COUNTRY}"
  11. EOF
  12. fi
  13. if [ -v WPA_ESSID ] && [ -v WPA_PASSWORD ]; then
  14. on_chroot <<EOF
  15. set -o pipefail
  16. wpa_passphrase "${WPA_ESSID}" "${WPA_PASSWORD}" | tee -a "/etc/wpa_supplicant/wpa_supplicant.conf"
  17. EOF
  18. elif [ -v WPA_ESSID ]; then
  19. cat >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" << EOL
  20. network={
  21. ssid="${WPA_ESSID}"
  22. key_mgmt=NONE
  23. }
  24. EOL
  25. fi
  26. # Disable wifi on 5GHz models if WPA_COUNTRY is not set
  27. mkdir -p "${ROOTFS_DIR}/var/lib/systemd/rfkill/"
  28. if [ -n "$WPA_COUNTRY" ]; then
  29. echo 0 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-3f300000.mmcnr:wlan"
  30. echo 0 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-fe300000.mmcnr:wlan"
  31. else
  32. echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-3f300000.mmcnr:wlan"
  33. echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-fe300000.mmcnr:wlan"
  34. fi