Skip to content

Commit

Permalink
feat: Get-SystemDrive, fix SOFTWARE temp path (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Aug 11, 2024
1 parent 5065610 commit 28d1862
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,18 @@ function Get-Accounts {
return $data
}

function Get-SystemDrive {
@(
$env:SystemDrive,
(Get-CimInstance -ClassName Win32_OperatingSystem).SystemDrive,
"C:"
) | ForEach-Object {
if (($_.Length -eq 2) -and (Test-Path $_ -ItemType Container)) {
return $_
}
}

throw "Failed to find the system drive!"
}

Export-ModuleMember -Function Get-UserPath, Get-Accounts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$seperator = [IO.Path]::PathSeparator

# Add modules path
$env:PSModulePath += "$seperator" + "$PWD\AtlasModules\Scripts\Modules"

# Update PATH variable
$env:Path = [System.Environment]::GetEnvironmentVariable("Path",[System.EnvironmentVariableTarget]::Machine) + `
$seperator + `
[System.Environment]::GetEnvironmentVariable("Path",[System.EnvironmentVariableTarget]::User)
2 changes: 1 addition & 1 deletion src/playbook/Executables/CLEANUP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function Invoke-AtlasDiskCleanup {

# Check for other installations of Windows
# If so, don't cleanup as it will also cleanup other drives, which will be slow, and we don't want to touch other data
$drives = (Get-PSDrive -PSProvider FileSystem).Root | Where-Object { $_ -notmatch $env:SystemDrive }
$drives = (Get-PSDrive -PSProvider FileSystem).Root | Where-Object { $_ -notmatch $(Get-SystemDrive) }
foreach ($drive in $drives) {
if (!(Test-Path -Path $(Join-Path -Path $drive.Root -ChildPath 'Windows') -PathType Container)) {
Invoke-AtlasDiskCleanup
Expand Down
5 changes: 3 additions & 2 deletions src/playbook/Executables/LIBREWOLF.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $ProgressPreference = "SilentlyContinue"
$ErrorActionPreference = "Stop"

# Initial variables
$drive = Get-SystemDrive
$env:PSModulePath += ";$PWD\AtlasModules\Scripts\Modules"
$desktop = [Environment]::GetFolderPath("Desktop")
$startMenu = [Environment]::GetFolderPath("CommonPrograms")
Expand All @@ -25,8 +26,8 @@ $librewolfUpdaterDownload = (Invoke-RestMethod -Uri "$librewolfUpdaterURI").Asse
Select-Object -ExpandProperty browser_download_url

# Output paths
$outputLibrewolf = "$env:systemdrive\$librewolfFileName"
$outputLibrewolfUpdater = "$env:systemdrive\librewolf-winupdater.zip"
$outputLibrewolf = "$drive\$librewolfFileName"
$outputLibrewolfUpdater = "$drive\librewolf-winupdater.zip"

Write-Output "Downloading the latest LibreWolf setup"
curl.exe -LSs "$librewolfDownload" -o "$outputLibrewolf"
Expand Down
2 changes: 1 addition & 1 deletion src/playbook/Executables/SOFTWARE.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $msiArgs = "/qn /quiet /norestart ALLUSERS=1 REBOOT=ReallySuppress"
$arm = ((Get-CimInstance -Class Win32_ComputerSystem).SystemType -match 'ARM64') -or ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64')

# Create temporary directory
$tempDir = Join-Path -Path $([System.IO.Path]::GetTempPath()) -ChildPath $([System.Guid]::NewGuid())
$tempDir = Join-Path -Path $(Get-SystemDrive) -ChildPath $([System.Guid]::NewGuid())
New-Item $tempDir -ItemType Directory -Force | Out-Null
Push-Location $tempDir

Expand Down

0 comments on commit 28d1862

Please sign in to comment.