Compare commits
9 commits
984fd09352
...
e6c8bbe9c6
Author | SHA1 | Date | |
---|---|---|---|
Manuel Thalmann | e6c8bbe9c6 | ||
Manuel Thalmann | 687c36d50c | ||
Manuel Thalmann | 559fc4be96 | ||
Manuel Thalmann | e37a7a1e08 | ||
Manuel Thalmann | 14c3a3ed85 | ||
Manuel Thalmann | c585ef0029 | ||
Manuel Thalmann | 727b8c1d4c | ||
Manuel Thalmann | 940520d83d | ||
Manuel Thalmann | bfb2ecf106 |
|
@ -3,8 +3,6 @@ using namespace System.Security.AccessControl;
|
|||
using namespace System.Security.Principal;
|
||||
|
||||
enum SetupStage {
|
||||
Idle
|
||||
OneShot
|
||||
Configure
|
||||
Install
|
||||
CreateUser
|
||||
|
@ -389,7 +387,7 @@ $null = New-Module {
|
|||
Gets a value indicating whether the setup has finished.
|
||||
#>
|
||||
function Get-IsFinished {
|
||||
return [bool] (((Get-Stage) -eq ([SetupStage]::Idle)) -or (Get-SetupOption $finishedOption));
|
||||
return [bool](Get-SetupOption $finishedOption);
|
||||
}
|
||||
|
||||
<#
|
||||
|
|
|
@ -27,7 +27,7 @@ $null = New-Module {
|
|||
|
||||
function Start-Operation {
|
||||
param(
|
||||
[switch] $NonInteractive = ((Get-Stage) -eq ([SetupStage]::OneShot)),
|
||||
[switch] $NonInteractive = ($null -ne (Get-OneShotTask)),
|
||||
[switch] $NoImplicitCleanup,
|
||||
[scriptblock] $Action
|
||||
)
|
||||
|
@ -140,12 +140,8 @@ $null = New-Module {
|
|||
$sys32 = "$env:WINDIR/System32";
|
||||
$osk = (Get-Item "$sys32/osk.exe").FullName;
|
||||
$cmd = (Get-Item "$sys32/cmd.exe").FullName;
|
||||
$tmpOsk = New-TemporaryFile;
|
||||
$tmpCmd = New-TemporaryFile;
|
||||
gsudo -d copy "$osk" "$tmpOsk";
|
||||
gsudo -d copy "$cmd" "$tmpCmd";
|
||||
|
||||
if ((Get-FileHash $tmpOsk).Hash -ne (Get-FileHash $tmpCmd).Hash) {
|
||||
if ((Get-FileHash $osk).Hash -ne (Get-FileHash $cmd).Hash) {
|
||||
Set-MpPreference -ExclusionPath $osk;
|
||||
gsudo -d --ti move $osk "${osk}_";
|
||||
gsudo -d -s copy $cmd $osk;
|
||||
|
@ -165,6 +161,12 @@ $null = New-Module {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (-not (Test-Command "yq")) {
|
||||
Install-ChocoPackage "yq";
|
||||
refreshenv;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (-not (Test-Wsl)) {
|
||||
Install-Wsl;
|
||||
Restart-Intermediate;
|
||||
|
@ -227,7 +229,12 @@ $null = New-Module {
|
|||
}
|
||||
}
|
||||
|
||||
& $Action;
|
||||
if ((Get-OneShotTask)) {
|
||||
Start-OneShot;
|
||||
} else {
|
||||
& $Action;
|
||||
}
|
||||
|
||||
& $cleanup;
|
||||
}
|
||||
|
||||
|
@ -236,7 +243,13 @@ $null = New-Module {
|
|||
Gets the current OneShot task.
|
||||
#>
|
||||
function Get-OneShotTask {
|
||||
[OneShotTask](Get-SetupOption $taskOption);
|
||||
$task = Get-SetupOption $taskOption;
|
||||
|
||||
if ($task) {
|
||||
return [OneShotTask]$task;
|
||||
} else {
|
||||
return $null;
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
|
@ -289,8 +302,6 @@ $null = New-Module {
|
|||
[OneShotTask] $Task
|
||||
)
|
||||
|
||||
$currentStage = Get-Stage;
|
||||
Set-Stage ([SetupStage]::OneShot);
|
||||
& $taskSetter $Task;
|
||||
|
||||
& {
|
||||
|
@ -319,8 +330,6 @@ $null = New-Module {
|
|||
}
|
||||
};
|
||||
|
||||
Set-Stage $currentStage;
|
||||
|
||||
if (Test-Path $errorPath) {
|
||||
$errorMessage = Get-Content $errorPath;
|
||||
Remove-Item $errorPath;
|
||||
|
@ -338,23 +347,29 @@ $null = New-Module {
|
|||
Executes the specified action and notifies the OneShot task executor.
|
||||
#>
|
||||
function Start-OneShot {
|
||||
param(
|
||||
[scriptblock] $Action
|
||||
)
|
||||
|
||||
try {
|
||||
Start-Operation -NonInteractive @PSBoundParameters;
|
||||
Write-Host "Running OneShot task ``$(Get-OneShotTask)``";
|
||||
|
||||
Start-Operation {
|
||||
switch (Get-OneShotTask) {
|
||||
([OneShotTask]::InitializeMSAccount) {
|
||||
Initialize-UserCreation;
|
||||
}
|
||||
([OneShotTask]::DisableUAC) {
|
||||
Disable-UAC;
|
||||
Register-Setup;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
catch {
|
||||
Set-Content -Path $errorPath -Value $Error;
|
||||
Set-UserPermissions $errorPath;
|
||||
}
|
||||
finally {
|
||||
Set-Stage ([SetupStage]::Idle);
|
||||
& $taskSetter $null;
|
||||
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "The OneShot task ``$(Get-OneShotTask)`` finished.";
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
<#
|
||||
|
|
|
@ -41,7 +41,7 @@ Start-SoftwareInstaller @PSBoundParameters `
|
|||
& ([scriptblock]::Create((aliae init pwsh)));
|
||||
}
|
||||
|
||||
& ([scriptblock]::Create((aliae completion powershell)));
|
||||
aliae completion powershell | Out-String | Invoke-Expression;
|
||||
}
|
||||
) -join [System.Environment]::NewLine)
|
||||
} `
|
||||
|
|
|
@ -10,6 +10,7 @@ using namespace System.Security.Principal;
|
|||
. "$PSScriptRoot/User/Install.ps1";
|
||||
|
||||
$null = New-Module {
|
||||
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
||||
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
||||
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
||||
. "$PSScriptRoot/../Scripts/Registry.ps1";
|
||||
|
@ -44,444 +45,55 @@ $null = New-Module {
|
|||
break;
|
||||
}
|
||||
default {
|
||||
switch ($_) {
|
||||
([SetupStage]::OneShot) {
|
||||
Write-Host "Running OneShot task ``$(Get-OneShotTask)``";
|
||||
if (Test-Admin) {
|
||||
$null = Import-Module PSWindowsUpdate;
|
||||
|
||||
Start-OneShot {
|
||||
switch (Get-OneShotTask) {
|
||||
([OneShotTask]::InitializeMSAccount) {
|
||||
Initialize-UserCreation;
|
||||
}
|
||||
([OneShotTask]::DisableUAC) {
|
||||
Disable-UAC;
|
||||
Register-Setup;
|
||||
}
|
||||
}
|
||||
};
|
||||
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
|
||||
Update-WindowsInstallation;
|
||||
};
|
||||
|
||||
break;
|
||||
if ((Get-WURebootStatus -Silent)) {
|
||||
Restart-Intermediate;
|
||||
return;
|
||||
}
|
||||
default {
|
||||
if (Test-Admin) {
|
||||
$null = Import-Module PSWindowsUpdate;
|
||||
}
|
||||
|
||||
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
|
||||
Update-WindowsInstallation;
|
||||
};
|
||||
switch ($_) {
|
||||
([SetupStage]::Configure) {
|
||||
if (Get-Config "valhalla.windows.dualboot.enable") {
|
||||
if (-not (Test-Qemu)) {
|
||||
# Fix synchronization between Linux and Windows clocks.
|
||||
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Value 1 -Type "DWord";
|
||||
}
|
||||
|
||||
if ((Get-WURebootStatus -Silent)) {
|
||||
Restart-Intermediate;
|
||||
return;
|
||||
# Force time resynchronization
|
||||
$timeZoneOption = "Start";
|
||||
$timeZoneKey = "HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate";
|
||||
$service = Get-Service W32Time;
|
||||
$autoUpdate = (Get-Item $timeZoneKey).GetValue($timeZoneOption);
|
||||
$stopped = ($service.Status -eq "Stopped");
|
||||
|
||||
$setUpdate = { param([int] $Value) Set-ItemProperty $timeZoneKey -Name $timeZoneOption $Value };
|
||||
& $setUpdate 3;
|
||||
Start-Service $service;
|
||||
w32tm /resync /force;
|
||||
& $setUpdate $autoUpdate;
|
||||
|
||||
if ($stopped) {
|
||||
Stop-Service $service;
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Deploys an action for each software.
|
||||
|
||||
.PARAMETER Action
|
||||
The action to execute by default.
|
||||
#>
|
||||
function Deploy-SoftwareAction {
|
||||
param(
|
||||
[Nullable[InstallerAction]] $Action = $null
|
||||
)
|
||||
|
||||
[bool] $install = $false;
|
||||
$arguments = [hashtable]@{ };
|
||||
|
||||
if ($null -ne $Action) {
|
||||
$install = ($Action -eq ([InstallerAction]::Install));
|
||||
$null = $arguments.Add("action", $Action);
|
||||
} else {
|
||||
$install = $true;
|
||||
}
|
||||
|
||||
# Drivers
|
||||
& {
|
||||
$driverPath = "$PSScriptRoot/../Drivers";
|
||||
$mbPath = "$driverPath/ROG Zenith Extreme Alpha";
|
||||
|
||||
if ($install) {
|
||||
if (Get-Config "valhalla.hardware.elgatoWave") {
|
||||
if (-not (Test-ChocoPackage wavelink)) {
|
||||
Install-ChocoPackage wavelink -ArgumentList '--install-arguments="/norestart"';
|
||||
Remove-DesktopIcon "*Wave Link*";
|
||||
Restart-Intermediate;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($component in (Get-Config "valhalla.hardware.components")) {
|
||||
switch ($component) {
|
||||
("ROG Zenith Extreme Alpha") {
|
||||
& "$mbPath/MarvellEthernet/Manage.ps1" @arguments;
|
||||
& "$mbPath/IntelWiFi/Manage.ps1" @arguments;
|
||||
& "$mbPath/IntelBluetooth/Manage.ps1" @arguments;
|
||||
& "$mbPath/AMDChipsetX399/Manage.ps1" @arguments;
|
||||
& "$driverPath/AMDChipsetX399/Manage.ps1" @arguments;
|
||||
}
|
||||
("Predator Z301C") {
|
||||
& "$driverPath/Predator Z301C/Manage.ps1" @arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($install) {
|
||||
if (Get-Config "valhalla.hardware.amdCPU") {
|
||||
Install-ChocoPackage amd-ryzen-master;
|
||||
# ToDo: backup Ryzen energy saving plan
|
||||
}
|
||||
|
||||
if (Get-Config "valhalla.hardware.nvidiaGPU") {
|
||||
Install-ChocoPackage geforce-game-ready-driver;
|
||||
Remove-DesktopIcon "*Geforce*";
|
||||
}
|
||||
|
||||
if (Get-Config "valhalla.hardware.corsairDevice") {
|
||||
Install-ChocoPackage icue;
|
||||
}
|
||||
}
|
||||
|
||||
if (Get-Config "valhalla.hardware.eyeX") {
|
||||
& "$driverPath/Tobii EyeX/Manage.ps1" @arguments;
|
||||
}
|
||||
};
|
||||
|
||||
& {
|
||||
# Windows Config
|
||||
$softwarePath = "$PSScriptRoot/../Software";
|
||||
$commonSoftware = "$PSScriptRoot/../../Common/Software";
|
||||
& "$softwarePath/Windows/Manage.ps1" @arguments;
|
||||
|
||||
if (Get-Config "valhalla.hardware.logitechG") {
|
||||
& "$softwarePath/LGHub/Manage.ps1" @arguments;
|
||||
}
|
||||
|
||||
if (Test-Collection "essential") {
|
||||
# Essentials
|
||||
& "$softwarePath/aliae/Main.ps1" @arguments;
|
||||
& "$softwarePath/OpenSSH/Manage.ps1" @arguments;
|
||||
& "$softwarePath/PowerShell/Manage.ps1" @arguments;
|
||||
& "$softwarePath/chocolatey/Manage.ps1" @arguments;
|
||||
& "$softwarePath/zoxide/Manage.ps1" @arguments;
|
||||
& "$commonSoftware/posh-git/Manage.ps1" @arguments;
|
||||
& "$commonSoftware/Terminal-Icons/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Oh My Posh/Manage.ps1" @arguments;
|
||||
|
||||
if (Get-Config "valhalla.windows.dualboot") {
|
||||
& "$softwarePath/Ext4Fsd/Main.ps1" @arguments;
|
||||
}
|
||||
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
procexp `
|
||||
procmon `
|
||||
;
|
||||
|
||||
Install-WingetPackage `
|
||||
KDE.KDEConnect `
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "common") {
|
||||
# Common Software
|
||||
& "$softwarePath/WinSCP/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Thunderbird/Manage.ps1" @arguments;
|
||||
& "$softwarePath/PuTTY/Manage.ps1" @arguments;
|
||||
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
7zip `
|
||||
chocolateygui `
|
||||
DefaultProgramsEditor `
|
||||
bitwarden `
|
||||
keepass `
|
||||
;
|
||||
|
||||
Install-WingetPackage `
|
||||
SomePythonThings.WingetUIStore `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "UniGetUI*";
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "desktopExperience") {
|
||||
if ($install) {
|
||||
# Fonts
|
||||
Install-ChocoPackage nerd-fonts-CascadiaCode;
|
||||
|
||||
# Internet Access
|
||||
Install-WingetPackage Brave.Brave kamranahmedse.pennywise;
|
||||
Remove-DesktopIcon "*Brave*";
|
||||
Remove-TaskbarItem "*Brave*";
|
||||
Remove-DesktopIcon "Pennywise*";
|
||||
|
||||
# Tools
|
||||
Install-SetupPackage -Source "https://github.com/mRemoteNG/mRemoteNG/releases/download/2023.03.03-v1.77.3-nb/mRemoteNG-Installer-1.77.3.nb-1784.msi" -ArgumentList "/Quiet";
|
||||
Remove-DesktopIcon "mRemoteNG*";
|
||||
|
||||
Install-ChocoPackage `
|
||||
gimp `
|
||||
gpu-z `
|
||||
windirstat `
|
||||
winmerge `
|
||||
handbrake `
|
||||
hwmonitor `
|
||||
qbittorrent `
|
||||
imgburn `
|
||||
inkscape `
|
||||
krita `
|
||||
MetaX `
|
||||
obs-studio `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "GIMP*";
|
||||
Remove-DesktopIcon "GPU-Z*";
|
||||
Remove-DesktopIcon "WinDirStat*";
|
||||
Remove-DesktopIcon "*HWMonitor*";
|
||||
Remove-DesktopIcon "ImgBurn*";
|
||||
Remove-DesktopIcon "InkScape*";
|
||||
Remove-DesktopIcon "Krita*";
|
||||
Remove-DesktopIcon "MetaX*";
|
||||
Remove-DesktopIcon "OBS Studio*";
|
||||
|
||||
Install-WingetPackage `
|
||||
AntSoftware.AntRenamer `
|
||||
AppWork.JDownloader;
|
||||
|
||||
Remove-DesktopIcon "JDownloader*";
|
||||
}
|
||||
|
||||
# ToDo: Consider hiding behind own config?
|
||||
& "$softwarePath/Ubiquiti UniFi Controller/Manage.ps1" @arguments;
|
||||
|
||||
# Internet Access
|
||||
& "$softwarePath/Firefox/Manage.ps1" @arguments;
|
||||
& "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments;
|
||||
|
||||
if (Test-Collection "fileSync") {
|
||||
& "$softwarePath/Nextcloud/Main.ps1" @arguments;
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "socialMedia") {
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
signal `
|
||||
threema-desktop `
|
||||
element-desktop `
|
||||
teamspeak `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "*Element*";
|
||||
Remove-DesktopIcon "*TeamSpeak*";
|
||||
|
||||
Install-WingetPackage Discord.Discord;
|
||||
Remove-DesktopIcon "*Discord*";
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "media") {
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
k-litecodecpackmega `
|
||||
vlc `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "VLC*";
|
||||
Install-ChocoPackage jellyfin-media-player -ArgumentList "--install-args","/norestart";
|
||||
Remove-DesktopIcon "Jellyfin Media Player*";
|
||||
Install-WingetPackage Ytmdesktop.Ytmdesktop;
|
||||
Remove-DesktopIcon "Youtube Music*";
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "coding") {
|
||||
if ($install) {
|
||||
& "$softwarePath/vscode/Main.ps1" @arguments;
|
||||
|
||||
Install-ChocoPackage `
|
||||
gh `
|
||||
github-desktop `
|
||||
ida-free `
|
||||
HxD `
|
||||
docker-desktop `
|
||||
imhex `
|
||||
dotpeek `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "IDA *";
|
||||
Remove-DesktopIcon "GitHub*";
|
||||
Remove-DesktopIcon "Docker*";
|
||||
}
|
||||
|
||||
& "$softwarePath/VisualStudio/Manage.ps1" @arguments;
|
||||
|
||||
# Node.js
|
||||
& "$softwarePath/NVS/Manage.ps1" @arguments;
|
||||
}
|
||||
|
||||
if (Test-Collection "gaming") {
|
||||
# Gaming
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
goggalaxy `
|
||||
epicgameslauncher `
|
||||
rayman-controlpanel `
|
||||
ppsspp `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "*Epic Games*";
|
||||
Remove-DesktopIcon "*PPSSPP *-Bit*";
|
||||
|
||||
Install-ChocoPackage `
|
||||
steam `
|
||||
ubisoft-connect `
|
||||
-ArgumentList "--ignore-checksums" `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "*Steam*";
|
||||
Remove-DesktopIcon "*Ubisoft Connect*";
|
||||
|
||||
Install-WingetPackage ElectronicArts.EADesktop;
|
||||
Remove-DesktopIcon "EA.*";
|
||||
}
|
||||
|
||||
& "$softwarePath/TrackMania Nations Forever/Manage.ps1" @arguments;
|
||||
& "$softwarePath/TrackMania United Forever/Manage.ps1" @arguments;
|
||||
& "$softwarePath/ManiaPlanet/Manage.ps1" @arguments;
|
||||
& "$softwarePath/osu!/Manage.ps1" @arguments;
|
||||
& "$softwarePath/osu!lazer/Manage.ps1" @arguments;
|
||||
& "$softwarePath/RetroArch/Manage.ps1" @arguments;
|
||||
& "$softwarePath/reWASD/Manage.ps1" @arguments;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
switch ($_) {
|
||||
([SetupStage]::Configure) {
|
||||
if (Get-Config "valhalla.windows.dualboot.enable") {
|
||||
if (-not (Test-Qemu)) {
|
||||
# Fix synchronization between Linux and Windows clocks.
|
||||
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Value 1 -Type "DWord";
|
||||
}
|
||||
|
||||
# Force time resynchronization
|
||||
$timeZoneOption = "Start";
|
||||
$timeZoneKey = "HKLM:\SYSTEM\CurrentControlSet\Services\tzautoupdate";
|
||||
$service = Get-Service W32Time;
|
||||
$autoUpdate = (Get-Item $timeZoneKey).GetValue($timeZoneOption);
|
||||
$stopped = ($service.Status -eq "Stopped");
|
||||
|
||||
$setUpdate = { param([int] $Value) Set-ItemProperty $timeZoneKey -Name $timeZoneOption $Value };
|
||||
& $setUpdate 3;
|
||||
Start-Service $service;
|
||||
w32tm /resync /force;
|
||||
& $setUpdate $autoUpdate;
|
||||
|
||||
if ($stopped) {
|
||||
Stop-Service $service;
|
||||
}
|
||||
}
|
||||
|
||||
Set-Stage ([SetupStage]::Install);
|
||||
}
|
||||
([SetupStage]::Install) {
|
||||
Write-Host "Entering install phase";
|
||||
Deploy-SoftwareAction;
|
||||
Set-Stage ([SetupStage]::CreateUser);
|
||||
}
|
||||
([SetupStage]::CreateUser) {
|
||||
$users = @(Get-Users);
|
||||
$i = Get-CurrentUser;
|
||||
|
||||
for (; $i -lt $users.Count; $i++) {
|
||||
$name = $users[$i];
|
||||
Set-CurrentUser $i;
|
||||
|
||||
if (Test-Admin) {
|
||||
Disable-BootMessage;
|
||||
}
|
||||
|
||||
while ((Get-UserStage) -ne ([UserStage]::Completed)) {
|
||||
switch (Get-UserStage) {
|
||||
($null) {
|
||||
Set-UserStage ([UserStage]::Create);
|
||||
continue;
|
||||
}
|
||||
([UserStage]::Create) {
|
||||
$msAccount = Get-UserConfig -UserName $name "microsoftAccount";
|
||||
|
||||
if ($env:UserName -ne $name) {
|
||||
New-ValhallaUser $name;
|
||||
|
||||
if ($msAccount) {
|
||||
logoff;
|
||||
} else {
|
||||
Restart-Intermediate;
|
||||
}
|
||||
|
||||
exit;
|
||||
} else {
|
||||
if ($msAccount) {
|
||||
if (-not (Test-Admin)) {
|
||||
Invoke-OneShot DisableUAC;
|
||||
Restart-Intermediate -NoRegister;
|
||||
return;
|
||||
}
|
||||
|
||||
Clear-SetupRegistration;
|
||||
Disable-OneShotListener;
|
||||
}
|
||||
|
||||
Set-UserStage ([UserStage]::Configure);
|
||||
}
|
||||
}
|
||||
(([UserStage]::Configure)) {
|
||||
$displayName = Get-UserConfig -UserName $name "displayName";
|
||||
|
||||
$userArguments = @{
|
||||
name = $name;
|
||||
};
|
||||
|
||||
if ($displayName) {
|
||||
$userArguments.fullName = $displayName;
|
||||
}
|
||||
|
||||
$adminGroup = @{
|
||||
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||
};
|
||||
|
||||
Set-LocalUser @userArguments;
|
||||
Deploy-SoftwareAction -Action ([InstallerAction]::ConfigureUser);
|
||||
Remove-LocalGroupMember -Member "$name" @adminGroup -ErrorAction SilentlyContinue;
|
||||
|
||||
foreach ($group in Get-UserConfig "groups") {
|
||||
Add-LocalGroupMember -Member "$name" -Name "$group";
|
||||
}
|
||||
|
||||
Set-UserStage ([UserStage]::Cleanup);
|
||||
}
|
||||
([UserStage]::Cleanup) {
|
||||
$user = Get-SetupUser;
|
||||
Enable-LocalUser $user;
|
||||
Set-AutologinUser $user;
|
||||
Unregister-WslDistribution;
|
||||
Set-UserStage ([UserStage]::Completed);
|
||||
Restart-Intermediate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set-IsFinished $true;
|
||||
}
|
||||
}
|
||||
Set-Stage ([SetupStage]::Install);
|
||||
}
|
||||
([SetupStage]::Install) {
|
||||
Write-Host "Entering install phase";
|
||||
Deploy-SoftwareAction;
|
||||
Set-Stage ([SetupStage]::CreateUser);
|
||||
}
|
||||
([SetupStage]::CreateUser) {
|
||||
Install-ValhallaUsers;
|
||||
Set-IsFinished $true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
293
scripts/Windows/Scripts/Deployment.ps1
Normal file
293
scripts/Windows/Scripts/Deployment.ps1
Normal file
|
@ -0,0 +1,293 @@
|
|||
. "$PSScriptRoot/../../Common/Scripts/Software.ps1";
|
||||
. "$PSScriptRoot/../../Common/Scripts/SoftwareManagement.ps1";
|
||||
. "$PSScriptRoot/../../Common/Types/InstallerAction.ps1";
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Deploys an action for each software selected for installation.
|
||||
|
||||
.PARAMETER
|
||||
The action to execute.
|
||||
#>
|
||||
function Deploy-SoftwareAction {
|
||||
param(
|
||||
[System.Nullable[InstallerAction]] $Action = $null
|
||||
)
|
||||
|
||||
[bool] $install = $false;
|
||||
$arguments = [hashtable]@{ };
|
||||
|
||||
if ($null -ne $Action) {
|
||||
$install = ($Action -eq ([InstallerAction]::Install));
|
||||
$null = $arguments.Add("action", $Action);
|
||||
} else {
|
||||
$install = $true;
|
||||
}
|
||||
|
||||
# Drivers
|
||||
& {
|
||||
$driverPath = "$PSScriptRoot/../Drivers";
|
||||
$mbPath = "$driverPath/ROG Zenith Extreme Alpha";
|
||||
|
||||
if ($install) {
|
||||
if (Get-Config "valhalla.hardware.elgatoWave") {
|
||||
if (-not (Test-ChocoPackage wavelink)) {
|
||||
Install-ChocoPackage wavelink -ArgumentList '--install-arguments="/norestart"';
|
||||
Remove-DesktopIcon "*Wave Link*";
|
||||
Restart-Intermediate;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($component in (Get-Config "valhalla.hardware.components")) {
|
||||
switcH ($component) {
|
||||
("ROG Zenith Extreme Alpha") {
|
||||
& "$mbPath/MarvellEthernet/Manage.ps1" @arguments;
|
||||
& "$mbPath/IntelWiFi/Manage.ps1" @arguments;
|
||||
& "$mbPath/IntelBluetooth/Manage.ps1" @arguments;
|
||||
& "$mbPath/AMDChipsetX399/Manage.ps1" @arguments;
|
||||
& "$driverPath/AMDChipsetX399/Manage.ps1" @arguments;
|
||||
}
|
||||
("Predator Z301C") {
|
||||
& "$driverPath/Predator Z301C/Manage.ps1" @arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($install) {
|
||||
if (Get-Config "valhalla.hardware.amdCPU") {
|
||||
Install-ChocoPackage amd-ryzen-master;
|
||||
# ToDo: backup Ryzen energy saving plan
|
||||
}
|
||||
|
||||
if (Get-Config "valhalla.hardware.nvidiaGPU") {
|
||||
Install-ChocoPackage geforce-game-ready-driver;
|
||||
Remove-DesktopIcon "*Geforce*";
|
||||
}
|
||||
|
||||
if (Get-Config "valhalla.hardware.corsairDevice") {
|
||||
Install-ChocoPackage icue;
|
||||
}
|
||||
}
|
||||
|
||||
if (Get-Config "valhalla.hardware.eyeX") {
|
||||
& "$driverPath/Tobii EyeX/Manage.ps1" @arguments;
|
||||
}
|
||||
};
|
||||
|
||||
& {
|
||||
$softwarePath = "$PSScriptRoot/../Software";
|
||||
$commonSoftware = "$PSScriptRoot/../../Common/Software";
|
||||
|
||||
# Windows Config
|
||||
& "$softwarePath/Windows/Manage.ps1" @arguments;
|
||||
|
||||
if (Get-Config "valhalla.hardware.logitechG") {
|
||||
& "$softwarePath/LGHub/Manage.ps1" @arguments;
|
||||
}
|
||||
|
||||
# Essentials
|
||||
if (Test-Collection "essential") {
|
||||
& "$softwarePath/aliae/Main.ps1" @arguments;
|
||||
& "$softwarePath/OpenSSH/Manage.ps1" @arguments;
|
||||
& "$softwarePath/PowerShell/Manage.ps1" @arguments;
|
||||
& "$softwarePath/chocolatey/Manage.ps1" @arguments;
|
||||
& "$softwarePath/zoxide/Manage.ps1" @arguments;
|
||||
& "$commonSoftware/posh-git/Manage.ps1" @arguments;
|
||||
& "$commonSoftware/Terminal-Icon/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Oh My Posh/Manage.ps1" @arguments;
|
||||
|
||||
if (Get-Config "valhalla.windows.dualboot") {
|
||||
& "$softwarePath/Ext4Fsd/Main.ps1" @arguments;
|
||||
}
|
||||
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
procexp `
|
||||
procmon `
|
||||
;
|
||||
|
||||
Install-WingetPackage `
|
||||
KDE.KDEConnect `
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
# Common Software
|
||||
if (Test-Collection "common") {
|
||||
& "$softwarePath/WinSCP/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Thunderbird/Manage.ps1" @arguments;
|
||||
& "$softwarePath/PuTTY/Manage.ps1" @arguments;
|
||||
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
7zip `
|
||||
chocolateygui `
|
||||
DefaultProgramsEditor `
|
||||
bitwarden `
|
||||
keepass `
|
||||
;
|
||||
|
||||
Install-WingetPackage `
|
||||
SomePythonThings.WingetUIStore `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "UniGetUI*";
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "desktopExperience") {
|
||||
if ($install) {
|
||||
# Fonts
|
||||
Install-ChocoPackage nerd-fonts-CascadiaCode;
|
||||
|
||||
# Internet Access
|
||||
Install-WingetPackage Brave.Brave kamranahmedse.pennywise;
|
||||
Remove-DesktopIcon "*Brave*";
|
||||
Remove-TaskbarItem "*Brave*";
|
||||
Remove-DesktopIcon "Pennywise*";
|
||||
|
||||
# Tools
|
||||
Install-SetupPackage -Source "https://github.com/mRemoteNG/mRemoteNG/releases/download/2023.03.03-v1.77.3-nb/mRemoteNG-Installer-1.77.3.nb-1784.msi" -ArgumentList "/Quiet";
|
||||
Remove-DesktopIcon "mRemoteNG*";
|
||||
|
||||
Install-ChocoPackage `
|
||||
gimp `
|
||||
gpu-z `
|
||||
windirstat `
|
||||
winmerge `
|
||||
handbrake `
|
||||
hwmonitor `
|
||||
qbittorrent `
|
||||
imgburn `
|
||||
inkscape `
|
||||
krita `
|
||||
MetaX `
|
||||
obs-studio `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "GIMP*";
|
||||
Remove-DesktopIcon "GPU-Z*";
|
||||
Remove-DesktopIcon "WinDirStat*";
|
||||
Remove-DesktopIcon "*HWMonior*";
|
||||
Remove-DesktopIcon "ImgBurn*";
|
||||
Remove-DesktopIcon "InkScape*";
|
||||
Remove-DesktopIcon "Krita*";
|
||||
Remove-DesktopIcon "MetaX*";
|
||||
Remove-DesktopIcon "OBS Studio*";
|
||||
|
||||
Install-WingetPackage `
|
||||
AntSoftware.AntRenamer `
|
||||
AppWork.JDownloader `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "JDownloader*";
|
||||
}
|
||||
|
||||
# ToDo: Consider hiding behind own config?
|
||||
& "$softwarePath/Ubiquiti UniFi Controller/Manage.ps1" @arguments;
|
||||
|
||||
# Internet Access
|
||||
& "$softwarePath/Firefox/Manage.ps1" @arguments;
|
||||
& "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments;
|
||||
|
||||
if (Test-Collection "fileSync") {
|
||||
& "$softwarePath/Nextcloud/Main.ps1" @arguments;
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "socialMedia") {
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
signal `
|
||||
threema-desktop `
|
||||
element-desktop `
|
||||
teamspeak `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "*Element*";
|
||||
Remove-DesktopIcon "*TeamSpeak*";
|
||||
|
||||
Install-WingetPackage Discord.Discord;
|
||||
Remove-DesktopIcon "*Discord*";
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "media") {
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
k-litecodecpackmega `
|
||||
vlc `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "VLC*";
|
||||
# When installing Jellyfin Media Player after iCUE, Jellyfin will try to reboot automatically
|
||||
Install-ChocoPackage jellyfin-media-player -ArgumentList "--install-args","/norestart";
|
||||
Remove-DesktopIcon "Jellyfin Media Player*";
|
||||
Install-WingetPackage Ytmdesktop.Ytmdesktop;
|
||||
Remove-DesktopIcon "Youtube Music*";
|
||||
}
|
||||
}
|
||||
|
||||
if (Test-Collection "coding") {
|
||||
if ($install) {
|
||||
& "$softwarePath/vscode/Main.ps1" @arguments;
|
||||
|
||||
Install-ChocoPackage `
|
||||
gh `
|
||||
github-desktop `
|
||||
ida-free `
|
||||
HxD `
|
||||
docker-desktop `
|
||||
imhex `
|
||||
dotpeek `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "IDA *";
|
||||
Remove-DesktopIcon "GitHub*";
|
||||
Remove-DesktopIcon "Docker*";
|
||||
}
|
||||
|
||||
& "$softwarePath/VisualStudio/Manage.ps1" @arguments;
|
||||
|
||||
# Node.js
|
||||
& "$softwarePath/NVS/Manage.ps1" @arguments;
|
||||
}
|
||||
|
||||
# Gaming
|
||||
if (Test-Collection "gaming") {
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
goggalaxy `
|
||||
epicgameslauncher `
|
||||
rayman-controlpanel `
|
||||
ppsspp `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "*Epic Games*";
|
||||
Remove-DesktopIcon "*PPSSPP *-Bit*";
|
||||
|
||||
Install-ChocoPackage `
|
||||
steam `
|
||||
ubisoft-connect `
|
||||
-ArgumentList "--ignore-checksums" `
|
||||
;
|
||||
|
||||
Remove-DesktopIcon "*Steam*";
|
||||
Remove-DesktopIcon "*Ubisoft Connect*";
|
||||
|
||||
Install-WingetPackage ElectronicArts.EADesktop;
|
||||
Remove-DesktopIcon "EA.*";
|
||||
}
|
||||
|
||||
& "$softwarePath/TrackMania Nations Forever/Manage.ps1" @arguments;
|
||||
& "$softwarePath/TrackMania United Forever/Manage.ps1" @arguments;
|
||||
& "$softwarePath/ManiaPlanet/Manage.ps1" @arguments;
|
||||
& "$softwarePath/osu!/Manage.ps1" @arguments;
|
||||
& "$softwarePath/osu!lazer/Manage.ps1" @arguments;
|
||||
& "$softwarePath/RetroArch/Manage.ps1" @arguments;
|
||||
& "$softwarePath/reWASD/Manage.ps1" @arguments;
|
||||
}
|
||||
};
|
||||
}
|
119
scripts/Windows/Scripts/Restoration.ps1
Normal file
119
scripts/Windows/Scripts/Restoration.ps1
Normal file
|
@ -0,0 +1,119 @@
|
|||
. "$PSScriptRoot/../../Common/Scripts/System.ps1";
|
||||
|
||||
$null = New-Module {
|
||||
$pathResolver = {
|
||||
param(
|
||||
[string] $User,
|
||||
[string] $Path
|
||||
)
|
||||
|
||||
[string] $result = $null;
|
||||
|
||||
if ($User) {
|
||||
$result = "Users/$User";
|
||||
} else {
|
||||
$result = "System";
|
||||
}
|
||||
|
||||
$result = Join-Path $result $Path;
|
||||
return $result;
|
||||
};
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the name of the variable holding the path to the backup archive of the current machine.
|
||||
#>
|
||||
function Get-ArchiveVariableName {
|
||||
return "BACKUP_ARCHIVE";
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the path to the backup archive of the current machine.
|
||||
#>
|
||||
function Get-ValhallaBackupArchive {
|
||||
(Get-Item "Env:\$(Get-ArchiveVariableName)").Value;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the path to the backup archive of the current machine.
|
||||
|
||||
.PARAMETER Path
|
||||
The path to set.
|
||||
#>
|
||||
function Set-ValhallaBackupArchive {
|
||||
param(
|
||||
[string] $Path
|
||||
)
|
||||
|
||||
Set-Item "Env:\$(Get-ArchiveVariableName)" $Path;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Adds files to the backup archive.
|
||||
|
||||
.PARAMETER User
|
||||
The user to add the files to.
|
||||
|
||||
.PARAMETER Source
|
||||
The file or directory to add to the backup archive.
|
||||
|
||||
.PARAMETER Path
|
||||
The path to the location to store the file or directory at.
|
||||
|
||||
.PARAMETER ArgumentList
|
||||
The arguments to pass to the `7z` command.
|
||||
#>
|
||||
function Add-BackupArtifacts {
|
||||
param(
|
||||
[string] $User,
|
||||
[string] $Source,
|
||||
[string] $Path,
|
||||
[Parameter(ValueFromRemainingArguments)]
|
||||
[string[]] $ArgumentList
|
||||
)
|
||||
|
||||
$dir = New-TemporaryDirectory;
|
||||
$targetPath = & $pathResolver @PSBoundParameters;
|
||||
$targetPath = Join-Path $dir $targetPath;
|
||||
$null = New-Item -ItemType Directory -Force $targetPath;
|
||||
|
||||
Copy-Item -Force -Recurse $Source $targetPath;
|
||||
7z a (Get-ValhallaBackupArchive) "$dir/*" @ArgumentList;
|
||||
Remove-Item -Recurse -Force $dir;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Extracts the specified backup artifacts to the specified target path.
|
||||
|
||||
.PARAMETER User
|
||||
The user to restore the files for.
|
||||
|
||||
.PARAMETER Path
|
||||
The path to restore the files from.
|
||||
|
||||
.PARAMETER Target
|
||||
The path to restore the files to.
|
||||
|
||||
.PARAMETER ArgumentList
|
||||
The arguments to pass to `7z`.
|
||||
#>
|
||||
function Expand-BackupArtifacts {
|
||||
param(
|
||||
[string] $User,
|
||||
[string] $Path,
|
||||
[string] $Target,
|
||||
[Parameter(ValueFromRemainingArguments)]
|
||||
[string[]] $ArgumentList
|
||||
)
|
||||
|
||||
$dir = New-TemporaryDirectory;
|
||||
$sourcePath = & $pathResolver @PSBoundParameters;
|
||||
7z x "-o$dir" (Get-ValhallaBackupArchive) $sourcePath @ArgumentList;
|
||||
Copy-Item -Recurse (Join-Path $dir $sourcePath) $Target;
|
||||
Remove-Item -Recurse -Force $dir;
|
||||
}
|
||||
};
|
|
@ -2,20 +2,120 @@ using namespace System.Management.Automation.Host;
|
|||
using namespace System.Security.Principal;
|
||||
|
||||
$null = New-Module {
|
||||
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
||||
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
|
||||
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
|
||||
$loggedInUserOption = "LoggedInUser";
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Installs all pending users to the system.
|
||||
#>
|
||||
function Install-ValhallaUsers {
|
||||
$users = @(Get-Users);
|
||||
$i = Get-CurrentUser;
|
||||
|
||||
for (; $i -lt $users.Count; $i++) {
|
||||
Set-CurrentUser $i;
|
||||
|
||||
if (Test-Admin) {
|
||||
Disable-BootMessage;
|
||||
}
|
||||
|
||||
while ((Get-UserStage) -ne ([UserStage]::Completed)) {
|
||||
switch (Get-UserStage) {
|
||||
($null) {
|
||||
Set-UserStage ([UserStage]::Create);
|
||||
break;
|
||||
}
|
||||
([UserStage]::Create) {
|
||||
$msAccount = Get-UserConfig -UserName $name "microsoftAccount";
|
||||
|
||||
if ($env:UserName -ne $name) {
|
||||
New-ValhallaUser @{
|
||||
name = $name;
|
||||
msAccount = $msAccount;
|
||||
}
|
||||
|
||||
if ($msAccount) {
|
||||
logoff;
|
||||
} else {
|
||||
Restart-Intermediate;
|
||||
}
|
||||
|
||||
exit;
|
||||
} else {
|
||||
if ($msAccount) {
|
||||
if (-not (Test-Admin)) {
|
||||
Invoke-OneShot DisableUAC;
|
||||
Restart-Intermediate -NoRegister;
|
||||
exit;
|
||||
}
|
||||
|
||||
Clear-SetupRegistration;
|
||||
Disable-OneShotListener;
|
||||
}
|
||||
|
||||
Set-UserStage ([UserStage]::Configure);
|
||||
}
|
||||
}
|
||||
([UserStage]::Configure) {
|
||||
$displayName = Get-UserConfig -UserName $name "displayName";
|
||||
|
||||
$userInfo = @{
|
||||
name = $name;
|
||||
};
|
||||
|
||||
if ($displayName) {
|
||||
$userInfo.fullName = $displayName;
|
||||
}
|
||||
|
||||
$adminGroup = @{
|
||||
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||
};
|
||||
|
||||
Set-LocalUser @userInfo;
|
||||
Deploy-SoftwareAction -Action ConfigureUser;
|
||||
Remove-LocalGroupMember -Member "$name" @adminGroup -ErrorAction SilentlyContinue;
|
||||
|
||||
foreach ($group in Get-UserConfig "groups") {
|
||||
Add-LocalGroupMember -Member "$name" -Name "$group";
|
||||
}
|
||||
|
||||
Set-UserStage ([UserStage]::Cleanup);
|
||||
}
|
||||
([UserStage]::Cleanup) {
|
||||
$user = Get-SetupUser;
|
||||
Disable-LocalUser $name;
|
||||
Enable-LocalUser $user;
|
||||
Set-AutologinUser $user;
|
||||
Unregister-WslDistribution;
|
||||
Set-UserStage ([UserStage]::Completed);
|
||||
Restart-Intermediate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($user in $users) {
|
||||
Enable-LocalUser $user;
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Creates a new user for the PortValhalla setup.
|
||||
|
||||
.PARAMETER Name
|
||||
The name of the user to create.
|
||||
|
||||
.PARAMETER MSAccount
|
||||
A value indicating whether the user should be created as a Microsoft Account.
|
||||
#>
|
||||
function New-ValhallaUser {
|
||||
param(
|
||||
[string] $Name
|
||||
[string] $Name,
|
||||
[switch] $MSAccount
|
||||
)
|
||||
|
||||
function Add-MicrosoftAccount {
|
||||
|
@ -83,9 +183,7 @@ $null = New-Module {
|
|||
Set-MSAccountName ([string]$newUser);
|
||||
}
|
||||
|
||||
$msAccount = Get-UserConfig -UserName $Name "microsoftAccount";
|
||||
|
||||
if ($msAccount) {
|
||||
if ($MSAccount) {
|
||||
if (Test-Admin) {
|
||||
Write-Host "Preparing environment for creating MS Account";
|
||||
Register-Setup -DefaultUser;
|
||||
|
@ -104,7 +202,7 @@ $null = New-Module {
|
|||
|
||||
Write-Host "Creating personal user ``$Name``…";
|
||||
|
||||
if ($msAccount) {
|
||||
if ($MSAccount) {
|
||||
Add-MicrosoftAccount $Name;
|
||||
Set-SetupOption $loggedInUserOption $env:UserName;
|
||||
Invoke-OneShot ([OneShotTask]::InitializeMSAccount);
|
||||
|
|
Loading…
Reference in a new issue