diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 312a027e..5f1d14a8 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -114,9 +114,17 @@ $null = New-Module { } ([SetupStage]::Install) { Write-Host "Entering install phase"; + + # Windows Config + . "$PSScriptRoot/../Software/Windows/Manage.ps1"; + + if (Test-Collection "essential") { + # Essentials + . "$PSScriptRoot/../Software/OpenSSH/Manage.ps1"; + } + Set-IsFinished $true; } - Default {} } } } diff --git a/scripts/Windows/Scripts/Config.ps1 b/scripts/Windows/Scripts/Config.ps1 index 564c6d7a..26f24c0e 100644 --- a/scripts/Windows/Scripts/Config.ps1 +++ b/scripts/Windows/Scripts/Config.ps1 @@ -199,6 +199,21 @@ $null = New-Module { Set-SetupOption $finishedOption $true; } + <# + .SYNOPSIS + Checks whether the specified software collection is enabled. + + .PARAMETER Name + The name of the collection to check. + #> + function Test-Collection { + param( + [string] $Name + ) + + Get-Config "valhalla.software.$Name"; + } + <# .SYNOPSIS Checks whether the active session is executed with admin rights. diff --git a/scripts/Windows/Software/OpenSSH/Manage.ps1 b/scripts/Windows/Software/OpenSSH/Manage.ps1 new file mode 100644 index 00000000..43507671 --- /dev/null +++ b/scripts/Windows/Software/OpenSSH/Manage.ps1 @@ -0,0 +1,20 @@ +using namespace Microsoft.Win32; + +param( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../../Scripts/Software.ps1"; + +Start-SoftwareInstaller @PSBoundParameters ` + -Installer { + param( + [scriptblock] $Installer + ) + + & $Installer -Action ([InstallerAction]::Configure) + } ` + -Configurator { + Set-Service ssh-agent -StartupType AutomaticDelayedStart; + }; diff --git a/scripts/Windows/Software/chocolatey/Manage.ps1 b/scripts/Windows/Software/chocolatey/Manage.ps1 new file mode 100644 index 00000000..d48becad --- /dev/null +++ b/scripts/Windows/Software/chocolatey/Manage.ps1 @@ -0,0 +1,40 @@ +using namespace Microsoft.Win32; + +param( + $Action, + [hashtable] $Arguments +) + +. "$PSScriptRoot/../../Scripts/Software.ps1"; + +Start-SoftwareInstaller @PSBoundParameters ` + -Installer { + param( + [scriptblock] $Installer + ) + + & $Installer -Action ([InstallerAction]::Configure) + } ` + -Configurator { + $nativeProfile = powershell -c '$PROFILE'; + New-Item -Force $nativeProfile; + choco install -y --force chocolatey; + Copy-Item -Force $nativeProfile $PROFILE; + + Push-Location ~; + $files = @($nativeProfile, $PROFILE) | ForEach-Object { Resolve-Path -Relative $_ }; + Pop-Location; + + foreach ($path in $files) { + $fullName = "$env:SystemDrive/Users/Default/$path"; + $dirName = Split-Path -Parent $fullName; + + if (-not (Test-Path -PathType Container $dirName)) { + $null = New-Item -Force -ItemType Directory $dirName; + } + + Copy-Item -Force ~/"$path" $fullName; + } + + Import-Module "$env:ChocolateyInstall/helpers/chocolateyProfile.psm1"; + };