diff --git a/setup/macos_linux/setup-piForHeadlessConfig.sh b/setup/macos_linux/setup-piForHeadlessConfig.sh deleted file mode 100755 index 1fa1e498c..000000000 --- a/setup/macos_linux/setup-piForHeadlessConfig.sh +++ /dev/null @@ -1,98 +0,0 @@ -#! /bin/bash -eu - -# This script will modify the cmdline.txt file on a freshly flashed Raspbian Stretch/Lite -# It readies it for SSH, USB OTG, USB networking, and Wifi -# -# Pass it the path to the location at which the "boot" filesystem is mounted. -# E.g. on a Mac: -# ./setup-piForHeadlessConfig.sh /Volumes/boot -# or on Ubuntu: -# ./setup-piForHeadlessConfig.sh /media/$USER/boot -# cd /Volumes/boot (or wherever the boot folder is mounted) -# chmod +x setup-piForHeadlessConfig.sh -# ./setup-piForHeadlessConfig.sh -# -# Put the card in your Pi, and reboot! - -# Creates the ssh file if needed, since Raspbian now disables -# ssh by default if the file isn't present - -BOOT_DIR="$1" - -function verify_file_exists () { - local file_name="$1" - local expected_path="$2" - - if [ ! -e "$expected_path/$file_name" ] - then - echo "STOP: Didn't find $file_name at $expected_path." - exit 1 - fi -} - -function verify_wifi_variables () { - if [ -z "${SSID+x}" ] || [ -z "${WIFIPASS+x}" ] - then - echo 'STOP: You need to specify your wifi name and password first. Run: ' - echo " " - echo ' export SSID=your_ssid' - echo ' export WIFIPASS=your_wifi_password' - echo " " - echo "Be sure to replace the values with your SSID (network name) and password." - exit 1 - fi -} - -verify_file_exists "cmdline.txt" "$BOOT_DIR" -verify_file_exists "config.txt" "$BOOT_DIR" - -verify_wifi_variables - -CMDLINE_TXT_PATH="$BOOT_DIR/cmdline.txt" -CONFIG_TXT_PATH="$BOOT_DIR/config.txt" - -if ! grep -q "dtoverlay=dwc2" "$CONFIG_TXT_PATH" -then - echo "Updating $CONFIG_TXT_PATH ..." - echo "" >> "$CONFIG_TXT_PATH" - echo "dtoverlay=dwc2" >> "$CONFIG_TXT_PATH" -else - echo "$CONFIG_TXT_PATH already contains the required dwc2 module" -fi - -if ! grep -q "dwc2,g_ether" "$CMDLINE_TXT_PATH" -then - echo "Updating $CMDLINE_TXT_PATH ..." - sed -i'.bak' -e "s/rootwait/rootwait modules-load=dwc2,g_ether/" -e "s@ init=/usr/lib/raspi-config/init_resize.sh@@" "$CMDLINE_TXT_PATH" -else - echo "$CMDLINE_TXT_PATH already updated with modules and removed initial resize script." -fi - -echo "Enabling SSH ..." -touch "$BOOT_DIR/ssh" - -# Sets up wifi credentials so wifi will be -# auto configured on first boot - -WPA_SUPPLICANT_CONF_PATH="$BOOT_DIR/wpa_supplicant.conf" - -echo "Adding Wifi setup file (wpa_supplicant.conf)." -if [ -r "$WPA_SUPPLICANT_CONF_PATH" ] -then - rm "$WPA_SUPPLICANT_CONF_PATH" -fi - -cat << EOF >> "$WPA_SUPPLICANT_CONF_PATH" -ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev -update_config=1 - -network={ - ssid="$SSID" - psk="$WIFIPASS" - key_mgmt=WPA-PSK -} -EOF - -echo "" -echo '-- Files updated and ready for Wifi and SSH over USB --' -echo "" diff --git a/setup/windows/WpaSupplicantConf.psm1 b/setup/windows/WpaSupplicantConf.psm1 deleted file mode 100644 index 96a8c6c31..000000000 --- a/setup/windows/WpaSupplicantConf.psm1 +++ /dev/null @@ -1,91 +0,0 @@ -function Write-Header { -param( - [string]$driveLetter - ) -$header=@" -ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev -update_config=1 -"@ - - Set-WpaSupplicantConfContent "$driveLetter" "$header" -} - -function Add-Network { -param( - [string]$driveLetter, - [string]$wifiSSID, - [string]$wifiPSK - ) - - $network=@" - - -network={ - ssid="$wifiSSID" - psk="$wifiPSK" -} -"@ - - Add-WpaSupplicantConfContent "$driveLetter" "$network" -} - -function Set-WpaSupplicantConfContent { -param( - [string]$driveLetter, - [string]$content - ) - - $wpaSupplicantConfPath = Get-WpaSupplicantConfPath $driveLetter - $encodedContent = Encode-Content $content - Set-Content -Value $encodedContent -Encoding Byte -Path "$wpaSupplicantConfPath" -} - -function Add-WpaSupplicantConfContent { -param( - [string]$driveLetter, - [string]$content - ) - - $wpaSupplicantConfPath = Get-WpaSupplicantConfPath $driveLetter - $encodedContent = Encode-Content $content - Add-Content -Value $encodedContent -Encoding Byte -Path "$wpaSupplicantConfPath" -} - -function Verify-WpaSupplicantConfPath { -param( - [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 - } -} - -function Encode-Content { -param( - [string]$content - ) - $utf8 = New-Object System.Text.UTF8Encoding $false - - return $utf8.GetBytes($content) -} - -function Get-WpaSupplicantConfPath { -param( - [string]$driveLetter - ) - - Verify-WpaSupplicantConfPath $driveLetter - - return "${driveLetter}:\wpa_supplicant.conf" -} - -Export-ModuleMember -Function Write-Header -Export-ModuleMember -Function Add-Network diff --git a/setup/windows/add-wifi.ps1 b/setup/windows/add-wifi.ps1 deleted file mode 100644 index cd1b06e11..000000000 --- a/setup/windows/add-wifi.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -[CmdletBinding()] -Param -( - [Parameter(Mandatory=$True,Position=1)] - [string]$driveLetter, - - [Parameter(Mandatory=$True,Position=2)] - [string]$wifiSSID, - - [Parameter(Mandatory=$True,Position=3)] - [string]$wifiPSK -) - -Import-Module -Name ".\WpaSupplicantConf.psm1" -Force - -Add-Network "$driveLetter" "$wifiSSID" "$wifiPSK" - -Write-Verbose "All done." diff --git a/setup/windows/setup-piForHeadlessConfig.ps1 b/setup/windows/setup-piForHeadlessConfig.ps1 deleted file mode 100644 index 456c322ec..000000000 --- a/setup/windows/setup-piForHeadlessConfig.ps1 +++ /dev/null @@ -1,47 +0,0 @@ -[CmdletBinding()] -Param -( - [Parameter(Mandatory=$True,Position=1)] - [string]$driveLetter, - - [Parameter(Mandatory=$True,Position=2)] - [string]$wifiSSID, - - [Parameter(Mandatory=$True,Position=3)] - [string]$wifiPSK -) - -wget https://raw.githubusercontent.com/marcone/teslausb/main-dev/setup/windows/WpaSupplicantConf.psm1 -OutFile WpaSupplicantConf.psm1 -wget https://raw.githubusercontent.com/marcone/teslausb/main-dev/setup/windows/add-wifi.ps1 -OutFile add-wifi.ps1 - -Import-Module -Name ".\WpaSupplicantConf.psm1" -Force - -$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").Replace(" init=/usr/lib/raspi-config/init_resize.sh", "") | Out-File -FilePath $cmdlinePath -Encoding utf8 - -Write-Verbose "Enabling SSH ..." -[System.IO.File]::CreateText($sshPath).Dispose() - -Write-Verbose "(Re)creating WiFi configuration file $wpaSupplicantConfPath." - -Write-Header "$driveLetter" -Add-Network "$driveLetter" "$wifiSSID" "$wifiPSK" - -Write-Verbose "All done."