Add scripts for backing up osu!

This commit is contained in:
Manuel Thalmann 2024-08-28 12:47:07 +02:00
parent 5b550789da
commit 4e545ebcb9
2 changed files with 74 additions and 27 deletions

View file

@ -5,10 +5,41 @@ param(
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; . "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
Start-SoftwareInstaller @PSBoundParameters ` & {
-Installer { param($Parameters)
Install-ChocoPackage osu; . "$PSScriptRoot/../../Scripts/Restoration.ps1";
Remove-DesktopIcon "*osu*"; Export-ModuleMember -Function @();
};
# ToDo: Add restoration $getInstallPath = {
return "$((Get-KnownFolder -SpecialFolder ProgramFilesX86).Path)/osu!";
}
Start-SoftwareInstaller @Parameters `
-Installer {
Install-ChocoPackage osu;
Remove-DesktopIcon "*osu*";
} `
-Backup {
Add-BackupArtifacts -Source (& $getInstallPath) -Path "osu!" `
-Include @(
"Screenshots",
"Skins",
"Songs",
"osu!.cfg",
"scores.db"
);
} `
-Configurator {
Expand-BackupArtifacts -Path "osu!" -Target (& $getInstallPath);
} `
-UserBackup {
param([hashtable] $Arguments)
$name = $Arguments.Name;
Add-BackupArtifacts -Source "$(& $getInstallPath)/osu!.$name.cfg" -User $name -Path "osu!/osu!.cfg";
} `
-UserConfigurator {
param([hashtable] $Arguments)
$name = $Arguments.Name;
Expand-BackupArtifacts -User $name -Path "osu!/osu!.cfg" -Target "$(& $getInstallPath)/osu!.$name.cfg";
};
} $PSBoundParameters;

View file

@ -3,29 +3,45 @@ param(
[hashtable] $Arguments [hashtable] $Arguments
) )
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1"; & {
. "$PSScriptRoot/../../../Common/Scripts/System.ps1"; param($Parameters)
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
$path = "$env:AppData/osu";
Start-SoftwareInstaller @PSBoundParameters ` Start-SoftwareInstaller @Parameters `
-UserConfigurator { -UserBackup {
$file = "osu!lazer.exe"; param([hashtable] $Arguments)
$processName = "osu!"; Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "osu!lazer" `
$dir = New-TemporaryDirectory; -Include @(
"files",
"rulesets",
"screenshots",
"framework.ini",
"game.ini",
"input.json"
);
} `
-UserConfigurator {
$file = "osu!lazer.exe";
$processName = "osu!";
$dir = New-TemporaryDirectory;
Push-Location $dir; Push-Location $dir;
Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $file; Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $file;
Start-Process -FilePath $file; Start-Process -FilePath $file;
while (-not (Get-Process -ErrorAction SilentlyContinue $processName)) { while (-not (Get-Process -ErrorAction SilentlyContinue $processName)) {
Start-Sleep 1; Start-Sleep 1;
} }
Start-Sleep 10; Start-Sleep 10;
Get-Process $processName | Stop-Process -Force; Get-Process $processName | Stop-Process -Force;
Pop-Location; Pop-Location;
Remove-Item -Recurse $dir; Remove-Item -Recurse $dir;
Remove-DesktopIcon "*osu*"; Remove-DesktopIcon "*osu*";
}; Expand-BackupArtifacts -User $Arguments.Name -Path "osu!lazer" -Target $path;
};
# ToDo: Add restoration } $PSBoundParameters;