2016-04-11 06:29:41 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
install -v -d "${ROOTFS_DIR}/etc/wpa_supplicant"
|
|
|
|
install -v -m 600 files/wpa_supplicant.conf "${ROOTFS_DIR}/etc/wpa_supplicant/"
|
2016-04-11 06:29:41 +00:00
|
|
|
|
2021-10-05 14:54:05 +00:00
|
|
|
on_chroot << EOF
|
|
|
|
SUDO_USER="${FIRST_USER_NAME}" raspi-config nonint do_boot_wait 0
|
|
|
|
EOF
|
|
|
|
|
2019-02-18 12:54:15 +00:00
|
|
|
if [ -v WPA_COUNTRY ]; then
|
2018-12-17 00:01:04 +00:00
|
|
|
echo "country=${WPA_COUNTRY}" >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf"
|
|
|
|
fi
|
|
|
|
|
2019-02-18 12:54:15 +00:00
|
|
|
if [ -v WPA_ESSID ] && [ -v WPA_PASSWORD ]; then
|
2018-12-17 00:01:04 +00:00
|
|
|
on_chroot <<EOF
|
2019-12-23 14:21:08 +00:00
|
|
|
set -o pipefail
|
|
|
|
wpa_passphrase "${WPA_ESSID}" "${WPA_PASSWORD}" | tee -a "/etc/wpa_supplicant/wpa_supplicant.conf"
|
2018-12-17 00:01:04 +00:00
|
|
|
EOF
|
2019-12-05 15:08:04 +00:00
|
|
|
elif [ -v WPA_ESSID ]; then
|
|
|
|
cat >> "${ROOTFS_DIR}/etc/wpa_supplicant/wpa_supplicant.conf" << EOL
|
|
|
|
|
|
|
|
network={
|
|
|
|
ssid="${WPA_ESSID}"
|
|
|
|
key_mgmt=NONE
|
|
|
|
}
|
|
|
|
EOL
|
2018-12-17 00:01:04 +00:00
|
|
|
fi
|
2019-06-07 15:21:03 +00:00
|
|
|
|
2020-09-18 13:40:33 +00:00
|
|
|
# Disable wifi on 5GHz models if WPA_COUNTRY is not set
|
2019-06-07 15:21:03 +00:00
|
|
|
mkdir -p "${ROOTFS_DIR}/var/lib/systemd/rfkill/"
|
2020-09-18 13:40:33 +00:00
|
|
|
if [ -n "$WPA_COUNTRY" ]; then
|
|
|
|
echo 0 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-3f300000.mmcnr:wlan"
|
|
|
|
echo 0 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-fe300000.mmcnr:wlan"
|
|
|
|
else
|
|
|
|
echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-3f300000.mmcnr:wlan"
|
|
|
|
echo 1 > "${ROOTFS_DIR}/var/lib/systemd/rfkill/platform-fe300000.mmcnr:wlan"
|
|
|
|
fi
|