PortValhalla/scripts/Windows/Software/osu!lazer/Manage.ps1

38 lines
1.3 KiB
PowerShell

#!/bin/pwsh
. "$PSScriptRoot/../../Scripts/Context.ps1";
$null = New-Module {
$path = "$env:APPDATA/osu";
$softwareName = "osu!lazer";
function Backup-OsuLazer([Context] $context) {
Write-Host "Backing up osu!lazer";
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"", "-i!*.realm", "-i!*.db"));
}
function Restore-OsuLazer([Context] $context) {
Write-Host "Restoring osu!lazer";
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
Write-Information "Installing osu!lazer";
$installerName = "osu!lazer.exe";
$processName = "osu!";
$tempDir = $context.GetTempDirectory();
Push-Location $tempDir;
Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $installerName;
Start-Process -FilePath $installerName;
while (-not (Get-Process -ErrorAction "SilentlyContinue" $processName)) {
Start-Sleep 1;
}
Start-Sleep 10;
Get-Process $processName | Stop-Process -Force;
$context.RemoveDesktopIcon("*osu*");
Pop-Location;
Remove-Item -Recurse $tempDir;
}
}