PortValhalla/scripts/Windows/Software/reWASD/Manage.ps1

28 lines
1,022 B
PowerShell

#!/bin/pwsh
. "$PSScriptRoot/../../Scripts/Context.ps1";
. "$PSScriptRoot/../../Scripts/BrowserAutomation.ps1";
. "$PSScriptRoot/../../Scripts/SoftwarePackage.ps1";
$null = New-Module {
$path = "$env:PUBLIC/Documents/reWASD";
$softwareName = "reWASD";
function Backup-reWASD([Context] $context) {
Write-Host "Backing up reWASD";
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-x@`"$PSScriptRoot/exclude.txt`""));
}
function Restore-reWASD([Context] $context) {
Write-Host "Restoring reWASD";
$tempDir = $context.GetTempDirectory();
Write-Information "Downloading reWASD";
$file = Start-AutomatedDownload $context "https://rewasd.com/" 'a[data-event-category="Download"]' $tempDir;
Write-Information "Installing reWASD";
Start-Process -Wait -FilePath $file.FullName -ArgumentList "/S";
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
}
}