Compare commits

..

189 commits

Author SHA1 Message Date
Manuel Thalmann 879c4bc5d4 Add code for cleaning up after installations 2024-09-03 22:15:15 +02:00
Manuel Thalmann 2025fa8afd Add functions for uninstalling packages 2024-09-03 22:14:21 +02:00
Manuel Thalmann c483d13e73 Improve assignments of groups 2024-09-03 20:32:01 +02:00
Manuel Thalmann cc657ca0d8 Remove unnecessary policy change 2024-09-03 16:31:12 +02:00
Manuel Thalmann 36332b92c5 Migrate winiso script to fish 2024-09-03 12:08:47 +02:00
Manuel Thalmann 11cc9b1c65 Ask for live scripts only once 2024-09-03 12:08:35 +02:00
Manuel Thalmann 07ce2f2de5 Install Ubuntu automatically 2024-09-03 12:08:14 +02:00
Manuel Thalmann e08e9559e1 Add a backup script for reWASD 2024-09-03 12:02:48 +02:00
Manuel Thalmann dde27d8fde Add a backup script for Visual Studio 2024-09-03 12:02:32 +02:00
Manuel Thalmann 74d6e80560 Allow backing up TrackMania Forever 2024-09-03 12:02:09 +02:00
Manuel Thalmann 14cdf638f5 Allow testing winget packages with specific scope 2024-09-03 01:16:42 +02:00
Manuel Thalmann abb07af518 Allow backing up RetroArch 2024-08-28 13:07:58 +02:00
Manuel Thalmann 4342645275 Add scripts for backing up PuTTY 2024-08-28 13:00:37 +02:00
Manuel Thalmann 54cbbaf548 Add scripts for backing up osu! 2024-08-28 12:47:07 +02:00
Manuel Thalmann fde93b0b9a Install osu!lazer per user 2024-08-28 12:37:20 +02:00
Manuel Thalmann 2d8e1e9572 Add backup support for ManiaPlanet 2024-08-28 05:18:52 +02:00
Manuel Thalmann 15d38ca5ed Add scripts for backing up and restoring LGHub 2024-08-28 05:05:55 +02:00
Manuel Thalmann f47d858806 Allow users to restore a backup 2024-08-28 04:40:32 +02:00
Manuel Thalmann f4cc0514dd Add scripts for backing up and restoring personal files 2024-08-28 04:40:00 +02:00
Manuel Thalmann eb0ca51bb5 Fix non-functioning profile script 2024-08-28 04:39:15 +02:00
Manuel Thalmann 000fb9237e Ensure 7z is installed for backups 2024-08-28 04:38:56 +02:00
Manuel Thalmann 0fecb0546c Streamline restoration of directories 2024-08-28 04:38:30 +02:00
Manuel Thalmann ab4d874aae Set a default path for backup artifacts 2024-08-28 00:38:20 +02:00
Manuel Thalmann 7b2eb20220 Add capabilities to back up apps 2024-08-28 00:37:04 +02:00
Manuel Thalmann 185b19f6fd Allow specifying a backup action 2024-08-28 00:29:33 +02:00
Manuel Thalmann 3c01f7802d Ignore unspecified backup archives 2024-08-28 00:22:38 +02:00
Manuel Thalmann 6096a088f3 Ignore inexistent backup artifacts 2024-08-28 00:21:06 +02:00
Manuel Thalmann 0b60d65696 Make the install script action agnostic 2024-08-28 00:03:28 +02:00
Manuel Thalmann d1de499daf Rename the Windows installer script 2024-08-27 23:35:56 +02:00
Manuel Thalmann 8fa4396b2a Rename outdated script 2024-08-27 23:08:41 +02:00
Manuel Thalmann ace3d59d39 Silence errors concerning empty aliae configurations 2024-08-27 22:35:31 +02:00
Manuel Thalmann 28b32263c0 Make Operations script cross platform 2024-08-27 22:27:44 +02:00
Manuel Thalmann 7c84dfdedd Handle OneShot tasks only on Windows 2024-08-27 21:32:49 +02:00
Manuel Thalmann 0e2a70903f Add a script for managing backups 2024-08-27 21:05:51 +02:00
Manuel Thalmann 044c20461c Add tools for managing aliae 2024-08-27 18:58:33 +02:00
Manuel Thalmann 4eb25a2d71 Fix non-functioning aliae installation 2024-08-27 18:55:12 +02:00
Manuel Thalmann 9ccf2806ec Create dedicated script for creating users 2024-08-27 17:04:17 +02:00
Manuel Thalmann e09d5b1613 Create dedicated script for installing software 2024-08-27 16:41:08 +02:00
Manuel Thalmann 909fd1a2e5 Prevent reading nix config multiple times 2024-08-27 14:35:04 +02:00
Manuel Thalmann 5741d30539 Ensure only one user is enabled at once 2024-08-27 14:11:31 +02:00
Manuel Thalmann 03d158a5ff Prevent unnecessary file creation 2024-08-27 14:06:56 +02:00
Manuel Thalmann 8ef5920789 Execute OneShot tasks in any operation 2024-08-27 14:05:16 +02:00
Manuel Thalmann 4f9957dad4 Use /mnt as mount directory 2024-08-27 04:30:12 +02:00
Manuel Thalmann c292a3c7fc Force the use of the managed distribution 2024-08-27 04:26:25 +02:00
Manuel Thalmann 6022adac79 Initialize operation for all users 2024-08-27 04:24:29 +02:00
Manuel Thalmann 9a37921063 Handle initialization in operation code 2024-08-27 04:15:37 +02:00
Manuel Thalmann e0b5abe72b Execute script non-interactive during OneShot tasks 2024-08-27 03:50:08 +02:00
Manuel Thalmann 0f67360232 Exit script after running OneShot task 2024-08-27 03:45:44 +02:00
Manuel Thalmann fd53dd903e Modify user after first login 2024-08-27 03:27:54 +02:00
Manuel Thalmann fb633298ba Rearm Windows Activation before creating MSAcc 2024-08-27 03:25:19 +02:00
Manuel Thalmann 2afaff1999 Register MSAcc logon script early 2024-08-27 03:24:37 +02:00
Manuel Thalmann 94f5657ea7 Allow rebooting without registering setup 2024-08-27 03:11:35 +02:00
Manuel Thalmann beb97a95f5 Fix non-functioning NoProfile argument 2024-08-27 02:09:04 +02:00
Manuel Thalmann f9a68c631c Prevent unnecessary installation actions 2024-08-27 01:57:46 +02:00
Manuel Thalmann 3a0f841160 Only install PowerShell module if necessary 2024-08-27 01:25:32 +02:00
Manuel Thalmann 6c615c4707 Streamline PowerShell installation 2024-08-27 00:45:46 +02:00
Manuel Thalmann 8b0048c7ee Add further functionality to the WSL script 2024-08-27 00:38:46 +02:00
Manuel Thalmann 273f3c9965 Create a separate script for WSL interaction 2024-08-26 23:33:46 +02:00
Manuel Thalmann 4f8c3b1c4d Fix recursive configuration 2024-08-25 03:58:28 +02:00
Manuel Thalmann 496620d367 Fix malformed module 2024-08-24 18:35:43 +02:00
Manuel Thalmann 1ac885964e Keep Windows fixes separate 2024-08-24 16:56:29 +02:00
Manuel Thalmann 493944f358 Remove WSL after operation 2024-08-24 16:52:41 +02:00
Manuel Thalmann 5daeb40d88 Make distribution name unique 2024-08-24 16:41:05 +02:00
Manuel Thalmann 2728c45ac5 Streamline WSL distribution name 2024-08-24 16:27:34 +02:00
Manuel Thalmann fa5b462312 Remove unused resources after user setup 2024-08-24 16:15:10 +02:00
Manuel Thalmann cfbe29eb0e Print update logs properly 2024-08-24 14:47:51 +02:00
Manuel Thalmann 64e6e62c29 Allow overriding Windows settings 2024-08-24 14:20:22 +02:00
Manuel Thalmann ff925b57d7 Update incorrect path 2024-08-24 14:11:38 +02:00
Manuel Thalmann dd11967f95 Simplify osu!lazer installation 2024-08-24 14:10:02 +02:00
Manuel Thalmann a4577812b3 Determine name of setup user properly 2024-08-24 14:01:05 +02:00
Manuel Thalmann 1da7ad2a44 Make OMP configuration platform independent 2024-08-24 13:27:48 +02:00
Manuel Thalmann a9f2abf033 Fix incorrect character in OMP theme 2024-08-24 13:27:35 +02:00
Manuel Thalmann 758502ae08 Remove unnecessary code 2024-08-24 04:25:07 +02:00
Manuel Thalmann e064c55087 Remove unnecessary loop 2024-08-24 04:24:55 +02:00
Manuel Thalmann 196e530627 Add missing module 2024-08-24 04:24:37 +02:00
Manuel Thalmann e89a34b304 Add nextcloud to the module list 2024-08-24 04:18:57 +02:00
Manuel Thalmann 576e52d604 Add a function for creating shortcuts 2024-08-24 04:18:33 +02:00
Manuel Thalmann 4900b6b081 Configure nextcloud syncs 2024-08-24 04:07:47 +02:00
Manuel Thalmann 21907e77f6 Allow configuring nextcloud syncs 2024-08-24 04:07:35 +02:00
Manuel Thalmann e63d263247 Create separate option holding win users 2024-08-24 03:25:28 +02:00
Manuel Thalmann d10c040e4e Rename Nextcloud installer 2024-08-24 01:50:07 +02:00
Manuel Thalmann 147f67e11c Add file system driver for dual boot 2024-08-24 01:41:09 +02:00
Manuel Thalmann a4819bf1c6 Prevent unnecessary config evaluation 2024-08-24 01:31:39 +02:00
Manuel Thalmann b495406999 Fix non-functioning installer 2024-08-24 01:27:26 +02:00
Manuel Thalmann 3dd2c7de8f Install vscode extensions by default 2024-08-24 01:16:56 +02:00
Manuel Thalmann bedde68d66 Load theme file from WSL properly 2024-08-24 00:59:59 +02:00
Manuel Thalmann 3b0baae206 Update aliae configuration script 2024-08-24 00:42:57 +02:00
Manuel Thalmann 60e47dc297 Strip duplicate variables and aliases 2024-08-24 00:08:58 +02:00
Manuel Thalmann ab4b6dc63c Install posh theme automatically 2024-08-23 23:53:48 +02:00
Manuel Thalmann 0ad9e94a1f Export missing function 2024-08-23 23:50:13 +02:00
Manuel Thalmann 896c6fb2fb Install aliae by default 2024-08-23 23:46:23 +02:00
Manuel Thalmann 87fc264f6b Add scripts for changing aliae config 2024-08-23 23:44:51 +02:00
Manuel Thalmann 1d5b147b21 Fix compatibility with mixed new line characters 2024-08-23 23:44:23 +02:00
Manuel Thalmann 0bdf6e33ed Add a script for installing aliae 2024-08-23 22:38:28 +02:00
Manuel Thalmann e24dbe89f9 Add desired posh theme 2024-08-23 19:43:06 +02:00
Manuel Thalmann 4c6f9d8dbf Make option names more clear 2024-08-23 19:42:27 +02:00
Manuel Thalmann 689e55b6d7 Allow configuring oh-my-posh 2024-08-23 19:39:18 +02:00
Manuel Thalmann e40d22676c Fetch config from proper section 2024-08-23 19:24:49 +02:00
Manuel Thalmann 8ccef0e870 Adjust configuration accordingly 2024-08-23 19:14:09 +02:00
Manuel Thalmann 361827218b Refactor option descriptions 2024-08-23 19:02:06 +02:00
Manuel Thalmann fedd304543 Clean up the Windows configuration 2024-08-23 18:59:49 +02:00
Manuel Thalmann fd1a6f2973 Clean up the users.nix file 2024-08-23 18:51:54 +02:00
Manuel Thalmann 4c9568f974 Create dedicated rclone module 2024-08-23 18:48:30 +02:00
Manuel Thalmann cf04b3d320 Move git module to separate directory 2024-08-23 18:42:16 +02:00
Manuel Thalmann 865fc519f0 Move git options to separate module 2024-08-23 18:40:24 +02:00
Manuel Thalmann 1445192c55 Fix inheritance of user config 2024-08-23 18:28:20 +02:00
Manuel Thalmann 4d7cc6f567 Allow OS specific settings 2024-08-23 18:11:48 +02:00
Manuel Thalmann 727a80b24c Update archiso 2024-08-23 14:19:56 +02:00
Manuel Thalmann c81f63b416 Set user info during git setup 2024-08-23 02:01:16 +02:00
Manuel Thalmann 3aa6967734 Make all config scripts platform independent 2024-08-23 01:57:53 +02:00
Manuel Thalmann fc2bf2276c Allow leaving aliases unspecified 2024-08-23 01:52:25 +02:00
Manuel Thalmann 720ec85bf0 Make scripts platform independent 2024-08-23 01:52:04 +02:00
Manuel Thalmann 47f6d45da6 Add scripts for configuring git 2024-08-23 01:43:26 +02:00
Manuel Thalmann 7d6c3d6a60 Configure software implicitly 2024-08-23 01:41:32 +02:00
Manuel Thalmann 6cade00931 Skip profile creation for PinnedItem 2024-08-22 23:55:41 +02:00
Manuel Thalmann b2f5dd6fc1 Allow skipping powershell module registration 2024-08-22 23:55:00 +02:00
Manuel Thalmann 3c4f794d0a Add profiles to the flake 2024-08-22 23:37:53 +02:00
Manuel Thalmann 9b5c9d1126 Remove user profile of OneShot user 2024-08-22 23:12:11 +02:00
Manuel Thalmann b303844e4a Add missing OneShotTask declaration 2024-08-22 20:41:30 +02:00
Manuel Thalmann 2afc7a0c69 Fix infinite loop 2024-08-22 20:41:17 +02:00
Manuel Thalmann 834aaa2d5b Fix incorrect variable name 2024-08-22 20:34:16 +02:00
Manuel Thalmann fe48bbe881 Fix handling empty error messages 2024-08-22 20:12:18 +02:00
Manuel Thalmann 110d55a302 Add choco to the profile of the setup user 2024-08-22 13:46:55 +02:00
Manuel Thalmann f063536b7d Fix incorrect typings 2024-08-22 11:11:12 +02:00
Manuel Thalmann 06c9f61030 Fix permission issues when enabling Win hack 2024-08-22 11:11:00 +02:00
Manuel Thalmann 317509167d Register setup script as admin 2024-08-22 11:10:39 +02:00
Manuel Thalmann 51655b2291 Execute the entire installer using live scripts 2024-08-21 23:21:32 +02:00
Manuel Thalmann 539780ba3c Streamline the creation of users 2024-08-21 18:34:18 +02:00
Manuel Thalmann 899eddf507 Replace osk with cmd during debugging 2024-08-21 18:33:41 +02:00
Manuel Thalmann d82c3ae1e9 Prevent pauses in OneShot tasks 2024-08-21 18:28:50 +02:00
Manuel Thalmann b441e9231a Print commands in debug mode 2024-08-21 18:28:08 +02:00
Manuel Thalmann 83165588f9 Run OneShot tasks with dedicated user 2024-08-21 18:27:47 +02:00
Manuel Thalmann d00d571194 Add function for generating startup command 2024-08-21 18:26:58 +02:00
Manuel Thalmann 977fe76248 Allow registering startup script for the default user 2024-08-21 18:20:11 +02:00
Manuel Thalmann 187f0d465a Prevent unnecessary errors during WSL execution 2024-08-21 14:08:26 +02:00
Manuel Thalmann 4c587f87b1 Register WSL before running OneShot tasks 2024-08-21 03:37:44 +02:00
Manuel Thalmann d871b48864 Overwrite broken module 2024-08-21 03:20:37 +02:00
Manuel Thalmann 7feae37eb9 Prevent initialization of nested operations 2024-08-21 03:18:31 +02:00
Manuel Thalmann d2dbe59071 Improve log messages of OneShot tasks 2024-08-21 02:02:30 +02:00
Manuel Thalmann d029018563 Retry Linux path conversion for errors 2024-08-20 00:20:33 +02:00
Manuel Thalmann 72d46420f4 Fix typo 2024-08-20 00:20:07 +02:00
Manuel Thalmann f5359efad7 Fix broken signature of Restart-Intermediate 2024-08-19 12:07:26 +02:00
Manuel Thalmann 8e3abf6087 Report unexpected path conversions 2024-08-19 02:50:41 +02:00
Manuel Thalmann 4f89c167cb Load missing path 2024-08-19 02:50:19 +02:00
Manuel Thalmann 4d56597f86 Ensure error file can be read from 2024-08-19 02:24:45 +02:00
Manuel Thalmann 4dccba5632 Streamline OneShot task handler 2024-08-19 02:24:30 +02:00
Manuel Thalmann fae955e126 Simplify script registration 2024-08-19 02:24:13 +02:00
Manuel Thalmann 59e61b6ea8 Fix broken regedit paths 2024-08-19 01:38:25 +02:00
Manuel Thalmann 8eecac02bf Allow registering reboots for users 2024-08-19 01:37:14 +02:00
Manuel Thalmann 345b3fb1df Prevent users from being excluded 2024-08-19 01:10:29 +02:00
Manuel Thalmann d8596f0a58 Force copying of Linux users to Windows 2024-08-19 00:54:13 +02:00
Manuel Thalmann df57160ef5 Improve log messages of updates 2024-08-18 12:20:21 +02:00
Manuel Thalmann 2f59726682 Remove unnecessary command 2024-08-18 10:24:15 +02:00
Manuel Thalmann 7dbf75e591 Fix time for QEMU VMs 2024-08-18 09:35:16 +02:00
Manuel Thalmann 0b2824cf9e Remove unnecessary desktop icons 2024-08-18 09:25:23 +02:00
Manuel Thalmann bd8224b3f4 Add a timeout for the reWASD downloader 2024-08-18 09:05:04 +02:00
Manuel Thalmann 5c0e462cc7 Allow setting a timeout for clicking download buttons 2024-08-18 09:04:42 +02:00
Manuel Thalmann 7015a69d16 Emit errors concerning WSL commands 2024-08-17 13:51:10 +02:00
Manuel Thalmann 0a23112e2c Emit errors using Write-Error 2024-08-17 13:49:21 +02:00
Manuel Thalmann d684d1ec42 Convert Argument to string explicitly 2024-08-16 23:03:19 +02:00
Manuel Thalmann 40b3472700 Ignore unfinished browser downloads 2024-08-16 17:57:22 +02:00
Manuel Thalmann 24ff14ca99 Install powershell modules for all users 2024-08-16 16:43:30 +02:00
Manuel Thalmann 60074b9ad0 Fix typos 2024-08-16 16:10:09 +02:00
Manuel Thalmann 73c0f0913e Install AutoHotkey as preparation 2024-08-16 15:22:09 +02:00
Manuel Thalmann ff8b949b35 Allow running live scripts in debug mode 2024-08-16 15:21:41 +02:00
Manuel Thalmann 6a73d54056 Generate env variables using shorthand scripts 2024-08-16 15:16:56 +02:00
Manuel Thalmann 0d8ea792fc Allow running installation in debug mode 2024-08-16 15:16:28 +02:00
Manuel Thalmann f3e70d2908 Redirect winiso exit code properly 2024-08-16 15:13:53 +02:00
Manuel Thalmann a3a3b5e9b4 Allow specifying winiso build type 2024-08-16 15:13:33 +02:00
Manuel Thalmann cb0af07f0c Refactor winget check for rare issue 2024-08-16 15:04:37 +02:00
Manuel Thalmann 36dd010efb Disable Windows Update reboot only as admin 2024-08-16 14:35:35 +02:00
Manuel Thalmann 1e198093cc Add a function for queueing startup commands 2024-08-15 18:34:48 +02:00
Manuel Thalmann d6a85c8cda Hide output of DISM commands 2024-08-15 13:57:15 +02:00
Manuel Thalmann fac547f4be Ensure website is loaded before download 2024-08-15 02:42:00 +02:00
Manuel Thalmann 1ff78c6769 Prevent Jellyfin from rebooting 2024-08-15 02:22:07 +02:00
Manuel Thalmann 18a0b3d577 Improve handling of slow websites 2024-08-14 18:47:29 +02:00
Manuel Thalmann 318a880b5f Fix potential CRC errors 2024-08-14 18:46:42 +02:00
Manuel Thalmann fcfc58ff7e Ensure auto reboot is disabled properly 2024-08-12 21:32:53 +02:00
Manuel Thalmann 580cbd2f2a Disable auto reboot by default 2024-08-12 01:27:50 +02:00
Manuel Thalmann a9090b9b9c Add methods for managing auto restart feature 2024-08-12 01:23:42 +02:00
Manuel Thalmann 908a847bbe Install Wave Link first 2024-08-11 18:27:16 +02:00
Manuel Thalmann df0a2847c4 Throw an error when failing to load config 2024-08-11 18:27:06 +02:00
Manuel Thalmann dfc70a2b0c Fix incorrect script path 2024-08-10 20:37:10 +02:00
Manuel Thalmann 6db6fd02ee Allow leaving install action unspecified 2024-08-10 19:27:56 +02:00
Manuel Thalmann b504ee0979 Retrieve registry value properly 2024-08-10 19:26:53 +02:00
Manuel Thalmann 234a0f17d5 Add scripts for installing git 2024-08-10 15:28:10 +02:00
Manuel Thalmann 77ed70468e Remove unnecessary code 2024-08-10 15:24:15 +02:00
Manuel Thalmann e0771278a5 Add a function for removing the RunOnce key 2024-08-10 15:24:04 +02:00
Manuel Thalmann 2fd325d580 Set user groups properly 2024-08-10 15:23:38 +02:00
12 changed files with 200 additions and 76 deletions

