Compare commits
31 commits
019ad5693d
...
eab83d2528
Author | SHA1 | Date | |
---|---|---|---|
Manuel Thalmann | eab83d2528 | ||
Manuel Thalmann | 92d4c82883 | ||
Manuel Thalmann | 4f3edae514 | ||
Manuel Thalmann | cb093dd9a2 | ||
Manuel Thalmann | a828a4824f | ||
Manuel Thalmann | 2a7eabff16 | ||
Manuel Thalmann | fb9875b861 | ||
Manuel Thalmann | 43f8d8850e | ||
Manuel Thalmann | ba1e4bd249 | ||
Manuel Thalmann | e9f7b6dd6e | ||
Manuel Thalmann | ebd977eead | ||
Manuel Thalmann | 49b06b555c | ||
Manuel Thalmann | 5f1dd06f07 | ||
Manuel Thalmann | 466e0375bf | ||
Manuel Thalmann | 9e945a6543 | ||
Manuel Thalmann | 4888e95f8b | ||
Manuel Thalmann | 47678fab1a | ||
Manuel Thalmann | 439e5b9d9a | ||
Manuel Thalmann | 07bfa92ff8 | ||
Manuel Thalmann | 4af30b01f7 | ||
Manuel Thalmann | d35a0aacaa | ||
Manuel Thalmann | 4ccab1510d | ||
Manuel Thalmann | a72471d470 | ||
Manuel Thalmann | 65584b719f | ||
Manuel Thalmann | c816a97110 | ||
Manuel Thalmann | 143872840e | ||
Manuel Thalmann | df6ac5ab4d | ||
Manuel Thalmann | 2472ca5cc6 | ||
Manuel Thalmann | 3de22dd745 | ||
Manuel Thalmann | bae76b7473 | ||
Manuel Thalmann | c4cb3f4f88 |
|
@ -13,6 +13,7 @@
|
|||
|
||||
users.Manuel = {
|
||||
microsoftAccount = true;
|
||||
groups = ["Administrators"];
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ using namespace System.Security.AccessControl;
|
|||
using namespace System.Security.Principal;
|
||||
|
||||
enum SetupStage {
|
||||
Idle
|
||||
Initialize
|
||||
OneShot
|
||||
Configure
|
||||
Install
|
||||
CreateUser
|
||||
|
@ -244,7 +246,7 @@ $null = New-Module {
|
|||
Gets a value indicating whether the setup has finished.
|
||||
#>
|
||||
function Get-IsFinished {
|
||||
return [bool] (Get-SetupOption $finishedOption);
|
||||
return [bool] (((Get-Stage) -eq ([SetupStage]::Idle)) -or (Get-SetupOption $finishedOption));
|
||||
}
|
||||
|
||||
<#
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
function Start-Operation {
|
||||
. "$PSScriptRoot/Config.ps1";
|
||||
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
||||
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
|
||||
|
||||
$null = New-Module {
|
||||
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
||||
$oneShotTaskName = "PortValhalla OneShot";
|
||||
$logName = "Application";
|
||||
$oneShotTrigger = 1337;
|
||||
$taskOption = "OneShotTask";
|
||||
# ToDo: Store "ProgramData/PortValhalla" path somewhere as const
|
||||
$errorPath = "$env:ProgramData/PortValhalla/error.txt";
|
||||
|
||||
$taskSetter = {
|
||||
param([OneShotTask] $Task)
|
||||
Set-SetupOption $taskOption ([string]$Task);
|
||||
};
|
||||
|
||||
function Start-Operation {
|
||||
param(
|
||||
[scriptblock] $Action
|
||||
)
|
||||
|
@ -10,6 +28,110 @@ function Start-Operation {
|
|||
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
||||
}
|
||||
|
||||
New-Alias "sudo" gsudo;
|
||||
New-Alias -Force "sudo" gsudo;
|
||||
& $Action;
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets the current OneShot task.
|
||||
#>
|
||||
function Get-OneShotTask {
|
||||
[OneShotTask](Get-SetupOption $taskOption);
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Registers a task for listening to OneShot invocations.
|
||||
#>
|
||||
function Enable-OneShotListener {
|
||||
$tempTask = "PortValhalla Temp";
|
||||
$action = New-ScheduledTaskAction -Execute "pwsh" -Argument (Get-StartupArguments);
|
||||
schtasks /Create /SC ONEVENT /EC $logName /MO "*[System[Provider[@Name='$logName'] and EventID=$($oneShotTrigger)]]" /TR cmd.exe /TN $tempTask;
|
||||
$trigger = (Get-ScheduledTask $tempTask).Triggers;
|
||||
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest;
|
||||
$task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger;
|
||||
$null = Register-ScheduledTask -Force $oneShotTaskName -InputObject $task;
|
||||
$null = Unregister-ScheduledTask -Confirm:$false $tempTask;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Removes the OneShot task.
|
||||
#>
|
||||
function Disable-OneShotListener {
|
||||
Unregister-ScheduledTask -Confirm:$false $oneShotTaskName;
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Invokes a one-shot task.
|
||||
|
||||
.PARAMETER Task
|
||||
The task to run.
|
||||
#>
|
||||
function Invoke-OneShot {
|
||||
param(
|
||||
[OneShotTask] $Task
|
||||
)
|
||||
|
||||
$currentStage = Get-Stage;
|
||||
Set-Stage ([SetupStage]::OneShot);
|
||||
& $taskSetter $Task;
|
||||
|
||||
& {
|
||||
$identifier = "EventLog$oneShotTrigger";
|
||||
$log = [System.Diagnostics.EventLog]::new($logName);
|
||||
$log.EnableRaisingEvents = $true;
|
||||
|
||||
$null = Register-ObjectEvent -InputObject $log -EventName EntryWritten -Action {
|
||||
$entry = $Event.SourceEventArgs.Entry;
|
||||
$trigger = $Event.MessageData.Trigger;
|
||||
$identifier = $Event.MessageData.Identifier;
|
||||
|
||||
if ($entry.EventID -eq $trigger) {
|
||||
$null = New-Event -SourceIdentifier $identifier;
|
||||
}
|
||||
} `
|
||||
-MessageData @{
|
||||
Trigger = $oneShotTrigger;
|
||||
Identifier = $identifier;
|
||||
};
|
||||
|
||||
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "Starting OneShot task ``$(Get-OneShotTask)``…";
|
||||
Remove-Event -EventIdentifier (Wait-Event -SourceIdentifier $identifier).EventIdentifier;
|
||||
$null = Wait-Event -SourceIdentifier $identifier;
|
||||
};
|
||||
|
||||
Set-Stage $currentStage;
|
||||
|
||||
if (Test-Path $errorPath) {
|
||||
$errorMessage = Get-Content $errorPath;
|
||||
Remove-Item $errorPath;
|
||||
throw $errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
# ToDo: Store Run-OneShot and Receive-OneShot somewhere else in Windows folder
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Executes the specified action and notifies the OneShot task executor.
|
||||
#>
|
||||
function Start-OneShot {
|
||||
param(
|
||||
[scriptblock] $Action
|
||||
)
|
||||
|
||||
try {
|
||||
Start-Operation @PSBoundParameters;
|
||||
}
|
||||
catch {
|
||||
Set-Content -Path $errorPath -Value $Error;
|
||||
}
|
||||
finally {
|
||||
Set-Stage ([SetupStage]::Idle);
|
||||
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "The OneShot task ``$(Get-OneShotTask)`` finished.";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -42,7 +42,7 @@ $null = New-Module {
|
|||
}
|
||||
|
||||
if ($Names.Count -ge 1) {
|
||||
choco install -y $ArgumentList $Names;
|
||||
choco install -y @ArgumentList @Names;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ $null = New-Module {
|
|||
)
|
||||
|
||||
[InstallerAction] $Action = & {
|
||||
if ($Action.HasValue) {
|
||||
if ($null -ne $Action) {
|
||||
$Action;
|
||||
} else {
|
||||
[InstallerAction]::Install;
|
||||
|
@ -253,8 +253,8 @@ $null = New-Module {
|
|||
& $installHandler @argumentList;
|
||||
}
|
||||
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
|
||||
if ((-not $Arguments.ContainsKey($userArgument)) -or ($null -eq $Arguments[$userArgument])) {
|
||||
$argumentList.Add($userArgument, ($env:UserName));
|
||||
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
|
||||
$Arguments.Add($userArgument, ($env:UserName));
|
||||
}
|
||||
|
||||
if ($UserConfigurator) {
|
||||
|
|
18
scripts/Common/Software/git/Manage.ps1
Normal file
18
scripts/Common/Software/git/Manage.ps1
Normal file
|
@ -0,0 +1,18 @@
|
|||
param (
|
||||
$Action,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
||||
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
||||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
-Installer {
|
||||
param(
|
||||
[scriptblock] $Installer
|
||||
)
|
||||
|
||||
& $Installer -Action ([InstallerAction]::Configure);
|
||||
} `
|
||||
-Configurator {
|
||||
};
|
3
scripts/Common/Types/OneShotTask.ps1
Normal file
3
scripts/Common/Types/OneShotTask.ps1
Normal file
|
@ -0,0 +1,3 @@
|
|||
enum OneShotTask {
|
||||
DisableUAC
|
||||
}
|
|
@ -4,7 +4,7 @@ param(
|
|||
)
|
||||
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||
. "$PSScriptRoot/../../Scripts/System.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
-Installer {
|
||||
|
|
|
@ -3,7 +3,9 @@ param(
|
|||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$null = New-Module {
|
||||
& {
|
||||
param($parameters);
|
||||
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||
$softwarePath = "$PSScriptRoot/../../Software";
|
||||
|
||||
|
@ -12,17 +14,17 @@ $null = New-Module {
|
|||
"$softwarePath/TobiiGameHub/Manage.ps1"
|
||||
);
|
||||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
Start-SoftwareInstaller @parameters `
|
||||
-Installer {
|
||||
Install-SetupPackage -Source "https://files.update.tech.tobii.com/Tobii_Eye_Tracking_Core_v2.16.8.214_x86.exe";
|
||||
|
||||
foreach ($script in $appScripts) {
|
||||
. $script @PSBoundParameters;
|
||||
. $script @parameters;
|
||||
}
|
||||
} `
|
||||
-UserConfigurator {
|
||||
foreach ($script in $appScripts) {
|
||||
. $script @PSBoundParameters;
|
||||
. $script @parameters;
|
||||
}
|
||||
};
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
|
@ -98,7 +98,7 @@ $null = New-Module {
|
|||
if (-not (& { $null = wsl -l; $?; })) {
|
||||
$wslRoot = Split-Path -Parent $wslLocation;
|
||||
|
||||
if (-not (Test-Path -PathType $wslRoot)) {
|
||||
if (-not (Test-Path $wslRoot)) {
|
||||
$null = New-Item -ItemType Directory $wslRoot;
|
||||
}
|
||||
|
||||
|
@ -133,6 +133,21 @@ $null = New-Module {
|
|||
Set-Stage ([SetupStage]::Configure);
|
||||
break;
|
||||
}
|
||||
([SetupStage]::OneShot) {
|
||||
Write-Host "Running a OneShot task";
|
||||
|
||||
Start-OneShot {
|
||||
Write-Host "task is-a running!";
|
||||
switch (Get-OneShotTask) {
|
||||
([OneShotTask]::DisableUAC) {
|
||||
Disable-UAC;
|
||||
Register-Setup;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
default {
|
||||
if (-not (& { $null = wsl -l; $? })) {
|
||||
wsl --import-in-place "PortValhalla" "$wslLocation/ext4.vhdx";
|
||||
|
@ -161,13 +176,13 @@ $null = New-Module {
|
|||
#>
|
||||
function Deploy-SoftwareAction {
|
||||
param(
|
||||
[InstallerAction] $Action
|
||||
[InstallerAction] $Action = $null
|
||||
)
|
||||
|
||||
[bool] $install = $null;
|
||||
$arguments = [hashtable]@{ };
|
||||
|
||||
if ($Action) {
|
||||
if ($null -ne $Action) {
|
||||
$install = ($Action -eq ([InstallerAction]::Install));
|
||||
$null = $arguments.Add("action", $Action);
|
||||
} else {
|
||||
|
@ -175,7 +190,7 @@ $null = New-Module {
|
|||
}
|
||||
|
||||
# Drivers
|
||||
$null = New-Module {
|
||||
& {
|
||||
$driverPath = "$PSScriptRoot/../Drivers";
|
||||
$mbPath = "$driverPath/ROG Zenith Extreme Alpha";
|
||||
|
||||
|
@ -183,14 +198,14 @@ $null = New-Module {
|
|||
|
||||
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;
|
||||
& "$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;
|
||||
& "$driverPath/Predator Z301C/Manage.ps1" @arguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,29 +236,29 @@ $null = New-Module {
|
|||
}
|
||||
|
||||
if (Get-Config "valhalla.hardware.eyeX") {
|
||||
. "$driverPath/Tobii EyeX/Manage.ps1" @arguments;
|
||||
& "$driverPath/Tobii EyeX/Manage.ps1" @arguments;
|
||||
}
|
||||
};
|
||||
|
||||
$null = New-Module {
|
||||
& {
|
||||
# Windows Config
|
||||
$softwarePath = "$PSScriptRoot/../Software";
|
||||
$commonSoftware = "$PSScriptRoot/../../Common/Software";
|
||||
. "$softwarePath/Windows/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Windows/Manage.ps1" @arguments;
|
||||
|
||||
if (Get-Config "valhalla.hardware.logitechG") {
|
||||
. "$softwarePath/LGHub/Manage.ps1" @arguments;
|
||||
& "$softwarePath/LGHub/Manage.ps1" @arguments;
|
||||
}
|
||||
|
||||
if (Test-Collection "essential") {
|
||||
# Essentials
|
||||
. "$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;
|
||||
. "$commonSoftware/Oh My Posh/Manage.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;
|
||||
& "$commonSoftware/Oh My Posh/Manage.ps1" @arguments;
|
||||
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
|
@ -259,9 +274,9 @@ $null = New-Module {
|
|||
|
||||
if (Test-Collection "common") {
|
||||
# Common Software
|
||||
. "$softwarePath/WinSCP/Manage.ps1" @arguments;
|
||||
. "$softwarePath/Thunderbird/Manage.ps1" @arguments;
|
||||
. "$softwarePath/PuTTY/Manage.ps1" @arguments;
|
||||
& "$softwarePath/WinSCP/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Thunderbird/Manage.ps1" @arguments;
|
||||
& "$softwarePath/PuTTY/Manage.ps1" @arguments;
|
||||
|
||||
if ($install) {
|
||||
Install-ChocoPackage `
|
||||
|
@ -325,14 +340,14 @@ $null = New-Module {
|
|||
}
|
||||
|
||||
# ToDo: Consider hiding behind own config?
|
||||
. "$softwarePath/Ubiquiti UniFi Controller/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Ubiquiti UniFi Controller/Manage.ps1" @arguments;
|
||||
|
||||
# Internet Access
|
||||
. "$softwarePath/Firefox/Manage.ps1" @arguments;
|
||||
. "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Firefox/Manage.ps1" @arguments;
|
||||
& "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments;
|
||||
|
||||
if (Test-Collection "fileSync") {
|
||||
. "$softwarePath/Nextcloud/Manage.ps1" @arguments;
|
||||
& "$softwarePath/Nextcloud/Manage.ps1" @arguments;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,10 +402,10 @@ $null = New-Module {
|
|||
Remove-DesktopIcon "Docker*";
|
||||
}
|
||||
|
||||
. "$softwarePath/VisualStudio/Manage.ps1" @arguments;
|
||||
& "$softwarePath/VisualStudio/Manage.ps1" @arguments;
|
||||
|
||||
# Node.js
|
||||
. "$softwarePath/NVS/Manage.ps1" @arguments;
|
||||
& "$softwarePath/NVS/Manage.ps1" @arguments;
|
||||
}
|
||||
|
||||
if (Test-Collection "gaming") {
|
||||
|
@ -415,13 +430,13 @@ $null = New-Module {
|
|||
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;
|
||||
& "$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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -433,10 +448,17 @@ $null = New-Module {
|
|||
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-ItemProperty $timeZoneKey -Name $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;
|
||||
|
@ -475,9 +497,14 @@ $null = New-Module {
|
|||
|
||||
if ($currentUser -lt $users.Count) {
|
||||
$user = Get-LocalUser $users[$currentUser];
|
||||
$msAccount = Get-UserConfig -UserName "$user" -Name "microsoftAccount";
|
||||
|
||||
$adminGroup = @{
|
||||
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||
};
|
||||
|
||||
Add-LocalGroupMember `
|
||||
-SID ([SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null))`
|
||||
@adminGroup `
|
||||
$user `
|
||||
-ErrorAction SilentlyContinue;
|
||||
|
||||
|
@ -485,19 +512,46 @@ $null = New-Module {
|
|||
Disable-LocalUser $env:UserName;
|
||||
Enable-LocalUser $user;
|
||||
|
||||
if (Get-UserConfig -UserName "$user" -Name "microsoftAccount") {
|
||||
if ($msAccount) {
|
||||
Enable-UAC;
|
||||
Disable-Autologin;
|
||||
Set-BootMessage -Caption "Login" -Message "Please login using your account.";
|
||||
Enable-OneShotListener;
|
||||
Set-BootMessage -Caption "Please Log In" -Message "Please log in using your new Microsoft Account ``$user``.";
|
||||
} else {
|
||||
Set-AutologinUser "$user";
|
||||
}
|
||||
|
||||
Restart-Intermediate -DefaultUser;
|
||||
return;
|
||||
} else {
|
||||
$configure = {
|
||||
Deploy-SoftwareAction -Action ([InstallerAction]::ConfigureUser);
|
||||
Remove-LocalGroupMember -Member "$user" @adminGroup -ErrorAction SilentlyContinue;
|
||||
|
||||
foreach ($group in Get-UserConfig "groups") {
|
||||
Add-LocalGroupMember -Member "$user" -Name "$group";
|
||||
}
|
||||
}
|
||||
|
||||
if ($msAccount) {
|
||||
if (-not (Test-Admin)) {
|
||||
Invoke-OneShot DisableUAC;
|
||||
Restart-Computer;
|
||||
return;
|
||||
} else {
|
||||
& $configure;
|
||||
Clear-SetupRegistration;
|
||||
Disable-OneShotListener;
|
||||
}
|
||||
} else {
|
||||
& $configure;
|
||||
}
|
||||
}
|
||||
|
||||
Set-CurrentUser ($currentUser + 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
Set-IsFinished $true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,32 @@ $null = New-Module {
|
|||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Generates a script for executing the installer.
|
||||
#>
|
||||
function Get-StartupScript {
|
||||
"pwsh " + (Get-StartupArguments);
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Generates arguments for running the installer using `pwsh`.
|
||||
#>
|
||||
function Get-StartupArguments {
|
||||
"-Command " +
|
||||
(& {
|
||||
if ($env:PWSH_PATH) {
|
||||
"`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}) +
|
||||
"`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +
|
||||
"`$env:CONFIG_MODULE = $(ConvertTo-Injection (Resolve-Path $env:CONFIG_MODULE));" +
|
||||
"& `$env:INSTALLER_SCRIPT;"
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Registers a task to run the setup once after the next reboot.
|
||||
|
@ -49,13 +75,14 @@ $null = New-Module {
|
|||
param(
|
||||
[Parameter(ParameterSetName="System")]
|
||||
[switch] $System,
|
||||
[Parameter(ParameterSetName="User",Mandatory)]
|
||||
[Parameter(ParameterSetName="User", Mandatory)]
|
||||
[switch] $User,
|
||||
[Parameter(Mandatory)]
|
||||
[Parameter(ParameterSetName="User")]
|
||||
[Parameter(ParameterSetName="SpecificUser", Mandatory)]
|
||||
[RegistryKey] $UserKey
|
||||
)
|
||||
|
||||
if ($User.IsPresent) {
|
||||
if ($User.IsPresent -or $UserKey) {
|
||||
if (-not $UserKey) {
|
||||
$UserKey = Get-Item "HKCU:\";
|
||||
}
|
||||
|
@ -65,23 +92,25 @@ $null = New-Module {
|
|||
$key = Get-RunOnceKey;
|
||||
}
|
||||
|
||||
Set-ItemProperty -Path $key.PSPath -Name $runOnceName -Type "ExpandString" -Value (
|
||||
"pwsh -Command " +
|
||||
(& {
|
||||
if ($env:PWSH_PATH) {
|
||||
"`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}) +
|
||||
"`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +
|
||||
"`$env:CONFIG_MODULE = $(ConvertTo-Injection $env:CONFIG_MODULE);" +
|
||||
"& `$env:INSTALLER_SCRIPT;"
|
||||
);
|
||||
|
||||
Set-ItemProperty -Path $key.PSPath -Name $runOnceName -Type "ExpandString" -Value (Get-StartupScript);
|
||||
$key.Handle.Close();
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Clears leftovers from past registrations.
|
||||
#>
|
||||
function Clear-SetupRegistration {
|
||||
Edit-DefaultUserKey {
|
||||
param(
|
||||
[RegistryKey] $Key
|
||||
)
|
||||
|
||||
$runOnceKey = Get-RunOnceKey $Key;
|
||||
Remove-Item $runOnceKey.PSPath;
|
||||
}
|
||||
}
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Sets the user to login automatically on boot.
|
||||
|
@ -94,7 +123,7 @@ $null = New-Module {
|
|||
[string] $Name
|
||||
)
|
||||
|
||||
Set-ItemProperty $autologinOption -Name $autologinOption "1";
|
||||
Set-ItemProperty $logonPath -Name $autologinOption "1";
|
||||
|
||||
if (-not $Name) {
|
||||
$Name = Get-SetupUser;
|
||||
|
@ -107,16 +136,7 @@ $null = New-Module {
|
|||
};
|
||||
|
||||
foreach ($key in $options.Keys) {
|
||||
Set-ItemProperty -Name $key
|
||||
$displayName = Get-UserConfig -UserName $name "displayName";
|
||||
|
||||
$userArguments = @{
|
||||
name = $name;
|
||||
};
|
||||
|
||||
if ($displayName) {
|
||||
$userArguments.fullName = $displayName;
|
||||
} -Value $options[$key];
|
||||
Set-ItemProperty $logonPath -Name $key -Value $options[$key];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +175,6 @@ $null = New-Module {
|
|||
& $register;
|
||||
}
|
||||
|
||||
Read-Host "Press enter to reboot";
|
||||
Restart-Computer -Force;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ $null = New-Module {
|
|||
Creates the configured users.
|
||||
#>
|
||||
function Start-ValhallaUserSetup {
|
||||
[int] $current = Get-SetupOption $userOption;
|
||||
[string[]] $users = Get-Users;
|
||||
|
||||
function Add-MicrosoftAccount {
|
||||
|
@ -108,7 +107,7 @@ $null = New-Module {
|
|||
Rename-LocalUser $newUser $Name;
|
||||
}
|
||||
|
||||
for ($i = $current ?? 0; $i -lt $users.Count; $i++) {
|
||||
for ($i = 0; $i -lt $users.Count; $i++) {
|
||||
Set-SetupOption $userOption $i;
|
||||
$name = $users[$i];
|
||||
Write-Host "Creating personal user ``$name``…";
|
||||
|
|
|
@ -9,32 +9,6 @@ Start-SoftwareInstaller @PSBoundParameters `
|
|||
-Installer {
|
||||
Install-ChocoPackage nextcloud-client -ArgumentList "-y","--params='/KeepUpdateCheck'";
|
||||
} `
|
||||
-Configurator {
|
||||
Write-Host "Making Firefox the default browser…";
|
||||
$progIdSuffix = "-308046B0AF4A39CB";
|
||||
$appName = "Firefox";
|
||||
|
||||
$extensions = @(
|
||||
".htm",
|
||||
".html",
|
||||
".svg",
|
||||
".xht",
|
||||
".xhtml"
|
||||
);
|
||||
|
||||
$schemes = @(
|
||||
"http",
|
||||
"https"
|
||||
);
|
||||
|
||||
foreach ($extension in $extensions) {
|
||||
Set-DefaultAppAssociation -Identifier $extensions -ProgId "${appName}HTML$progIdSuffix" -ApplicationName $appName;
|
||||
}
|
||||
|
||||
foreach ($scheme in $schemes) {
|
||||
Set-DefaultAppAssociation -Identifier $scheme -ProgId "${appName}URL$progIdSuffix" -ApplicationName $appName;
|
||||
}
|
||||
} `
|
||||
-UserConfigurator {
|
||||
if (-not (Test-Path $context.GetNextcloudConfigFile())) {
|
||||
Write-Information "Setting up Nextcloud configuration";
|
||||
|
|
|
@ -3,7 +3,9 @@ param(
|
|||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
$null = New-Module {
|
||||
& {
|
||||
param($parameters)
|
||||
|
||||
. "$PSScriptRoot/../../../Common/Scripts/BrowserAutomation.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||
|
@ -15,7 +17,7 @@ $null = New-Module {
|
|||
[System.Tuple]::Create("visualstudio2022community", "VisualStudio.17.Release", "Microsoft.VisualStudio.Product.Community")
|
||||
);
|
||||
|
||||
Start-SoftwareInstaller @PSBoundParameters `
|
||||
Start-SoftwareInstaller @parameters `
|
||||
-Installer {
|
||||
foreach ($version in $versions) {
|
||||
$packageName = $version[0];
|
||||
|
@ -29,4 +31,4 @@ $null = New-Module {
|
|||
|
||||
# ToDo: Add restoration
|
||||
# Only restore version if it has been backed up
|
||||
};
|
||||
} $PSBoundParameters;
|
||||
|
|
64
scripts/Windows/Software/git/Manage.ps1
Normal file
64
scripts/Windows/Software/git/Manage.ps1
Normal file
|
@ -0,0 +1,64 @@
|
|||
param (
|
||||
$Action,
|
||||
[hashtable] $Arguments
|
||||
)
|
||||
|
||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||
. "$PSScriptRoot/../../../Common/Scripts/Config.ps1";
|
||||
|
||||
$null = New-Module {
|
||||
param(
|
||||
[hashtable] $Parameters
|
||||
)
|
||||
|
||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a configuration value related to git.
|
||||
|
||||
.PARAMETER Name
|
||||
The name of the configuration to get.
|
||||
|
||||
.PARAMETER User
|
||||
The name of the user to get the configuration for.
|
||||
#>
|
||||
function Get-GitOption {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string] $Name,
|
||||
[string] $User
|
||||
)
|
||||
|
||||
$config = "git.$Name";
|
||||
|
||||
if ($User) {
|
||||
Get-UserConfig -UserName $User -Name $config;
|
||||
} else {
|
||||
Get-Config $config;
|
||||
}
|
||||
}
|
||||
|
||||
Start-SoftwareInstaller @Parameters `
|
||||
-Installer {
|
||||
param(
|
||||
[scriptblock] $Installer
|
||||
)
|
||||
|
||||
$params = "/WindowsTerminalProfile";
|
||||
$defaultBranch = Get-GitOption "defaultBranch";
|
||||
|
||||
if ($defaultBranch) {
|
||||
$params += " /DefaultBranchName:`"$defaultBranch`"";
|
||||
}
|
||||
|
||||
Install-ChocoPackage git -ArgumentList "--params",$params;
|
||||
& $Installer -Action ([InstallerAction]::Configure);
|
||||
} `
|
||||
-Configurator {
|
||||
& "$PSScriptRoot/../../../Common/Software/git/Manage.ps1" @Parameters;
|
||||
};
|
||||
|
||||
Export-ModuleMember -Function @();
|
||||
} -ArgumentList $PSBoundParameters
|
Loading…
Reference in a new issue