Add scripts for installing essential software

This commit is contained in:
Manuel Thalmann 2024-08-06 00:04:02 +02:00
parent 348b1a00bc
commit 6997a800b9
4 changed files with 84 additions and 1 deletions

View file

@ -115,9 +115,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 {}
}
}
}

View file

@ -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.

View file

@ -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;
};

View file

@ -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";
};