From 2da5240d3fd8db50fbad82df934621fc93493589 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 27 Aug 2024 16:41:08 +0200 Subject: [PATCH] Create dedicated script for installing software --- scripts/Windows/OS/Install.ps1 | 289 +----------------------- scripts/Windows/Scripts/Deployment.ps1 | 294 +++++++++++++++++++++++++ 2 files changed, 295 insertions(+), 288 deletions(-) create mode 100644 scripts/Windows/Scripts/Deployment.ps1 diff --git a/scripts/Windows/OS/Install.ps1 b/scripts/Windows/OS/Install.ps1 index 77d88ec6..244157ec 100644 --- a/scripts/Windows/OS/Install.ps1 +++ b/scripts/Windows/OS/Install.ps1 @@ -11,6 +11,7 @@ using namespace System.Security.Principal; . "$PSScriptRoot/../../Common/Scripts/Context.ps1"; $null = New-Module { + . "$PSScriptRoot/../Scripts/Deployment.ps1"; . "$PSScriptRoot/../Scripts/Hooks.ps1"; . "$PSScriptRoot/../Scripts/PowerManagement.ps1"; . "$PSScriptRoot/../Scripts/Registry.ps1"; @@ -52,294 +53,6 @@ $null = New-Module { } } - <# - .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/git/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; - & "$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) { - - Install-ChocoPackage ` - gh ` - github-desktop ` - ida-free ` - HxD ` - docker-desktop ` - imhex ` - dotpeek ` - ; - - Remove-DesktopIcon "IDA *"; - Remove-DesktopIcon "GitHub*"; - Remove-DesktopIcon "Docker*"; - } - - & "$softwarePath/vscode/Main.ps1" @arguments; - & "$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 (Get-Stage) { ($null) { Set-Stage ([SetupStage]::Configure); diff --git a/scripts/Windows/Scripts/Deployment.ps1 b/scripts/Windows/Scripts/Deployment.ps1 new file mode 100644 index 00000000..f505a44c --- /dev/null +++ b/scripts/Windows/Scripts/Deployment.ps1 @@ -0,0 +1,294 @@ +. "$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/git/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; + & "$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) { + + Install-ChocoPackage ` + gh ` + github-desktop ` + ida-free ` + HxD ` + docker-desktop ` + imhex ` + dotpeek ` + ; + + Remove-DesktopIcon "IDA *"; + Remove-DesktopIcon "GitHub*"; + Remove-DesktopIcon "Docker*"; + } + + & "$softwarePath/vscode/Main.ps1" @arguments; + & "$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; + } + }; +}