View file

@ -78,9 +78,7 @@
description = "Blablabla";
default = (lib.attrsets.concatMapAttrs (
name: options: {
${capitalize name} = options // {
groups = [];
};
${capitalize name} = options;
}) config.users);
};
};

View file

@ -40,17 +40,17 @@
manuel = {
displayName = "Manuel Thalmann";
mailAddress = "m@nuth.ch";
groups = [
"wheel"
"nix-users"
];
};
};
linux.users.manuel = {
defaultShell = "fish";
groups = [
"wheel"
"nix-users"
];
rclone = {
configurations = {
nextcloud = {

View file

@ -5,6 +5,7 @@ using namespace System.Security.Principal;
enum WindowsInstallerStage {
Initialize
Run
Cleanup
Completed
}

View file

@ -27,6 +27,33 @@ $null = New-Module {
Set-SetupOption $taskOption ([string]$Task);
};
<#
.SYNOPSIS
Gets the PowerShell modules required for operating.
#>
function Get-RequiredModules {
$modules = @(
@("PSScriptAnalyzer")
) + (& {
if (-not $IsWindows) {
@()
} else {
@(
@("KnownFolders"),
@("PSWindowsUpdate"),
@("LocalAccounts", $true),
@("NuGet")
)
}
});
for ($i = 0; $i -lt $modules.Count; $i++) {
if ($modules[$i] -is [string]) {
$modules[$i] = @($modules[$i]);
}
}
}
function Start-Operation {
param(
[switch] $NonInteractive,
@ -57,10 +84,6 @@ $null = New-Module {
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
}
if (Test-Admin) {
Disable-WindowsUpdateAutoRestart;
}
New-Alias -Force "sudo" gsudo;
}
@ -219,22 +242,7 @@ $null = New-Module {
}
Invoke-Hook "Install-PSModules" -Fallback {
$modules = @(
@("PSScriptAnalyzer")
) + (& {
if (-not $IsWindows) {
@()
} else {
@(
@("KnownFolders"),
@("PSWindowsUpdate"),
@("LocalAccounts", $true),
@("NuGet")
)
}
});
foreach ($module in $modules) {
foreach ($module in (Get-RequiredModules)) {
$parameters = @{ };
if ($module -is [string]) {
@ -407,6 +415,13 @@ $null = New-Module {
function Clear-OperationResources {
if ($IsWindows) {
Uninstall-WslDistribution;
$null = Uninstall-Package Selenium.WebDriver -ErrorAction Continue;
Uninstall-ChocoPackage 7zip.portable gsudo selenium-gecko-driver yq;
Uninstall-WingetPackage AutoHotkey.AutoHotkey;
}
foreach ($module in (Get-RequiredModules)) {
Uninstall-Module -Force -Name $module[0];
}
}
};

View file

@ -9,6 +9,64 @@ $null = New-Module {
. "$PSScriptRoot/../Types/InstallerAction.ps1";
$userArgument = "name";
$chocoRunner = {
param(
[string] $Action = 'install',
[string[]] $ArgumentList,
[scriptblock] $Guard = { $true },
[Parameter(Position = 0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
[System.Collections.ArrayList] $Names = @();
$null = $Names.Add($Name);
$Names.AddRange($AdditionalNames);
if (-not ($Force.IsPresent)) {
for ($i = $Names.Count - 1; $i -ge 0; $i--) {
$name = $Names[$i];
if (-not (& $Guard $name)) {
$Names.RemoveAt($i);
}
}
}
if ($Names.Count -ge 1) {
choco $Action -y @ArgumentList @Names;
}
};
$wingetRunner = {
param(
[string] $Action = 'install',
[string[]] $ArgumentList,
[scriptblock] $Guard = { $true },
[Parameter(Position = 0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
[System.Collections.ArrayList] $Names = @();
$null = $Names.Add($Name);
$Names.AddRange($AdditionalNames);
foreach ($name in $Names) {
if ($Force.IsPresent -or (& $Guard $name $PSBoundParameters)) {
winget $Action `
--accept-source-agreements `
--source winget `
$ArgumentList `
--exact --id $name ;
} else {
Write-Host "Package ``$name`` is already installed"
}
}
};
<#
.SYNOPSIS
Installs the specified packages using chocolatey.
@ -26,24 +84,39 @@ $null = New-Module {
[string[]] $AdditionalNames = @()
)
[System.Collections.ArrayList] $Names = @();
$null = $Names.Add($Name);
$Names.AddRange($AdditionalNames);
if (-not ($Force.IsPresent)) {
for ($i = $Names.Count - 1; $i -ge 0; $i--) {
$name = $Names[$i];
if (Test-ChocoPackage $name) {
Write-Host "Package ``$name`` is already installed"
$Names.RemoveAt($i);
}
& $chocoRunner @PSBoundParameters -Guard {
param($Name)
if (Test-ChocoPackage $Name) {
Write-Host "Package ``$Name`` is already installed"
$false;
} else {
$true;
}
}
};
}
if ($Names.Count -ge 1) {
choco install -y @ArgumentList @Names;
}
<#
.SYNOPSIS
Uninstalls the specified packages using chocolatey.
#>
function Uninstall-ChocoPackage {
param(
[string[]] $ArgumentList,
[Parameter(Position=0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
& $chocoRunner @PSBoundParameters -Action 'uninstall' -Guard {
param($Name)
if (Test-ChocoPackage $Name) {
$true;
} else {
Write-Host "Package ``$Name`` is not installed";
$false;
}
};
}
<#
@ -63,21 +136,41 @@ $null = New-Module {
[string[]] $AdditionalNames = @()
)
[System.Collections.ArrayList] $Names = @();
$null = $Names.Add($Name);
$Names.AddRange($AdditionalNames);
& $wingetRunner @PSBoundParameters `
-ArgumentList @($PSBoundParameters.ArgumentList + @("--accept-package-agreements")) `
-Guard {
param($Name, $Parameters)
if (Test-WingetPackage @Parameters) {
Write-Host "Package ``$Name`` is already installed"
$false;
} else {
$true;
}
};
}
foreach ($name in $Names) {
if ($Force.IsPresent -or -not (Test-WingetPackage @PSBoundParameters)) {
winget install `
--accept-source-agreements --accept-package-agreements `
--source winget `
$ArgumentList `
--exact --id $name ;
<#
.SYNOPSIS
Uninstalls the specified packages using `winget`.
#>
function Uninstall-WingetPackage {
param(
[string[]] $ArgumentList,
[Parameter(Position=0)]
[string] $Name,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $AdditionalNames = @()
)
& $wingetRunner @PSBoundParameters -Action 'uninstall' -Guard {
param($Name, $Parameters)
if (Test-WingetPackage @Parameters) {
$true;
} else {
Write-Host "Package ``$name`` is already installed"
Write-Host "Package ``$Name`` is not installed"
$false;
}
}
};
}
<#

View file

@ -20,6 +20,7 @@ $null = New-Module {
. "$PSScriptRoot/../Types/WindowsInstallerAction.ps1";
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
. "$PSScriptRoot/../../Common/Scripts/Scripting.ps1";
. "$PSScriptRoot/../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../Common/Scripts/SoftwareManagement.ps1";
. "$PSScriptRoot/../../Common/Types/InstallerAction.ps1";
@ -119,6 +120,8 @@ $null = New-Module {
Write-Host "Entering install phase";
Deploy-SoftwareAction;
Set-SetupStage ([SetupStage]::CreateUser);
Restart-Intermediate;
return;
}
([SetupStage]::CreateUser) {
Install-ValhallaUsers;
@ -129,7 +132,36 @@ $null = New-Module {
}
}
Set-Stage ([WindowsInstallerStage]::Cleanup);
break;
}
([WindowsInstallerStage]::Cleanup) {
$taskName = "PortValhalla Cleaner";
$setupUser = Get-SetupUser;
Clear-OperationResources;
Remove-Item -Recurse -Force "C:\ProgramData\PortValhalla";
Get-SetupConfigKey | Remove-Item -Recurse -Force;
Disable-Autologin;
Disable-LocalUser $setupUser;
$script = {
param(
$TaskName,
$UserName
)
$user = Get-LocalUser $UserName;
[string] $sid = $user.SID;
Remove-LocalUser $user;
Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance;
Unregister-ScheduledTask -Confirm:$false $TaskName;
};
$trigger = New-ScheduledTaskTrigger -AtStartup;
$task = New-ScheduledTaskAction -Execute "pwsh" -Argument "-Command & { $script } $(ConvertTo-Injection $taskName) $(ConvertTo-Injection $setupUser)";
$null = Register-ScheduledTask -Force $taskName -Action $task -Trigger $trigger -RunLevel Highest -User "SYSTEM";
Set-Stage ([WindowsInstallerStage]::Completed);
Restart-Intermediate -NoRegister;
break;
}
}

View file

@ -56,19 +56,6 @@ $null = New-Module {
Set-BootMessage;
}
<#
.SYNOPSIS
Disables automatic reboots by Windows Update.
#>
function Disable-WindowsUpdateAutoRestart {
$path = "$wuPolicyPath\AU";
$null = New-Item -Force $path -ErrorAction SilentlyContinue;
Set-ItemProperty $path `
-Name NoAutoRebootWithLoggedOnUsers `
-Value 1;
}
<#
.SYNOPSIS
Resets the automatic reboot state.

View file

@ -81,7 +81,7 @@ $null = New-Module {
Deploy-SoftwareAction -Action ConfigureUser;
Remove-LocalGroupMember -Member "$name" @adminGroup -ErrorAction SilentlyContinue;
foreach ($group in Get-UserConfig "groups") {
foreach ($group in Get-UserConfig -UserName "$name" "groups") {
Add-LocalGroupMember -Member "$name" -Name "$group";
}

View file

@ -40,7 +40,7 @@ param(
)
Expand-BackupArtifacts -User $Arguments.Name -Path "ManiaPlanet" -Target $path;
} | Out-Host;
};
} $PSBoundParameters;
# ToDo: Add restoration

View file

@ -32,7 +32,5 @@ $null = New-Module {
-Configurator {
Add-StartMenuIcon "RetroArch" "C:\tools\RetroArch-Win64\retroarch.exe";
Expand-BackupArtifacts -Path "RetroArch" -Target $path;
} | Out-Host;
};
} $PSBoundParameters;
# ToDo: Add restoration

View file

@ -40,5 +40,5 @@ param(
param([hashtable] $Arguments)
$name = $Arguments.Name;
Expand-BackupArtifacts -User $name -Path "TmNationsForever" -Target $path;
} | Out-Host;
};
} $PSBoundParameters;

View file

@ -49,5 +49,5 @@ param(
-UserConfigurator {
param([hashtable] $Arguments)
Expand-BackupArtifacts -User $Arguments.Name -Path "TmUnitedForever" -Target $path;
} | Out-Host;
};
} $PSBoundParameters;