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

35 lines
1.3 KiB
PowerShell

#!/bin/pwsh
. "$PSScriptRoot/../../Scripts/Context.ps1";
$null = New-Module {
$path = "$((Get-KnownFolder -SpecialFolder ProgramFilesX86).Path)/osu!";
$softwareName = "osu!";
$genericConfigName = "osu!.User.cfg";
function Backup-Osu([Context] $context) {
Write-Host "Backing up osu!";
$archive = $context.SoftwareArchive($softwareName);
Write-Information "Backing up important files";
$context.Backup($path, $archive, @("-i@`"$PSScriptRoot/include.txt`""));
Write-Information "Renaming user configuration to $genericConfigName";
& 7z rn "$archive" "osu!.$env:USERNAME.cfg" $genericConfigName;
}
function Restore-Osu([Context] $context) {
Write-Host "Restoring osu!";
Write-Information "Installing osu!";
choco install -y osu;
Remove-Item "$env:PUBLIC\Desktop\*osu*";
Write-Information "Restoring files";
$context.Restore($context.SoftwareArchive($softwareName), $path);
$configName = "osu!.$env:USERNAME.cfg";
Write-Information "Renaming user configuration to $configName";
Push-Location $path;
if ((Test-Path $genericConfigName)) {
Rename-Item $genericConfigName $configName;
}
Pop-Location;
}
}