a bit more logs

pull/458/head
romanitho 2023-10-31 18:04:27 +01:00
parent c125b77f86
commit 7b1a749b4e
1 changed files with 13 additions and 18 deletions

View File

@ -197,47 +197,42 @@ function Install-WingetAutoUpdate {
if (!(Test-Path $WAUinstallPath)) { if (!(Test-Path $WAUinstallPath)) {
New-Item -ItemType Directory -Force -Path $WAUinstallPath | Out-Null New-Item -ItemType Directory -Force -Path $WAUinstallPath | Out-Null
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
Write-ToLog "-> Running fresh installation..."
} }
elseif ($NoClean) { elseif ($NoClean) {
#Keep critical files #Keep critical files
Get-ChildItem -Path $WAUinstallPath -Exclude *.txt, mods, logs, icons | Remove-Item -Recurse -Force Get-ChildItem -Path $WAUinstallPath -Exclude *.txt, mods, logs, icons | Remove-Item -Recurse -Force
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Exclude icons -Recurse -Force -ErrorAction SilentlyContinue #Exclude icons if personalized Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Exclude icons -Recurse -Force -ErrorAction SilentlyContinue #Exclude icons if personalized
Write-ToLog "-> Updating previous installation. Keeping critical existing files..."
} }
else { else {
#Keep logs only #Keep logs only
Get-ChildItem -Path $WAUinstallPath -Exclude *.logs | Remove-Item -Recurse -Force Get-ChildItem -Path $WAUinstallPath -Exclude *.logs | Remove-Item -Recurse -Force
Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
Write-ToLog "-> Updating previous installation..."
} }
#White List or Black List apps #White List or Black List apps
if ($UseWhiteList) { if ($UseWhiteList) {
if (!$NoClean) { #If fresh install and "included_apps.txt" exists, copy the list to WAU
if ((Test-Path "$PSScriptRoot\included_apps.txt")) { if ((!$NoClean) -and (Test-Path "$PSScriptRoot\included_apps.txt")) {
Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
Write-ToLog "-> Copied a brand new Whitelist."
} }
else { #Else, only copy the "included_apps.txt" list if not existing in WAU
if (!$ListPath) { elseif (Test-Path "$WAUinstallPath\included_apps.txt") {
New-Item -Path $WAUinstallPath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null
}
}
}
elseif (!(Test-Path "$WAUinstallPath\included_apps.txt")) {
if ((Test-Path "$PSScriptRoot\included_apps.txt")) {
Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\included_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
} Write-ToLog "-> No Whitelist was existing. Copied from install sources."
else {
if (!$ListPath) {
New-Item -Path $WAUinstallPath -Name "included_apps.txt" -ItemType "file" -ErrorAction SilentlyContinue | Out-Null
}
}
} }
} }
else { else {
if (!$NoClean) { if (!$NoClean) {
Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
Write-ToLog "-> Copied brand new Blacklist."
} }
elseif (!(Test-Path "$WAUinstallPath\excluded_apps.txt")) { elseif (!(Test-Path "$WAUinstallPath\excluded_apps.txt")) {
Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\excluded_apps.txt" -Destination $WAUinstallPath -Recurse -Force -ErrorAction SilentlyContinue
Write-ToLog "-> No Blacklist was existing. Copied from install sources."
} }
} }