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

30 lines
1.1 KiB
PowerShell
Raw Normal View History

2023-06-07 18:02:31 +00:00
. "$PSScriptRoot/../../Scripts/Context.ps1";
2023-06-08 00:28:33 +00:00
$null = New-Module {
2023-07-02 14:07:47 +00:00
$path = "$((Get-KnownFolder -SpecialFolder ProgramFilesX86).Path)/osu!";
2023-06-08 00:28:33 +00:00
$softwareName = "osu!";
$genericConfigName = "osu!.User.cfg";
2023-06-30 10:19:54 +00:00
function Backup-Osu([Context] $context) {
Write-Host "Backing up osu!";
2023-06-08 00:28:33 +00:00
$archive = $context.SoftwareArchive($softwareName);
Write-Information "Backing up important files";
2023-06-08 00:28:33 +00:00
$context.Backup($path, $archive, @("-i@`"$PSScriptRoot/include.txt`""));
Write-Information "Renaming user configuration to $genericConfigName";
2023-06-08 00:28:33 +00:00
& 7z rn "$archive" "osu!.$env:USERNAME.cfg" $genericConfigName;
}
2023-07-02 12:42:17 +00:00
function Restore-Osu([Context] $context) {
Write-Host "Restoring osu!";
Write-Information "Installing osu!";
choco install -y 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;
Rename-Item $genericConfigName $configName;
2023-07-02 16:45:38 +00:00
Pop-Location;
2023-07-02 12:42:17 +00:00
}
2023-06-07 18:02:31 +00:00
}