From e416032f2820b6824fe6b2c4b530c39d4041d56d Mon Sep 17 00:00:00 2001
From: Manuel Thalmann <m@nuth.ch>
Date: Sun, 2 Jul 2023 15:12:56 +0200
Subject: [PATCH] Add a script for installing osu!lazer

---
 scripts/Windows/Collections/Personal.ps1      |  1 +
 scripts/Windows/Software/osu!lazer/Manage.ps1 | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/scripts/Windows/Collections/Personal.ps1 b/scripts/Windows/Collections/Personal.ps1
index d06ec28b..9c70d280 100644
--- a/scripts/Windows/Collections/Personal.ps1
+++ b/scripts/Windows/Collections/Personal.ps1
@@ -35,4 +35,5 @@ function Restore-PersonalApps([Context] $context) {
     Restore-TmUnited $context;
     Restore-ManiaPlanet $context;
     Restore-Osu $context;
+    Restore-OsuLazer $context;
 }
diff --git a/scripts/Windows/Software/osu!lazer/Manage.ps1 b/scripts/Windows/Software/osu!lazer/Manage.ps1
index 00b93bda..c0ba4b08 100644
--- a/scripts/Windows/Software/osu!lazer/Manage.ps1
+++ b/scripts/Windows/Software/osu!lazer/Manage.ps1
@@ -8,4 +8,19 @@ $null = New-Module {
         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";
+        $tempDir = $context.GetTempDirectory();
+        Push-Location $tempDir;
+        Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $installerName;
+        Start-Process -Wait -FilePath $installerName;
+        Pop-Location;
+        Remove-Item -Recurse $tempDir;
+    }
 }
\ No newline at end of file