-override mods (.txt) too
parent
e5d155f16d
commit
ddd852abc6
|
@ -4,6 +4,7 @@ function Test-Mods ($app) {
|
||||||
|
|
||||||
#Takes care of a null situation
|
#Takes care of a null situation
|
||||||
$ModsPreInstall = $null
|
$ModsPreInstall = $null
|
||||||
|
$ModsOverride = $null
|
||||||
$ModsUpgrade = $null
|
$ModsUpgrade = $null
|
||||||
$ModsInstall = $null
|
$ModsInstall = $null
|
||||||
$ModsInstalled = $null
|
$ModsInstalled = $null
|
||||||
|
@ -13,6 +14,9 @@ function Test-Mods ($app) {
|
||||||
if (Test-Path "$Mods\$app-preinstall.ps1") {
|
if (Test-Path "$Mods\$app-preinstall.ps1") {
|
||||||
$ModsPreInstall = "$Mods\$app-preinstall.ps1"
|
$ModsPreInstall = "$Mods\$app-preinstall.ps1"
|
||||||
}
|
}
|
||||||
|
if (Test-Path "$Mods\$app-override.txt") {
|
||||||
|
$ModsOverride = Get-Content "$Mods\$app-override.txt" -Raw
|
||||||
|
}
|
||||||
if (Test-Path "$Mods\$app-install.ps1") {
|
if (Test-Path "$Mods\$app-install.ps1") {
|
||||||
$ModsInstall = "$Mods\$app-install.ps1"
|
$ModsInstall = "$Mods\$app-install.ps1"
|
||||||
$ModsUpgrade = "$Mods\$app-install.ps1"
|
$ModsUpgrade = "$Mods\$app-install.ps1"
|
||||||
|
@ -25,6 +29,6 @@ function Test-Mods ($app) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled
|
return $ModsPreInstall, $ModsOverride, $ModsUpgrade, $ModsInstall, $ModsInstalled
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
||||||
$ExternalMods = "$ModsPath"
|
$ExternalMods = "$ModsPath"
|
||||||
|
|
||||||
#Get File Names Locally
|
#Get File Names Locally
|
||||||
$InternalModsNames = Get-ChildItem -Path $LocalMods -Name -Recurse -Include *.ps1
|
$InternalModsNames = Get-ChildItem -Path $LocalMods -Name -Recurse -Include *.ps1, *.txt
|
||||||
|
|
||||||
# If path is URL
|
# If path is URL
|
||||||
if ($ExternalMods -like "http*") {
|
if ($ExternalMods -like "http*") {
|
||||||
|
@ -35,8 +35,8 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
||||||
|
|
||||||
#Loop through all links
|
#Loop through all links
|
||||||
$WebResponse.Links | Select-Object -ExpandProperty href | ForEach-Object {
|
$WebResponse.Links | Select-Object -ExpandProperty href | ForEach-Object {
|
||||||
#Check for .ps1 in listing/HREF:s in an index page pointing to .ps1
|
#Check for .ps1/.txt in listing/HREF:s in an index page pointing to .ps1/.txt
|
||||||
if ($_ -like "*.ps1") {
|
if (($_ -like "*.ps1") -or ($_ -like "*.txt")) {
|
||||||
try {
|
try {
|
||||||
$dateExternalMod = ""
|
$dateExternalMod = ""
|
||||||
$dateLocalMod =""
|
$dateLocalMod =""
|
||||||
|
@ -67,9 +67,9 @@ function Test-ModsPath ($ModsPath, $WingetUpdatePath) {
|
||||||
}
|
}
|
||||||
# If path is UNC or local
|
# If path is UNC or local
|
||||||
else {
|
else {
|
||||||
if (Test-Path -Path $ExternalMods"\*.ps1") {
|
if ((Test-Path -Path $ExternalMods"\*.ps1") -or (Test-Path -Path $ExternalMods"\*.txt")) {
|
||||||
#Get File Names Externally
|
#Get File Names Externally
|
||||||
$ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1
|
$ExternalModsNames = Get-ChildItem -Path $ExternalMods -Name -Recurse -Include *.ps1, *.txt
|
||||||
#Delete Local Mods that don't exist Externally
|
#Delete Local Mods that don't exist Externally
|
||||||
foreach ($Mod in $InternalModsNames){
|
foreach ($Mod in $InternalModsNames){
|
||||||
If($Mod -notin $ExternalModsNames ){
|
If($Mod -notin $ExternalModsNames ){
|
||||||
|
|
|
@ -17,7 +17,10 @@ Function Update-App ($app) {
|
||||||
Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text
|
Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text
|
||||||
|
|
||||||
#Check if mods exist for preinstall/install/upgrade
|
#Check if mods exist for preinstall/install/upgrade
|
||||||
$ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled = Test-Mods $($app.Id)
|
$ModsPreInstall, $ModsOverride, $ModsUpgrade, $ModsInstall, $ModsInstalled = Test-Mods $($app.Id)
|
||||||
|
|
||||||
|
#Winget upgrade
|
||||||
|
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
|
||||||
|
|
||||||
#If PreInstall script exist
|
#If PreInstall script exist
|
||||||
if ($ModsPreInstall) {
|
if ($ModsPreInstall) {
|
||||||
|
@ -25,12 +28,15 @@ Function Update-App ($app) {
|
||||||
& "$ModsPreInstall"
|
& "$ModsPreInstall"
|
||||||
}
|
}
|
||||||
|
|
||||||
#Winget upgrade
|
|
||||||
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
|
|
||||||
|
|
||||||
#Run Winget Upgrade command
|
#Run Winget Upgrade command
|
||||||
|
if ($ModsOverride) {
|
||||||
|
Write-Log "-> Running (overriding default): Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride"
|
||||||
|
& $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append
|
||||||
|
}
|
||||||
|
else {
|
||||||
Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
|
Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
|
||||||
& $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
|
& $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
|
||||||
|
}
|
||||||
|
|
||||||
if ($ModsUpgrade) {
|
if ($ModsUpgrade) {
|
||||||
Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow"
|
Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow"
|
||||||
|
@ -54,8 +60,15 @@ Function Update-App ($app) {
|
||||||
|
|
||||||
#If app failed to upgrade, run Install command
|
#If app failed to upgrade, run Install command
|
||||||
Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow"
|
Write-Log "-> An upgrade for $($app.Name) failed, now trying an install instead..." "Yellow"
|
||||||
|
|
||||||
|
if ($ModsOverride) {
|
||||||
|
Write-Log "-> Running (overriding default): Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride"
|
||||||
|
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements --override $ModsOverride | Tee-Object -file $LogFile -Append
|
||||||
|
}
|
||||||
|
else {
|
||||||
Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
|
Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
|
||||||
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
|
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
|
||||||
|
}
|
||||||
|
|
||||||
if ($ModsInstall) {
|
if ($ModsInstall) {
|
||||||
Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow"
|
Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow"
|
||||||
|
|
Loading…
Reference in New Issue