Create the wpa_supplicant file on the boot partition during setup-piForHeadlessConfig.ps1.

Also consolidate the documentation. Removed support for manual setup; that process doesn't add value, anymore.
This commit is contained in:
cimryan
2018-10-19 10:39:36 -07:00
parent 475af79d48
commit 832320aa1a
3 changed files with 38 additions and 63 deletions

View File

@@ -2,7 +2,13 @@
Param
(
[Parameter(Mandatory=$True,Position=1)]
[string]$driveLetter
[string]$driveLetter,
[Parameter(Mandatory=$True,Position=2)]
[string]$wifiSSID,
[Parameter(Mandatory=$True,Position=3)]
[string]$wifiPSK
)
$drivePath="${driveLetter}:"
@@ -28,4 +34,24 @@ $cmdlinetxtContent.Replace("rootwait", "rootwait modules-load=dwc2,g_ether").Rep
Write-Verbose "Enabling SSH ..."
[System.IO.File]::CreateText($sshPath).Dispose()
# Sets up wifi credentials so wifi will be
# auto configured on first boot
$wpaSupplicantConfPath="$drivePath\wpa_supplicant.conf"
Write-Verbose "(Re)creating WiFi configuration file $wpaSupplicantConfPath."
if ([System.IO.File]::Exists("$wpaSupplicantConfPath")) {
del "$wpaSupplicantConfPath"
}
"ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev`
update_config=1`
`
network={`
ssid=`"$wifiSSID`"`
psk=`"$wifiPSK`"`
key_mgmt=WPA-PSK`
}`
" | Out-File -FilePath "$wpaSupplicantConfPath" -Encoding utf8
Write-Verbose "All done."