mirror of
https://github.com/cimryan/teslausb.git
synced 2026-03-01 04:30:33 +00:00
Add setup-piForHeadlessConfig.ps1
Script to automate the process of preparing the Pi to listen for SSH connections over USB.
This commit is contained in:
31
windows_archive/setup-piForHeadlessConfig.ps1
Normal file
31
windows_archive/setup-piForHeadlessConfig.ps1
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
[CmdletBinding()]
|
||||||
|
Param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory=$True,Position=1)]
|
||||||
|
[string]$driveLetter
|
||||||
|
)
|
||||||
|
|
||||||
|
$drivePath="${driveLetter}:"
|
||||||
|
$configPath = "$drivePath\config.txt"
|
||||||
|
$cmdlinePath = "$drivePath\cmdline.txt"
|
||||||
|
$sshPath = "$drivePath\ssh"
|
||||||
|
|
||||||
|
if ((![System.IO.File]::Exists($configPath) -or
|
||||||
|
(![System.IO.File]::Exists($cmdlinePath)))) {
|
||||||
|
Write-Error "Didn't find cmdline.txt and config.txt on drive $drivePath."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Verbose "Updating $configPath ..."
|
||||||
|
|
||||||
|
"" | Out-File -FilePath $configPath -Append -Encoding utf8
|
||||||
|
"dtoverlay=dwc2" | Out-File -FilePath $configPath -Append -Encoding utf8
|
||||||
|
|
||||||
|
Write-Verbose "Updating $cmdlinePath ..."
|
||||||
|
$cmdlinetxtContent = gc -Raw $cmdlinePath
|
||||||
|
$cmdlinetxtContent.Replace("rootwait", "rootwait modules-load=dwc2,g_ether") | Out-File -FilePath $cmdlinePath -Encoding utf8
|
||||||
|
|
||||||
|
Write-Verbose "Enabling SSH ..."
|
||||||
|
[System.IO.File]::CreateText($sshPath).Dispose()
|
||||||
|
|
||||||
|
Write-Verbose "All done."
|
||||||
Reference in New Issue
Block a user