Add capabilities to back up apps

This commit is contained in:
Manuel Thalmann 2024-08-28 00:37:04 +02:00
parent 5dcf809caf
commit f5c2d678ae
2 changed files with 19 additions and 4 deletions

View file

@ -200,6 +200,7 @@ $null = New-Module {
[scriptblock] $Backup = $null, [scriptblock] $Backup = $null,
[scriptblock] $Installer = $null, [scriptblock] $Installer = $null,
[scriptblock] $Configurator = $null, [scriptblock] $Configurator = $null,
[scriptblock] $UserBackup = $null,
[scriptblock] $UserConfigurator = $null, [scriptblock] $UserConfigurator = $null,
[Nullable[InstallerAction]] $Action, [Nullable[InstallerAction]] $Action,
[hashtable] $Arguments [hashtable] $Arguments
@ -262,14 +263,26 @@ $null = New-Module {
& $Configurator @argumentList; & $Configurator @argumentList;
} }
} }
([InstallerAction]::ConfigureUser) { default {
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) { if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER)); $Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
} }
if ($UserConfigurator) { $user = $Arguments[$userArgument];
Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``";
& $UserConfigurator @argumentList; switch ($_) {
([InstallerAction]::BackupUser) {
if ($UserBackup) {
Write-Host "Backing up $Name for user ``$user``";
& $UserBackup @argumentList;
}
}
([InstallerAction]::ConfigureUser) {
if ($UserConfigurator) {
Write-Host "Configuring $Name for user ``$user``";
& $UserConfigurator @argumentList;
}
}
} }
} }
} }

View file

@ -1,5 +1,7 @@
enum InstallerAction { enum InstallerAction {
Backup
Install Install
Configure Configure
BackupUser
ConfigureUser ConfigureUser
} }