From 550cb86241bf3d9883d19de55093ed177fcbebf7 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Fri, 30 Jun 2023 13:17:00 +0200 Subject: [PATCH] Add step for installing Nextcloud --- scripts/Windows/Collections/Personal.ps1 | 3 +++ scripts/Windows/Scripts/Context.ps1 | 4 ++++ scripts/Windows/Software/Nextcloud/Manage.ps1 | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 scripts/Windows/Software/Nextcloud/Manage.ps1 diff --git a/scripts/Windows/Collections/Personal.ps1 b/scripts/Windows/Collections/Personal.ps1 index 0dacdbaa..bb9f4030 100644 --- a/scripts/Windows/Collections/Personal.ps1 +++ b/scripts/Windows/Collections/Personal.ps1 @@ -2,6 +2,7 @@ . "$PSScriptRoot/../Software/git/Manage.ps1"; . "$PSScriptRoot/../Software/LGHub/Manage.ps1"; . "$PSScriptRoot/../Software/ManiaPlanet/Manage.ps1"; +. "$PSScriptRoot/../Software/Nextcloud/Manage.ps1"; . "$PSScriptRoot/../Software/osu!/Manage.ps1"; . "$PSScriptRoot/../Software/osu!lazer/Manage.ps1"; . "$PSScriptRoot/../Software/PuTTY/Manage.ps1"; @@ -26,5 +27,7 @@ function Backup-PersonalApps([Context] $context) { } function Restore-PersonalApps([Context] $context) { + choco feature enable -n useEnhancedExitCodes; + Restore-Nextcloud $context; Restore-Git $context; } diff --git a/scripts/Windows/Scripts/Context.ps1 b/scripts/Windows/Scripts/Context.ps1 index ec3a414e..3d51e6e9 100644 --- a/scripts/Windows/Scripts/Context.ps1 +++ b/scripts/Windows/Scripts/Context.ps1 @@ -205,6 +205,10 @@ class Context { }); } + [string] GetNextcloudConfigFile() { + return "$env:APPDATA/Nextcloud/nextcloud.cfg"; + } + [void] Reboot() { Write-Host "Restarting Computer..."; $this.RegisterReboot(); diff --git a/scripts/Windows/Software/Nextcloud/Manage.ps1 b/scripts/Windows/Software/Nextcloud/Manage.ps1 new file mode 100644 index 00000000..b33fa501 --- /dev/null +++ b/scripts/Windows/Software/Nextcloud/Manage.ps1 @@ -0,0 +1,18 @@ +. "$PSScriptRoot/../../Scripts/Context.ps1"; + +$null = New-Module { + function Restore-Nextcloud([Context] $context) { + if (-not (choco list --exact nextcloud-client)) { + choco install nextcloud-client -y --params="'/KeepUpdateCheck'"; + } + + while (-not (Test-Path $context.GetNextcloudConfigFile())) { + Write-Host "Nextcloud has been installed!"; + Write-Host "Please log in in the Nextcloud app to continue."; + + if (-not (Test-Path $context.GetNextcloudConfigFile())) { + Write-Error "The login seems to have failed. Please try again."; + } + } + } +}