Compare commits
65 commits
7a20aed42a
...
4969177431
Author | SHA1 | Date | |
---|---|---|---|
Manuel Thalmann | 4969177431 | ||
Manuel Thalmann | 6a295cf0b8 | ||
Manuel Thalmann | 40aacc3b7b | ||
Manuel Thalmann | 994b0d71b2 | ||
Manuel Thalmann | 08c5369260 | ||
Manuel Thalmann | 3b10e5b30d | ||
Manuel Thalmann | b2a485ff48 | ||
Manuel Thalmann | 2616c10f88 | ||
Manuel Thalmann | 35926f7fb2 | ||
Manuel Thalmann | df1eebd9c0 | ||
Manuel Thalmann | a36f134f64 | ||
Manuel Thalmann | 06d2b4e26a | ||
Manuel Thalmann | 9e2ae31575 | ||
Manuel Thalmann | 61ac127339 | ||
Manuel Thalmann | 4e8f8e9aec | ||
Manuel Thalmann | 939f573ffd | ||
Manuel Thalmann | 19ff0fcd25 | ||
Manuel Thalmann | 56aafd40c1 | ||
Manuel Thalmann | a4024e165f | ||
Manuel Thalmann | 9c219d4e75 | ||
Manuel Thalmann | 6b411c1b3f | ||
Manuel Thalmann | d6352802bc | ||
Manuel Thalmann | 63ec4dc30a | ||
Manuel Thalmann | 97016a8dd4 | ||
Manuel Thalmann | 132619ace5 | ||
Manuel Thalmann | 136adc8209 | ||
Manuel Thalmann | 6613ebd6b5 | ||
Manuel Thalmann | ccb8529e5f | ||
Manuel Thalmann | 632bb3fa5b | ||
Manuel Thalmann | ac2ca2e89f | ||
Manuel Thalmann | b3a739f2fc | ||
Manuel Thalmann | d65696aa2b | ||
Manuel Thalmann | 1f40489b68 | ||
Manuel Thalmann | 0f3ee1ece0 | ||
Manuel Thalmann | 38b1ed2fdc | ||
Manuel Thalmann | afb9421066 | ||
Manuel Thalmann | f0d5716b4a | ||
Manuel Thalmann | 7021ea4cda | ||
Manuel Thalmann | 010a1b0012 | ||
Manuel Thalmann | 591531c3c0 | ||
Manuel Thalmann | 5bc61af552 | ||
Manuel Thalmann | f8b16059a7 | ||
Manuel Thalmann | f0bf91790f | ||
Manuel Thalmann | 4dd1b04ec5 | ||
Manuel Thalmann | 6d96904dc4 | ||
Manuel Thalmann | 73b3dcaf91 | ||
Manuel Thalmann | 31a81ca7a9 | ||
Manuel Thalmann | 145da7d37e | ||
Manuel Thalmann | 40a6fbc8ff | ||
Manuel Thalmann | 6c4cdbe9eb | ||
Manuel Thalmann | 09e2455571 | ||
Manuel Thalmann | 6dbace2f4f | ||
Manuel Thalmann | be1e205b4f | ||
Manuel Thalmann | 510ede6394 | ||
Manuel Thalmann | 3e071ff3ce | ||
Manuel Thalmann | d975747190 | ||
Manuel Thalmann | ed063c7208 | ||
Manuel Thalmann | fa43cbdfc7 | ||
Manuel Thalmann | 87adddb054 | ||
Manuel Thalmann | ef626736b5 | ||
Manuel Thalmann | f321f7bebc | ||
Manuel Thalmann | ecdff5fab1 | ||
Manuel Thalmann | 2ea60dfe4d | ||
Manuel Thalmann | abb3da7e48 | ||
Manuel Thalmann | ea74ec0cbb |
|
@ -10,7 +10,21 @@
|
||||||
type = types.submodule (
|
type = types.submodule (
|
||||||
{ extendModules, ... }:
|
{ extendModules, ... }:
|
||||||
let
|
let
|
||||||
osVariant = extendModules { };
|
osVariant = extendModules {
|
||||||
|
modules = [
|
||||||
|
({ config, ... }: {
|
||||||
|
options = {
|
||||||
|
config = mkOption {
|
||||||
|
type = types.attrs;
|
||||||
|
description = "The configuration of the Operating System.";
|
||||||
|
default = builtins.removeAttrs config ["_module" "config" "linux" "windows"];
|
||||||
|
visible = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
linuxVariant = osVariant.extendModules { };
|
linuxVariant = osVariant.extendModules { };
|
||||||
windowsVariant = osVariant.extendModules { };
|
windowsVariant = osVariant.extendModules { };
|
||||||
in {
|
in {
|
||||||
|
|
44
lib/modules/packages/nextcloud.nix
Normal file
44
lib/modules/packages/nextcloud.nix
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkEnableOption
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
|
syncType = types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
remotePath = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The path to the folder on the cloud to sync.";
|
||||||
|
};
|
||||||
|
|
||||||
|
localPath = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The path to sync the cloud content to.";
|
||||||
|
};
|
||||||
|
|
||||||
|
virtualFiles = (mkEnableOption "virtual file support") // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
valhalla.windows.users = mkOption {
|
||||||
|
type = types.attrsOf (types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
nextcloud = {
|
||||||
|
folderSyncs = mkOption {
|
||||||
|
type = types.listOf syncType;
|
||||||
|
description = "The folders to synchronize.";
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,11 +1,10 @@
|
||||||
{ config, lib, ... }:
|
{ lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkOption
|
mkOption
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
cfg = config.valhalla;
|
|
||||||
capitalize = (import ../text.nix { inherit lib; }).capitalize;
|
capitalize = (import ../text.nix { inherit lib; }).capitalize;
|
||||||
|
|
||||||
userType = types.submodule (
|
userType = types.submodule (
|
||||||
|
@ -65,18 +64,27 @@
|
||||||
type = types.attrsOf linuxUserType;
|
type = types.attrsOf linuxUserType;
|
||||||
};
|
};
|
||||||
|
|
||||||
windows.users = mkOption {
|
windows = mkOption {
|
||||||
type = types.attrsOf winUserType;
|
type = types.submoduleWith {
|
||||||
|
modules = [
|
||||||
|
({ config, options, ... }: {
|
||||||
|
options = {
|
||||||
|
users = mkOption {
|
||||||
|
type = types.attrsOf winUserType;
|
||||||
|
};
|
||||||
|
|
||||||
|
winUsers = mkOption {
|
||||||
|
type = options.users.type;
|
||||||
|
default = (lib.attrsets.concatMapAttrs (
|
||||||
|
name: options: {
|
||||||
|
${capitalize name} = options;
|
||||||
|
}) config.users);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
|
||||||
valhalla.windows.users = lib.mkForce (lib.attrsets.concatMapAttrs (
|
|
||||||
name: options: {
|
|
||||||
${capitalize name} = options // {
|
|
||||||
groups = [];
|
|
||||||
};
|
|
||||||
}) cfg.users);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./packages/git.nix
|
./packages/git.nix
|
||||||
|
./packages/nextcloud.nix
|
||||||
./packages/oh-my-posh.nix
|
./packages/oh-my-posh.nix
|
||||||
./packages/rclone.nix
|
./packages/rclone.nix
|
||||||
./hardware.nix
|
./hardware.nix
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkOption
|
mkDefault
|
||||||
mkEnableOption
|
mkEnableOption
|
||||||
mkIf
|
mkIf
|
||||||
|
mkOption
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -39,8 +40,8 @@
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
valhalla.windows = {
|
valhalla.windows = {
|
||||||
setupUser.name = capitalize config.valhalla.setupUser.name;
|
setupUser.name = mkDefault (capitalize config.valhalla.setupUser.name);
|
||||||
dualboot.linuxPercentage = mkIf (!config.valhalla.windows.dualboot.enable) 0;
|
dualboot.linuxPercentage = mkIf (!config.valhalla.windows.dualboot.enable) (mkDefault 0);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/pwsh
|
#!/bin/pwsh
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
. "$PSScriptRoot/../../../scripts/Common/Scripts/Context.ps1";
|
. "$PSScriptRoot/../../../scripts/Common/Scripts/Context.ps1";
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/OS/Manage.ps1";
|
. "$PSScriptRoot/../../../scripts/Windows/OS/Legacy.ps1";
|
||||||
|
|
||||||
Write-Host "Starting Backup of Windows";
|
Write-Host "Starting Backup of Windows";
|
||||||
$context = [Context]::new();
|
$context = [Context]::new();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
. "$PSScriptRoot/Drivers.ps1";
|
. "$PSScriptRoot/Drivers.ps1";
|
||||||
. "$PSScriptRoot/../../../scripts/Common/Scripts/Context.ps1";
|
. "$PSScriptRoot/../../../scripts/Common/Scripts/Context.ps1";
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/Collections/Personal.ps1"
|
. "$PSScriptRoot/../../../scripts/Windows/Collections/Personal.ps1"
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1";
|
. "$PSScriptRoot/../../../scripts/Windows/OS/Manage.ps1";
|
||||||
|
|
||||||
function Initialize-Configuration {
|
function Initialize-Configuration {
|
||||||
# Fix synchronization between Linux and Windows clock
|
# Fix synchronization between Linux and Windows clock
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
linuxPercentage = 30;
|
linuxPercentage = 30;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.Manuel = {
|
users.manuel = {
|
||||||
microsoftAccount = true;
|
microsoftAccount = true;
|
||||||
groups = ["Administrators"];
|
groups = ["Administrators"];
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/pwsh
|
#!/bin/pwsh
|
||||||
. "$PSScriptRoot/../../../scripts/Common/Scripts/Context.ps1";
|
. "$PSScriptRoot/../../../scripts/Common/Scripts/Context.ps1";
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/OS/Install.ps1";
|
. "$PSScriptRoot/../../../scripts/Windows/OS/Manage.ps1";
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/Collections/Generic.ps1"
|
. "$PSScriptRoot/../../../scripts/Windows/Collections/Generic.ps1"
|
||||||
|
|
||||||
function Restore-Apps {
|
function Restore-Apps {
|
||||||
|
|
|
@ -40,17 +40,17 @@
|
||||||
manuel = {
|
manuel = {
|
||||||
displayName = "Manuel Thalmann";
|
displayName = "Manuel Thalmann";
|
||||||
mailAddress = "m@nuth.ch";
|
mailAddress = "m@nuth.ch";
|
||||||
|
|
||||||
groups = [
|
|
||||||
"wheel"
|
|
||||||
"nix-users"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
linux.users.manuel = {
|
linux.users.manuel = {
|
||||||
defaultShell = "fish";
|
defaultShell = "fish";
|
||||||
|
|
||||||
|
groups = [
|
||||||
|
"wheel"
|
||||||
|
"nix-users"
|
||||||
|
];
|
||||||
|
|
||||||
rclone = {
|
rclone = {
|
||||||
configurations = {
|
configurations = {
|
||||||
nextcloud = {
|
nextcloud = {
|
||||||
|
@ -63,6 +63,30 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
windows.users.manuel = {
|
||||||
|
groups = [
|
||||||
|
"Administrators"
|
||||||
|
];
|
||||||
|
|
||||||
|
nextcloud = {
|
||||||
|
folderSyncs =
|
||||||
|
let
|
||||||
|
localPath = "C:/tools/RetroArch-Win64";
|
||||||
|
remotePath = "/Saved Games/RetroArch";
|
||||||
|
in [
|
||||||
|
{
|
||||||
|
remotePath = "${remotePath}/Saves";
|
||||||
|
localPath = "${localPath}/saves";
|
||||||
|
virtualFiles = false;
|
||||||
|
}
|
||||||
|
{
|
||||||
|
remotePath = "${remotePath}/System";
|
||||||
|
localPath = "${localPath}/system";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
timeZone = "Europe/Zurich";
|
timeZone = "Europe/Zurich";
|
||||||
keyMap = "de_CH-latin1";
|
keyMap = "de_CH-latin1";
|
||||||
keyboardLayout = "ch";
|
keyboardLayout = "ch";
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
valhalla.users.manuel = {
|
imports = [
|
||||||
oh-my-posh = {
|
../../lib/modules/valhalla.nix
|
||||||
theme = {
|
];
|
||||||
source = ./manuel.omp.json;
|
|
||||||
|
config = {
|
||||||
|
valhalla = {
|
||||||
|
users.manuel = {
|
||||||
|
oh-my-posh = {
|
||||||
|
theme = {
|
||||||
|
source = ./manuel.omp.json;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
partition = {
|
||||||
|
os = {
|
||||||
|
partitions = { };
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"display_host": false
|
"display_host": false
|
||||||
},
|
},
|
||||||
"template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }} "
|
"template": " {{ if .SSHSession }}\ueb39 {{ end }}{{ .UserName }} "
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "path",
|
"type": "path",
|
||||||
|
|
|
@ -2,10 +2,12 @@ using namespace Microsoft.Win32;
|
||||||
using namespace System.Security.AccessControl;
|
using namespace System.Security.AccessControl;
|
||||||
using namespace System.Security.Principal;
|
using namespace System.Security.Principal;
|
||||||
|
|
||||||
enum SetupStage {
|
enum WindowsInstallerStage {
|
||||||
Idle
|
|
||||||
Initialize
|
Initialize
|
||||||
OneShot
|
Run
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SetupStage {
|
||||||
Configure
|
Configure
|
||||||
Install
|
Install
|
||||||
CreateUser
|
CreateUser
|
||||||
|
@ -14,12 +16,14 @@ enum SetupStage {
|
||||||
enum UserStage {
|
enum UserStage {
|
||||||
Create
|
Create
|
||||||
Configure
|
Configure
|
||||||
|
Cleanup
|
||||||
Completed
|
Completed
|
||||||
}
|
}
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
[string] $configRoot = "HKLM:\Software\PortValhalla";
|
[string] $configRoot = "HKLM:\Software\PortValhalla";
|
||||||
[string] $stageOption = "Stage";
|
[string] $stageOption = "Stage";
|
||||||
|
[string] $setupStageOption = "SetupStage";
|
||||||
[string] $userOption = "SetupUser";
|
[string] $userOption = "SetupUser";
|
||||||
[string] $userStageOption = "UserStage";
|
[string] $userStageOption = "UserStage";
|
||||||
[string] $accountOption = "MSAccount";
|
[string] $accountOption = "MSAccount";
|
||||||
|
@ -164,6 +168,14 @@ $null = New-Module {
|
||||||
return "valhalla.$($IsWindows ? "windows" : "linux")";
|
return "valhalla.$($IsWindows ? "windows" : "linux")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the name of the user root.
|
||||||
|
#>
|
||||||
|
function Get-UserRootName {
|
||||||
|
return "$(Get-ConfigRootName).$($IsWindows ? "winUsers" : "users")";
|
||||||
|
};
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Gets a user configuration.
|
Gets a user configuration.
|
||||||
|
@ -182,7 +194,7 @@ $null = New-Module {
|
||||||
)
|
)
|
||||||
|
|
||||||
if ((Get-Users) -contains $UserName) {
|
if ((Get-Users) -contains $UserName) {
|
||||||
Get-Config "$(Get-ConfigRootName).users.$UserName.$Name";
|
Get-Config "$(Get-UserRootName).$UserName.$Name";
|
||||||
} else {
|
} else {
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +222,7 @@ $null = New-Module {
|
||||||
function Get-Users {
|
function Get-Users {
|
||||||
[OutputType([string[]])]
|
[OutputType([string[]])]
|
||||||
param()
|
param()
|
||||||
Get-Attributes "$(Get-ConfigRootName).users";
|
Get-Attributes "$(Get-UserRootName)";
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -220,7 +232,7 @@ $null = New-Module {
|
||||||
function Get-SetupUser {
|
function Get-SetupUser {
|
||||||
[OutputType([string])]
|
[OutputType([string])]
|
||||||
param()
|
param()
|
||||||
Get-Config "$(Get-ConfigRootName).setupUser";
|
Get-Config "$(Get-ConfigRootName).setupUser.name";
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -266,11 +278,44 @@ $null = New-Module {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Gets the name of the current setup stage.
|
Gets the name of the current stage of the Windows install script action.
|
||||||
#>
|
#>
|
||||||
function Get-Stage {
|
function Get-Stage {
|
||||||
$stage = Get-SetupOption $stageOption;
|
$stage = Get-SetupOption $stageOption;
|
||||||
|
|
||||||
|
if ($null -ne $stage) {
|
||||||
|
$stage = [WindowsInstallerStage]$stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets the name of the current stage of the Windows install script action.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the stage to set.
|
||||||
|
#>
|
||||||
|
function Set-Stage {
|
||||||
|
param(
|
||||||
|
$Name
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
|
||||||
|
$Name = ([WindowsInstallerStage]$Name).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = Set-SetupOption $stageOption $Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the name of the current setup stage.
|
||||||
|
#>
|
||||||
|
function Get-SetupStage {
|
||||||
|
$stage = Get-SetupOption $setupStageOption;
|
||||||
|
|
||||||
if ($null -ne $stage) {
|
if ($null -ne $stage) {
|
||||||
$stage = [SetupStage]$stage;
|
$stage = [SetupStage]$stage;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +330,7 @@ $null = New-Module {
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The name to set the current stage to.
|
The name to set the current stage to.
|
||||||
#>
|
#>
|
||||||
function Set-Stage {
|
function Set-SetupStage {
|
||||||
param(
|
param(
|
||||||
$Name
|
$Name
|
||||||
)
|
)
|
||||||
|
@ -294,7 +339,7 @@ $null = New-Module {
|
||||||
$Name = ([SetupStage]$Name).ToString();
|
$Name = ([SetupStage]$Name).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
$null = Set-SetupOption $stageOption $Name;
|
$null = Set-SetupOption $setupStageOption $Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -381,7 +426,7 @@ $null = New-Module {
|
||||||
Gets a value indicating whether the setup has finished.
|
Gets a value indicating whether the setup has finished.
|
||||||
#>
|
#>
|
||||||
function Get-IsFinished {
|
function Get-IsFinished {
|
||||||
return [bool] (((Get-Stage) -eq ([SetupStage]::Idle)) -or (Get-SetupOption $finishedOption));
|
return [bool](Get-SetupOption $finishedOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
. "$PSScriptRoot/Config.ps1";
|
using namespace System.Management.Automation.Host;
|
||||||
|
|
||||||
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
|
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
|
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
|
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
|
. "$PSScriptRoot/Config.ps1";
|
||||||
|
. "$PSScriptRoot/../Scripts/SoftwareManagement.ps1";
|
||||||
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
||||||
|
. "$PSScriptRoot/../../Windows/Scripts/Hooks.ps1";
|
||||||
|
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.ps1";
|
||||||
|
. "$PSScriptRoot/../../Windows/Scripts/Registry.ps1";
|
||||||
|
. "$PSScriptRoot/../../Windows/Scripts/Security.ps1";
|
||||||
|
. "$PSScriptRoot/../../Windows/Scripts/WSL.ps1";
|
||||||
$oneShotTaskName = "PortValhalla OneShot";
|
$oneShotTaskName = "PortValhalla OneShot";
|
||||||
$logName = "Application";
|
$logName = "Application";
|
||||||
$oneShotTrigger = 1337;
|
$oneShotTrigger = 1337;
|
||||||
|
@ -25,9 +30,17 @@ $null = New-Module {
|
||||||
function Start-Operation {
|
function Start-Operation {
|
||||||
param(
|
param(
|
||||||
[switch] $NonInteractive,
|
[switch] $NonInteractive,
|
||||||
|
[switch] $NoImplicitCleanup,
|
||||||
[scriptblock] $Action
|
[scriptblock] $Action
|
||||||
)
|
)
|
||||||
|
|
||||||
|
$cleanup = { };
|
||||||
|
|
||||||
|
if ($IsWindows -and ($null -ne (Get-OneShotTask))) {
|
||||||
|
$taskPending = $true;
|
||||||
|
[switch] $NonInteractive = $true;
|
||||||
|
}
|
||||||
|
|
||||||
if (-not $Global:InOperation) {
|
if (-not $Global:InOperation) {
|
||||||
if ($env:DEBUG) {
|
if ($env:DEBUG) {
|
||||||
Set-PSDebug -Trace 1;
|
Set-PSDebug -Trace 1;
|
||||||
|
@ -35,20 +48,218 @@ $null = New-Module {
|
||||||
|
|
||||||
$Global:InOperation = $true;
|
$Global:InOperation = $true;
|
||||||
$Global:ErrorActionPreference = $NonInteractive.IsPresent ? 'Continue' : 'Inquire';
|
$Global:ErrorActionPreference = $NonInteractive.IsPresent ? 'Continue' : 'Inquire';
|
||||||
$env:WSLENV = "CONFIG_MODULE/p";
|
|
||||||
|
|
||||||
if ($env:CONFIG_MODULE) {
|
if ($IsWindows) {
|
||||||
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
$env:WSLENV = "CONFIG_MODULE/p";
|
||||||
|
|
||||||
|
if ($env:CONFIG_MODULE) {
|
||||||
|
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Admin) {
|
||||||
|
Disable-WindowsUpdateAutoRestart;
|
||||||
|
}
|
||||||
|
|
||||||
|
New-Alias -Force "sudo" gsudo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Admin) {
|
if (-not $NoImplicitCleanup.IsPresent) {
|
||||||
Disable-WindowsUpdateAutoRestart;
|
$cleanup = {
|
||||||
|
Clear-OperationResources;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
New-Alias -Force "sudo" gsudo;
|
& {
|
||||||
|
$initialized = $false;
|
||||||
|
|
||||||
|
while (-not $initialized) {
|
||||||
|
if ($IsWindows) {
|
||||||
|
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
|
||||||
|
Invoke-Hook "Install-Chocolatey" -Fallback {
|
||||||
|
# Install chocolatey
|
||||||
|
New-Item -Force $PROFILE;
|
||||||
|
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
||||||
|
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
||||||
|
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
||||||
|
refreshenv;
|
||||||
|
};
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-ChocoPackage "powershell-core")) {
|
||||||
|
Invoke-Hook "Install-PowerShellCore" -Fallback {
|
||||||
|
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
|
||||||
|
};
|
||||||
|
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($env:PWSH_PATH -and (Test-Path $env:PWSH_PATH)) {
|
||||||
|
attrib "-R" "$env:PWSH_PATH\*" /S /D;
|
||||||
|
Remove-Item -Recurse -Force $env:PWSH_PATH;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($env:DEBUG) {
|
||||||
|
if (
|
||||||
|
(Get-Item $env:INSTALLER_SCRIPT).IsReadOnly -and
|
||||||
|
(Test-Qemu) -and
|
||||||
|
($Host.UI.PromptForChoice(
|
||||||
|
"Confirm",
|
||||||
|
"Do you wish to swap to live scripts?",
|
||||||
|
[ChoiceDescription[]]@(
|
||||||
|
[ChoiceDescription]::new("&No", "Use scripts stored in the virtual machine"),
|
||||||
|
[ChoiceDescription]::new("&Yes", "Use live scripts stored on the host")),
|
||||||
|
0) -eq 1)) {
|
||||||
|
Install-ChocoPackage winfsp qemu-guest-agent;
|
||||||
|
Get-Service VirtioFsSvc | Start-Service -PassThru | Set-Service -StartupType Automatic;
|
||||||
|
|
||||||
|
while (-not (Test-Path Z:\)) {
|
||||||
|
Start-Sleep 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($name in @("CONFIG_MODULE", "INSTALLER_SCRIPT")) {
|
||||||
|
$variable = Get-Item "Env:\$name";
|
||||||
|
|
||||||
|
$path = Join-Path `
|
||||||
|
"Z:\Repositories\PortValhalla" `
|
||||||
|
([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $variable.Value));
|
||||||
|
|
||||||
|
Set-Item "Env:\$name" $path;
|
||||||
|
Write-Host "The new value of ``$name`` is ``$path``";
|
||||||
|
}
|
||||||
|
|
||||||
|
Restart-Intermediate;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Command "gsudo")) {
|
||||||
|
Install-ChocoPackage gsudo;
|
||||||
|
refreshenv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($env:DEBUG) {
|
||||||
|
& {
|
||||||
|
$sys32 = "$env:WINDIR/System32";
|
||||||
|
$osk = (Get-Item "$sys32/osk.exe").FullName;
|
||||||
|
$cmd = (Get-Item "$sys32/cmd.exe").FullName;
|
||||||
|
|
||||||
|
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;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Winget)) {
|
||||||
|
. "$PSScriptRoot/../Software/winget/Manage.ps1";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Command "git")) {
|
||||||
|
Install-WingetPackage Git.Git;
|
||||||
|
refreshenv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Command "7z")) {
|
||||||
|
Install-ChocoPackage 7zip.portable;
|
||||||
|
refreshenv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Command "yq")) {
|
||||||
|
Install-ChocoPackage "yq";
|
||||||
|
refreshenv;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Wsl)) {
|
||||||
|
Install-Wsl;
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-WslDistribution)) {
|
||||||
|
if (-not (Test-Path (Get-WslDistributionDisk))) {
|
||||||
|
Install-WslDistribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
Register-WslDistribution;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (wsl --shell-type login type -t nix)) {
|
||||||
|
wsl -- sh `<`(curl -L https://nixos.org/nix/install`) --daemon --yes;
|
||||||
|
wsl --shutdown;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-PSPackage Selenium.WebDriver)) {
|
||||||
|
Write-Host "Installing browser automation tools…";
|
||||||
|
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Install-ChocoPackage selenium-gecko-driver firefox;
|
||||||
|
Install-WingetPackage AutoHotkey.AutoHotkey;
|
||||||
|
. "$PSScriptRoot/../../Windows/Software/PinnedItem/Manage.ps1";
|
||||||
|
}
|
||||||
|
|
||||||
|
Invoke-Hook "Install-PSModules" -Fallback {
|
||||||
|
$modules = @(
|
||||||
|
@("PSScriptAnalyzer")
|
||||||
|
) + (& {
|
||||||
|
if (-not $IsWindows) {
|
||||||
|
@()
|
||||||
|
} else {
|
||||||
|
@(
|
||||||
|
@("KnownFolders"),
|
||||||
|
@("PSWindowsUpdate"),
|
||||||
|
@("LocalAccounts", $true),
|
||||||
|
@("NuGet")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($module in $modules) {
|
||||||
|
$parameters = @{ };
|
||||||
|
|
||||||
|
if ($module -is [string]) {
|
||||||
|
$module = @($module);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($module[1]) {
|
||||||
|
$parameters = @{
|
||||||
|
allowPrerelease = $true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-PSModule $module[0])) {
|
||||||
|
Install-Module -Scope AllUsers -AcceptLicense -Force $module[0] @parameters;
|
||||||
|
Import-Module $module[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$initialized = $true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& $Action;
|
if ($taskPending) {
|
||||||
|
Start-OneShot;
|
||||||
|
} else {
|
||||||
|
& $Action;
|
||||||
|
}
|
||||||
|
|
||||||
|
& $cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -56,7 +267,13 @@ $null = New-Module {
|
||||||
Gets the current OneShot task.
|
Gets the current OneShot task.
|
||||||
#>
|
#>
|
||||||
function Get-OneShotTask {
|
function Get-OneShotTask {
|
||||||
[OneShotTask](Get-SetupOption $taskOption);
|
$task = Get-SetupOption $taskOption;
|
||||||
|
|
||||||
|
if ($task) {
|
||||||
|
return [OneShotTask]$task;
|
||||||
|
} else {
|
||||||
|
return $null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -109,8 +326,6 @@ $null = New-Module {
|
||||||
[OneShotTask] $Task
|
[OneShotTask] $Task
|
||||||
)
|
)
|
||||||
|
|
||||||
$currentStage = Get-Stage;
|
|
||||||
Set-Stage ([SetupStage]::OneShot);
|
|
||||||
& $taskSetter $Task;
|
& $taskSetter $Task;
|
||||||
|
|
||||||
& {
|
& {
|
||||||
|
@ -139,8 +354,6 @@ $null = New-Module {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Set-Stage $currentStage;
|
|
||||||
|
|
||||||
if (Test-Path $errorPath) {
|
if (Test-Path $errorPath) {
|
||||||
$errorMessage = Get-Content $errorPath;
|
$errorMessage = Get-Content $errorPath;
|
||||||
Remove-Item $errorPath;
|
Remove-Item $errorPath;
|
||||||
|
@ -158,20 +371,38 @@ $null = New-Module {
|
||||||
Executes the specified action and notifies the OneShot task executor.
|
Executes the specified action and notifies the OneShot task executor.
|
||||||
#>
|
#>
|
||||||
function Start-OneShot {
|
function Start-OneShot {
|
||||||
param(
|
|
||||||
[scriptblock] $Action
|
|
||||||
)
|
|
||||||
|
|
||||||
try {
|
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 {
|
catch {
|
||||||
Set-Content -Path $errorPath -Value $Error;
|
Set-Content -Path $errorPath -Value $Error;
|
||||||
Set-UserPermissions $errorPath;
|
Set-UserPermissions $errorPath;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
Set-Stage ([SetupStage]::Idle);
|
& $taskSetter $null;
|
||||||
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "The OneShot task ``$(Get-OneShotTask)`` finished.";
|
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "The OneShot task ``$(Get-OneShotTask)`` finished.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Clears resources allocated during the operation.
|
||||||
|
#>
|
||||||
|
function Clear-OperationResources {
|
||||||
|
if ($IsWindows) {
|
||||||
|
Uninstall-WslDistribution;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -197,8 +197,10 @@ $null = New-Module {
|
||||||
function Start-SoftwareInstaller {
|
function Start-SoftwareInstaller {
|
||||||
param(
|
param(
|
||||||
[string] $Name,
|
[string] $Name,
|
||||||
|
[scriptblock] $Backup = $null,
|
||||||
[scriptblock] $Installer = $null,
|
[scriptblock] $Installer = $null,
|
||||||
[scriptblock] $Configurator = $null,
|
[scriptblock] $Configurator = $null,
|
||||||
|
[scriptblock] $UserBackup = $null,
|
||||||
[scriptblock] $UserConfigurator = $null,
|
[scriptblock] $UserConfigurator = $null,
|
||||||
[Nullable[InstallerAction]] $Action,
|
[Nullable[InstallerAction]] $Action,
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
|
@ -235,32 +237,53 @@ $null = New-Module {
|
||||||
installer = $installHandler;
|
installer = $installHandler;
|
||||||
arguments = $Arguments;
|
arguments = $Arguments;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($action -eq ([InstallerAction]::Install)) {
|
|
||||||
if ($Installer) {
|
|
||||||
Write-Host "Installing $Name…";
|
|
||||||
& $Installer @argumentList;
|
|
||||||
}
|
|
||||||
|
|
||||||
& $installHandler @argumentList -Action ([InstallerAction]::Configure);
|
switch ($Action) {
|
||||||
|
([InstallerAction]::Backup) {
|
||||||
|
if ($Backup) {
|
||||||
|
Write-Host "Backing up $Name…";
|
||||||
|
& $Backup @argumentList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
([InstallerAction]::Install) {
|
||||||
|
if ($Installer) {
|
||||||
|
Write-Host "Installing $Name…";
|
||||||
|
& $Installer @argumentList;
|
||||||
|
}
|
||||||
|
|
||||||
if ($UserConfigurator -and (-not (Test-SetupUser))) {
|
& $installHandler @argumentList -Action ([InstallerAction]::Configure);
|
||||||
& $installHandler @argumentList -Action ([InstallerAction]::ConfigureUser);
|
|
||||||
|
if ($UserConfigurator -and (-not (Test-SetupUser))) {
|
||||||
|
& $installHandler @argumentList -Action ([InstallerAction]::ConfigureUser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# ToDo: Automatically configure after installation
|
([InstallerAction]::Configure) {
|
||||||
} elseif ($Action -eq ([InstallerAction]::Configure)) {
|
if ($Configurator) {
|
||||||
if ($Configurator) {
|
Write-Host "Configuring $Name…";
|
||||||
Write-Host "Configuring $Name…";
|
& $Configurator @argumentList;
|
||||||
& $Configurator @argumentList;
|
}
|
||||||
}
|
}
|
||||||
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
|
default {
|
||||||
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
|
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
|
||||||
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
|
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($UserConfigurator) {
|
$user = $Arguments[$userArgument];
|
||||||
Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``…";
|
|
||||||
& $UserConfigurator @argumentList;
|
switch ($_) {
|
||||||
|
([InstallerAction]::BackupUser) {
|
||||||
|
if ($UserBackup) {
|
||||||
|
Write-Host "Backing up ``$Name`` for user ``$user``…";
|
||||||
|
& $UserBackup @argumentList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
([InstallerAction]::ConfigureUser) {
|
||||||
|
if ($UserConfigurator) {
|
||||||
|
Write-Host "Configuring $Name for user ``$user``…";
|
||||||
|
& $UserConfigurator @argumentList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -103,3 +103,18 @@ function Test-PSPackage {
|
||||||
|
|
||||||
[bool] (Get-Package $Name -ErrorAction SilentlyContinue);
|
[bool] (Get-Package $Name -ErrorAction SilentlyContinue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks whether a module with the specified name is installed.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the module to check.
|
||||||
|
#>
|
||||||
|
function Test-PSModule {
|
||||||
|
param(
|
||||||
|
[string] $Name
|
||||||
|
)
|
||||||
|
|
||||||
|
[bool](Get-Module -ListAvailable $Name -ErrorAction SilentlyContinue);
|
||||||
|
}
|
||||||
|
|
|
@ -30,6 +30,27 @@ function Remove-DesktopIcon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Adds a new shortcut to the start menu.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the icon to create.
|
||||||
|
|
||||||
|
.PARAMETER Target
|
||||||
|
The file to link to.
|
||||||
|
#>
|
||||||
|
function Add-StartMenuIcon {
|
||||||
|
param(
|
||||||
|
[string] $Name,
|
||||||
|
[string] $Target
|
||||||
|
)
|
||||||
|
|
||||||
|
Import-Module KnownFolders;
|
||||||
|
Import-Module "$env:ChocolateyInstall/helpers/chocolateyInstaller.psm1";
|
||||||
|
Install-ChocolateyShortcut -ShortcutFilePath "$((Get-KnownFolder "Common Programs").Path)/$Name.lnk" -TargetPath ((Get-Item $Target).FullName);
|
||||||
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Removes icons from the task bar.
|
Removes icons from the task bar.
|
||||||
|
|
|
@ -34,7 +34,16 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
$root = "$($IsWindows ? $env:AppData : "~/.config")/oh-my-posh";
|
$root = "$($IsWindows ? $env:AppData : "~/.config")/oh-my-posh";
|
||||||
$path = Join-Path $root "$($theme.name).omp.json";
|
$path = Join-Path $root "$($theme.name).omp.json";
|
||||||
$null = New-Item -Force -ItemType Directory $root;
|
$null = New-Item -Force -ItemType Directory $root;
|
||||||
Set-Content $path (wsl cat $theme.source);
|
|
||||||
|
Set-Content $path (
|
||||||
|
& {
|
||||||
|
if ($IsWindows) {
|
||||||
|
wsl cat $theme.source
|
||||||
|
} else {
|
||||||
|
cat $theme.source
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$theme = [string] $path;
|
$theme = [string] $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,14 @@ $null = New-Module {
|
||||||
)
|
)
|
||||||
|
|
||||||
$env:PENDING_MODULE_NAME = $Arguments.Name;
|
$env:PENDING_MODULE_NAME = $Arguments.Name;
|
||||||
$installAction = { Install-Module -Scope AllUsers -Force $env:PENDING_MODULE_NAME @args };
|
|
||||||
|
$installAction = {
|
||||||
|
$module = $env:PENDING_MODULE_NAME;
|
||||||
|
|
||||||
|
if (-not (Get-Module -ListAvailable $module -ErrorAction SilentlyContinue)) {
|
||||||
|
Install-Module -Scope AllUsers -Force $module @args;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (-not $Arguments.NativeOnly) {
|
if (-not $Arguments.NativeOnly) {
|
||||||
& $installAction -AcceptLicense;
|
& $installAction -AcceptLicense;
|
||||||
|
@ -48,19 +55,17 @@ $null = New-Module {
|
||||||
& $Installer -Action ([InstallerAction]::Configure) @PSBoundParameters;
|
& $Installer -Action ([InstallerAction]::Configure) @PSBoundParameters;
|
||||||
};
|
};
|
||||||
|
|
||||||
configurator = {
|
configurator = ($NoProfile.IsPresent) ? { } : {
|
||||||
param(
|
param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not $NoProfile) {
|
$name = $Arguments.Name;
|
||||||
$name = $Arguments.Name;
|
|
||||||
|
|
||||||
Add-PowerShellProfileStatement `
|
Add-PowerShellProfileStatement `
|
||||||
-DefaultUser `
|
-DefaultUser `
|
||||||
-Category $name `
|
-Category $name `
|
||||||
-Script "Import-Module `"$name`";";
|
-Script "Import-Module `"$name`";";
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,11 @@ $null = New-Module {
|
||||||
|
|
||||||
Push-Location ~;
|
Push-Location ~;
|
||||||
|
|
||||||
$profiles = $profiles |
|
$profiles = @(
|
||||||
ForEach-Object { [System.IO.Path]::GetRelativePath((Get-Location), $_) } |
|
$profiles |
|
||||||
ForEach-Object { "$HomeDir/$_" };
|
ForEach-Object { [System.IO.Path]::GetRelativePath((Get-Location), $_) } |
|
||||||
|
ForEach-Object { "$HomeDir/$_" }
|
||||||
|
);
|
||||||
|
|
||||||
Pop-Location;
|
Pop-Location;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,14 +34,14 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Test-Path $globalPath) {
|
if (Test-Path $globalPath) {
|
||||||
& ([scriptblock]::Create((aliae init pwsh --config $globalPath)));
|
$null = & ([scriptblock]::Create((aliae init pwsh --config $globalPath))) *>&1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Path $userPath) {
|
if (Test-Path $userPath) {
|
||||||
& ([scriptblock]::Create((aliae init pwsh)));
|
$null = & ([scriptblock]::Create((aliae init pwsh))) *>&1;
|
||||||
}
|
}
|
||||||
|
|
||||||
& ([scriptblock]::Create((aliae completion powershell)));
|
aliae completion powershell | Out-String | Invoke-Expression;
|
||||||
}
|
}
|
||||||
) -join [System.Environment]::NewLine)
|
) -join [System.Environment]::NewLine)
|
||||||
} `
|
} `
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
enum InstallerAction {
|
enum InstallerAction {
|
||||||
|
Backup
|
||||||
Install
|
Install
|
||||||
Configure
|
Configure
|
||||||
|
BackupUser
|
||||||
ConfigureUser
|
ConfigureUser
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,733 +0,0 @@
|
||||||
#!/bin/pwsh
|
|
||||||
using namespace System.Management.Automation.Host;
|
|
||||||
using namespace System.Security.Principal;
|
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
|
|
||||||
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
|
|
||||||
. "$PSScriptRoot/../Scripts/Security.ps1";
|
|
||||||
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
|
||||||
. "$PSScriptRoot/Manage.ps1";
|
|
||||||
. "$PSScriptRoot/User/Install.ps1";
|
|
||||||
|
|
||||||
$null = New-Module {
|
|
||||||
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
|
||||||
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
|
||||||
. "$PSScriptRoot/../Scripts/Registry.ps1";
|
|
||||||
. "$PSScriptRoot/../Scripts/Security.ps1";
|
|
||||||
. "$PSScriptRoot/../Scripts/Update.ps1";
|
|
||||||
. "$PSScriptRoot/../Scripts/Users.ps1";
|
|
||||||
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
|
|
||||||
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
|
|
||||||
. "$PSScriptRoot/../../Common/Scripts/Software.ps1";
|
|
||||||
. "$PSScriptRoot/../../Common/Scripts/SoftwareManagement.ps1";
|
|
||||||
. "$PSScriptRoot/../../Common/Types/InstallerAction.ps1";
|
|
||||||
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Finishes the installation of a running Windows machine.
|
|
||||||
#>
|
|
||||||
function Start-WindowsInstallation {
|
|
||||||
Start-Operation {
|
|
||||||
Start-InstallationLoop;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Starts the installation loop.
|
|
||||||
#>
|
|
||||||
function Start-InstallationLoop {
|
|
||||||
$wslLocation = "$env:ProgramData\PortValhalla\Ubuntu";
|
|
||||||
|
|
||||||
while (-not (Get-IsFinished)) {
|
|
||||||
switch (Get-Stage) {
|
|
||||||
($null) {
|
|
||||||
Set-Stage ([SetupStage]::Initialize);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
([SetupStage]::Initialize) {
|
|
||||||
if (-not ((Test-Command "choco") -and (Test-Command "refreshenv"))) {
|
|
||||||
Invoke-Hook "Install-Chocolatey" -Fallback {
|
|
||||||
# Install chocolatey
|
|
||||||
New-Item -Force $PROFILE;
|
|
||||||
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
|
|
||||||
Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'));
|
|
||||||
Import-Module $env:ChocolateyInstall/helpers/chocolateyProfile.psm1;
|
|
||||||
refreshenv;
|
|
||||||
};
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (-not (Test-ChocoPackage "powershell-core")) {
|
|
||||||
Invoke-Hook "Install-PowerShellCore" -Fallback {
|
|
||||||
choco install -y powershell-core --install-arguments='"ADD_FILE_CONTEXT_MENU_RUNPOWERSHELL=1 ADD_EXPLORER_CONTEXT_MENU_OPENPOWERSHELL=1 REGISTER_MANIFEST=1 USER_MU=1 ENABLE_MU=1"';
|
|
||||||
};
|
|
||||||
|
|
||||||
Restart-Intermediate;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($env:PWSH_PATH -and (Test-Path $env:PWSH_PATH)) {
|
|
||||||
attrib "-R" "$env:PWSH_PATH\*" /S /D;
|
|
||||||
Remove-Item -Recurse -Force $env:PWSH_PATH;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($env:DEBUG) {
|
|
||||||
if (
|
|
||||||
(Get-Item $env:INSTALLER_SCRIPT).IsReadOnly -and
|
|
||||||
(Test-Qemu) -and
|
|
||||||
($Host.UI.PromptForChoice(
|
|
||||||
"Confirm",
|
|
||||||
"Do you wish to swap to live scripts?",
|
|
||||||
[ChoiceDescription[]]@(
|
|
||||||
[ChoiceDescription]::new("&No", "Use scripts stored in the virtual machine"),
|
|
||||||
[ChoiceDescription]::new("&Yes", "Use live scripts stored on the host")),
|
|
||||||
0) -eq 1)) {
|
|
||||||
Install-ChocoPackage winfsp qemu-guest-agent;
|
|
||||||
Get-Service VirtioFsSvc | Start-Service -PassThru | Set-Service -StartupType Automatic;
|
|
||||||
|
|
||||||
while (-not (Test-Path Z:\)) {
|
|
||||||
Start-Sleep 0.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($name in @("CONFIG_MODULE", "INSTALLER_SCRIPT")) {
|
|
||||||
$variable = Get-Item "Env:\$name";
|
|
||||||
|
|
||||||
$path = Join-Path `
|
|
||||||
"Z:\Repositories\PortValhalla" `
|
|
||||||
([System.IO.Path]::GetRelativePath("$PSScriptRoot/../../..", $variable.Value));
|
|
||||||
|
|
||||||
Set-Item "Env:\$name" $path;
|
|
||||||
Write-Host "The new value of ``$name`` is ``$path``";
|
|
||||||
}
|
|
||||||
|
|
||||||
Restart-Intermediate;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Command "gsudo")) {
|
|
||||||
Install-ChocoPackage gsudo;
|
|
||||||
refreshenv;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($env:DEBUG) {
|
|
||||||
& {
|
|
||||||
$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) {
|
|
||||||
Set-MpPreference -ExclusionPath $osk;
|
|
||||||
gsudo -d --ti move $osk "${osk}_";
|
|
||||||
gsudo -d -s copy $cmd $osk;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Winget)) {
|
|
||||||
. "$PSScriptRoot/../Software/winget/Manage.ps1";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Command "git")) {
|
|
||||||
Install-WingetPackage Git.Git;
|
|
||||||
refreshenv;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (& { $null = wsl --status; $?; })) {
|
|
||||||
wsl --install --no-launch;
|
|
||||||
Restart-Intermediate;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (& { $null = wsl -l; $?; })) {
|
|
||||||
$wslRoot = Split-Path -Parent $wslLocation;
|
|
||||||
|
|
||||||
if (-not (Test-Path $wslRoot)) {
|
|
||||||
$null = New-Item -ItemType Directory $wslRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
Copy-Item -Recurse (Get-AppxPackage "*Ubuntu*").InstallLocation $wslLocation;
|
|
||||||
Set-UserPermissions $wslLocation;
|
|
||||||
& "$wslLocation\ubuntu.exe" install --root;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (wsl --shell-type login type -t nix)) {
|
|
||||||
wsl -- sh `<`(curl -L https://nixos.org/nix/install`) --daemon --yes;
|
|
||||||
wsl --shutdown;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-PSPackage Selenium.WebDriver)) {
|
|
||||||
Write-Host "Installing browser automation tools…";
|
|
||||||
Install-Module -AcceptLicense -Force NuGet;
|
|
||||||
Import-Module NuGet;
|
|
||||||
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Install-ChocoPackage selenium-gecko-driver firefox;
|
|
||||||
|
|
||||||
Invoke-Hook "Install-PSModules" -Fallback {
|
|
||||||
Install-Module -Scope AllUsers -AcceptLicense -Force PSWindowsUpdate;
|
|
||||||
Install-Module -Scope AllUsers -AcceptLicense -Force PSScriptAnalyzer;
|
|
||||||
Install-Module -Scope AllUsers -AcceptLicense -AllowPrerelease -AllowClobber -Force LocalAccounts;
|
|
||||||
Import-Module LocalAccounts;
|
|
||||||
. "$PSScriptRoot/../Software/PinnedItem/Manage.ps1";
|
|
||||||
};
|
|
||||||
|
|
||||||
Install-WingetPackage AutoHotkey.AutoHotkey;
|
|
||||||
Set-Stage ([SetupStage]::Configure);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
if (-not (& { $null = wsl -l; $? })) {
|
|
||||||
wsl --import-in-place "PortValhalla" "$wslLocation/ext4.vhdx";
|
|
||||||
wsl --set-default "PortValhalla";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($_) {
|
|
||||||
([SetupStage]::OneShot) {
|
|
||||||
Write-Host "Running OneShot task ``$(Get-OneShotTask)``";
|
|
||||||
|
|
||||||
Start-OneShot {
|
|
||||||
switch (Get-OneShotTask) {
|
|
||||||
([OneShotTask]::InitializeMSAccount) {
|
|
||||||
Initialize-UserCreation;
|
|
||||||
Register-Setup -DefaultUser;
|
|
||||||
}
|
|
||||||
([OneShotTask]::DisableUAC) {
|
|
||||||
Disable-UAC;
|
|
||||||
Register-Setup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
if (Test-Admin) {
|
|
||||||
$null = Import-Module PSWindowsUpdate;
|
|
||||||
|
|
||||||
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
|
|
||||||
Update-WindowsInstallation;
|
|
||||||
};
|
|
||||||
|
|
||||||
if ((Get-WURebootStatus -Silent)) {
|
|
||||||
Restart-Intermediate;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
<#
|
|
||||||
.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/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) {
|
|
||||||
& "$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-Computer;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Clear-SetupRegistration;
|
|
||||||
Disable-OneShotListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-UserStage ([UserStage]::Configure);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(([UserStage]::Configure)) {
|
|
||||||
$adminGroup = @{
|
|
||||||
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
|
||||||
};
|
|
||||||
|
|
||||||
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]::Completed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-IsFinished $true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Invoke-WindowsInstallation([Context] $context) {
|
|
||||||
$Global:InformationPreference = "Continue";
|
|
||||||
$Global:ErrorActionPreference = "Inquire";
|
|
||||||
$context.UserNames ??= @("Manuel");
|
|
||||||
Start-OldWindowsInstallationScript $context;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Start-OldWindowsInstallationScript([Context] $context) {
|
|
||||||
. "$PSScriptRoot/Upgrade.ps1";
|
|
||||||
$finished = $false;
|
|
||||||
Remove-Item Env:\POSH_THEME -ErrorAction SilentlyContinue;
|
|
||||||
$configPath = "$PSScriptRoot/../Config";
|
|
||||||
$softwarePath = "$PSScriptRoot/../Software";
|
|
||||||
$initialConfigStage = "InitialConfiguration";
|
|
||||||
$prerequisitesStage = "InstallationPrerequisites";
|
|
||||||
$driverStage = "DriverInstallation";
|
|
||||||
$softwareStage = "MachineWideSoftwareInstallation";
|
|
||||||
$userStage = "CreatingUser";
|
|
||||||
$restorationStage = "Restoring";
|
|
||||||
|
|
||||||
|
|
||||||
while (-not $finished) {
|
|
||||||
switch ($context.GetStage()) {
|
|
||||||
{ (-not $_) -or ($_ -eq $initialConfigStage) } {
|
|
||||||
$context.SetStage($initialConfigStage);
|
|
||||||
|
|
||||||
if ((Get-Command Initialize-Configuration -ErrorAction SilentlyContinue)) {
|
|
||||||
Write-Information "Configuration initialization function was found. Running...";
|
|
||||||
Initialize-Configuration $context;
|
|
||||||
}
|
|
||||||
|
|
||||||
$null = Enable-WindowsOptionalFeature -Online -All -FeatureName "NetFx3";
|
|
||||||
|
|
||||||
. "$configPath/Windows/Install.ps1" $context;
|
|
||||||
. "$configPath/Explorer/Install.ps1" $context;
|
|
||||||
. "$configPath/OpenSSH/Install.ps1" $context;
|
|
||||||
. "$configPath/chocolatey/Install.ps1";
|
|
||||||
|
|
||||||
$context.RemoveDesktopIcon("*Microsoft Edge*");
|
|
||||||
$context.SetStage($prerequisitesStage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
# Always install updates
|
|
||||||
default {
|
|
||||||
Write-Host "Starting Installation and Restoration of Windows";
|
|
||||||
Update-WindowsInstallation $context;
|
|
||||||
}
|
|
||||||
$prerequisitesStage {
|
|
||||||
Write-Host "Installing prerequisites for installing software";
|
|
||||||
|
|
||||||
if (-not $(Get-Command winget)) {
|
|
||||||
choco install -y winget;
|
|
||||||
}
|
|
||||||
|
|
||||||
Install-Module -AcceptLicense -Force "NuGet";
|
|
||||||
Import-Module NuGet;
|
|
||||||
|
|
||||||
Install-Firefox $context;
|
|
||||||
choco install -y selenium-gecko-driver;
|
|
||||||
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
|
|
||||||
|
|
||||||
winget install --accept-source-agreements --accept-package-agreements -e --id AutoHotkey.AutoHotkey;
|
|
||||||
|
|
||||||
$context.SetStage($driverStage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$driverStage {
|
|
||||||
Write-Host "Installing drivers";
|
|
||||||
|
|
||||||
if ((Get-Command Install-PortValhallaDrivers -ErrorAction SilentlyContinue)) {
|
|
||||||
Write-Information "Driver installation function was found. Starting installation";
|
|
||||||
Install-PortValhallaDrivers $context;
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Information "Finished installing drivers";
|
|
||||||
$context.SetStage($softwareStage);
|
|
||||||
$context.Reboot();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
$softwareStage {
|
|
||||||
Write-Host "Setting up software with default app associations";
|
|
||||||
. "$softwarePath/WinSCP/Install.ps1" $context;
|
|
||||||
. "$softwarePath/Thunderbird/Install.ps1" $context;
|
|
||||||
|
|
||||||
Write-Host "Installing default settings for new users";
|
|
||||||
. "$softwarePath/aliae/Install.ps1" $context;
|
|
||||||
. "$softwarePath/posh-git/Install.ps1";
|
|
||||||
. "$softwarePath/Terminal-Icons/Install.ps1";
|
|
||||||
. "$softwarePath/Oh My Posh/Install.ps1" $context;
|
|
||||||
$context.SetStage($userStage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$userStage {
|
|
||||||
Install-PersonalUsers $context;
|
|
||||||
$context.SetStage($restorationStage);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$restorationStage {
|
|
||||||
Restore-WindowsInstallation $context;
|
|
||||||
$finished = $true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
63
scripts/Windows/OS/Legacy.ps1
Normal file
63
scripts/Windows/OS/Legacy.ps1
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/pwsh
|
||||||
|
. "$PSScriptRoot/../Scripts/PersonalFiles.ps1";
|
||||||
|
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
||||||
|
. "$PSScriptRoot/../Software/Nextcloud/Install.ps1";
|
||||||
|
. "$PSScriptRoot/../Collections/Personal.ps1";
|
||||||
|
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
|
||||||
|
|
||||||
|
function Backup-WindowsInstallation([Context] $context) {
|
||||||
|
Write-Information "Backing up Windows";
|
||||||
|
$Global:InformationPreference = "Continue";
|
||||||
|
$Global:ErrorActionPreference = "Inquire";
|
||||||
|
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
|
||||||
|
$backupRoot = $context.BackupRoot();
|
||||||
|
Backup-PersonalFiles $context;
|
||||||
|
Backup-PersonalApps $context;
|
||||||
|
$context.Backup($backupRoot, "$backupRoot.7z", @("-sdel"), $false);
|
||||||
|
$context.Cleanup();
|
||||||
|
Write-Host "Never forget to store the backup somewhere safe!";
|
||||||
|
Write-Host "I mean... what kind of a dumbass would ever forget to do so, right?";
|
||||||
|
}
|
||||||
|
|
||||||
|
function Restore-WindowsInstallation([Context] $context) {
|
||||||
|
Write-Host "Restoring Windows";
|
||||||
|
choco feature enable -n useEnhancedExitCodes;
|
||||||
|
|
||||||
|
function Read-Path()
|
||||||
|
{
|
||||||
|
$backupPath = Read-Host -Prompt "Please enter the path to the archive to load the backup from.";
|
||||||
|
|
||||||
|
if ($backupPath -and (-not (Test-Path -PathType Leaf $backupPath)))
|
||||||
|
{
|
||||||
|
Write-Host "No file could be found at the specified path.";
|
||||||
|
return Read-Path;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $backupPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Install-Firefox $context;
|
||||||
|
Restore-Nextcloud $context;
|
||||||
|
|
||||||
|
Write-Information "Determining Backup Archive Path";
|
||||||
|
$backupPath = Read-Path;
|
||||||
|
$context.BackupName ??= "PortValhalla";
|
||||||
|
$context.RootDir = $context.GetTempDirectory();
|
||||||
|
|
||||||
|
if ($backupPath)
|
||||||
|
{
|
||||||
|
$context.Restore($backupPath, $context.BackupRoot());
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-UserInternationalSettingsToSystem -WelcomeScreen $True -NewUser $False;
|
||||||
|
Restore-PersonalFiles $context;
|
||||||
|
|
||||||
|
if ((Get-Command Restore-Apps -ErrorAction SilentlyContinue)) {
|
||||||
|
Restore-Apps $context;
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove-Item -Recurse $context.RootDir;
|
||||||
|
$context.Cleanup();
|
||||||
|
}
|
|
@ -1,63 +1,236 @@
|
||||||
#!/bin/pwsh
|
#!/bin/pwsh
|
||||||
. "$PSScriptRoot/../Scripts/PersonalFiles.ps1";
|
using namespace System.Security.Principal;
|
||||||
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
|
||||||
. "$PSScriptRoot/../Software/Nextcloud/Install.ps1";
|
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
|
||||||
. "$PSScriptRoot/../Collections/Personal.ps1";
|
. "$PSScriptRoot/../../../scripts/Windows/Scripts/WSL.ps1";
|
||||||
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
|
. "$PSScriptRoot/../../Common/Scripts/Context.ps1";
|
||||||
|
. "$PSScriptRoot/../Scripts/Security.ps1";
|
||||||
|
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
|
||||||
|
. "$PSScriptRoot/Manage.ps1";
|
||||||
|
. "$PSScriptRoot/User/Install.ps1";
|
||||||
|
|
||||||
function Backup-WindowsInstallation([Context] $context) {
|
$null = New-Module {
|
||||||
Write-Information "Backing up Windows";
|
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
||||||
$Global:InformationPreference = "Continue";
|
. "$PSScriptRoot/../Scripts/Hooks.ps1";
|
||||||
$Global:ErrorActionPreference = "Inquire";
|
. "$PSScriptRoot/../Scripts/PowerManagement.ps1";
|
||||||
. "$PSScriptRoot/../../../scripts/Windows/Scripts/Prerequisites.ps1";
|
. "$PSScriptRoot/../Scripts/Registry.ps1";
|
||||||
$backupRoot = $context.BackupRoot();
|
. "$PSScriptRoot/../Scripts/Security.ps1";
|
||||||
Backup-PersonalFiles $context;
|
. "$PSScriptRoot/../Scripts/Update.ps1";
|
||||||
Backup-PersonalApps $context;
|
. "$PSScriptRoot/../Scripts/Users.ps1";
|
||||||
$context.Backup($backupRoot, "$backupRoot.7z", @("-sdel"), $false);
|
. "$PSScriptRoot/../Types/WindowsInstallerAction.ps1";
|
||||||
$context.Cleanup();
|
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
|
||||||
Write-Host "Never forget to store the backup somewhere safe!";
|
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
|
||||||
Write-Host "I mean... what kind of a dumbass would ever forget to do so, right?";
|
. "$PSScriptRoot/../../Common/Scripts/Software.ps1";
|
||||||
}
|
. "$PSScriptRoot/../../Common/Scripts/SoftwareManagement.ps1";
|
||||||
|
. "$PSScriptRoot/../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
function Restore-WindowsInstallation([Context] $context) {
|
<#
|
||||||
Write-Host "Restoring Windows";
|
.SYNOPSIS
|
||||||
choco feature enable -n useEnhancedExitCodes;
|
Finishes the installation of a running Windows machine.
|
||||||
|
#>
|
||||||
|
function Start-WindowsInstallation {
|
||||||
|
Start-Operation -NoImplicitCleanup {
|
||||||
|
Start-InstallationLoop;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function Read-Path()
|
<#
|
||||||
{
|
.SYNOPSIS
|
||||||
$backupPath = Read-Host -Prompt "Please enter the path to the archive to load the backup from.";
|
Starts the installation loop.
|
||||||
|
#>
|
||||||
|
function Start-InstallationLoop {
|
||||||
|
param(
|
||||||
|
[WindowsInstallerAction] $Action
|
||||||
|
)
|
||||||
|
|
||||||
if ($backupPath -and (-not (Test-Path -PathType Leaf $backupPath)))
|
switch ($_) {
|
||||||
{
|
([WindowsInstallerStage]::Initialize) {
|
||||||
Write-Host "No file could be found at the specified path.";
|
$env:BACKUP_ARCHIVE = pwsh -Command Write-Host (
|
||||||
return Read-Path;
|
Read-Host (
|
||||||
}
|
& {
|
||||||
else
|
switch ($Action) {
|
||||||
{
|
([WindowsInstallerAction]::Backup) {
|
||||||
return $backupPath;
|
"Please select the path you wish to store your backup at"
|
||||||
|
}
|
||||||
|
([WindowsInstallerAction]::Install) {
|
||||||
|
"Please select the backup archive you wish to restore from"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
([WindowsInstallerStage]::Run) {
|
||||||
|
switch ($Action) {
|
||||||
|
([WindowsInstallerAction]::Install) {
|
||||||
|
while (-not (Get-IsFinished)) {
|
||||||
|
switch (Get-SetupStage) {
|
||||||
|
($null) {
|
||||||
|
Set-SetupStage ([SetupStage]::Initialize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
if (Test-Admin) {
|
||||||
|
$null = Import-Module PSWindowsUpdate;
|
||||||
|
|
||||||
|
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
|
||||||
|
Update-WindowsInstallation;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((Get-WURebootStatus -Silent)) {
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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-SetupStage ([SetupStage]::Install);
|
||||||
|
}
|
||||||
|
([SetupStage]::Install) {
|
||||||
|
Write-Host "Entering install phase";
|
||||||
|
Deploy-SoftwareAction;
|
||||||
|
Set-SetupStage ([SetupStage]::CreateUser);
|
||||||
|
}
|
||||||
|
([SetupStage]::CreateUser) {
|
||||||
|
Install-ValhallaUsers;
|
||||||
|
Set-IsFinished $true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Install-Firefox $context;
|
function Invoke-WindowsInstallation([Context] $context) {
|
||||||
Restore-Nextcloud $context;
|
$Global:InformationPreference = "Continue";
|
||||||
|
$Global:ErrorActionPreference = "Inquire";
|
||||||
Write-Information "Determining Backup Archive Path";
|
$context.UserNames ??= @("Manuel");
|
||||||
$backupPath = Read-Path;
|
Start-OldWindowsInstallationScript $context;
|
||||||
$context.BackupName ??= "PortValhalla";
|
|
||||||
$context.RootDir = $context.GetTempDirectory();
|
|
||||||
|
|
||||||
if ($backupPath)
|
|
||||||
{
|
|
||||||
$context.Restore($backupPath, $context.BackupRoot());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Copy-UserInternationalSettingsToSystem -WelcomeScreen $True -NewUser $False;
|
function Start-OldWindowsInstallationScript([Context] $context) {
|
||||||
Restore-PersonalFiles $context;
|
. "$PSScriptRoot/Upgrade.ps1";
|
||||||
|
$finished = $false;
|
||||||
if ((Get-Command Restore-Apps -ErrorAction SilentlyContinue)) {
|
Remove-Item Env:\POSH_THEME -ErrorAction SilentlyContinue;
|
||||||
Restore-Apps $context;
|
$configPath = "$PSScriptRoot/../Config";
|
||||||
|
$softwarePath = "$PSScriptRoot/../Software";
|
||||||
|
$initialConfigStage = "InitialConfiguration";
|
||||||
|
$prerequisitesStage = "InstallationPrerequisites";
|
||||||
|
$driverStage = "DriverInstallation";
|
||||||
|
$softwareStage = "MachineWideSoftwareInstallation";
|
||||||
|
$userStage = "CreatingUser";
|
||||||
|
$restorationStage = "Restoring";
|
||||||
|
|
||||||
|
|
||||||
|
while (-not $finished) {
|
||||||
|
switch ($context.GetStage()) {
|
||||||
|
{ (-not $_) -or ($_ -eq $initialConfigStage) } {
|
||||||
|
$context.SetStage($initialConfigStage);
|
||||||
|
|
||||||
|
if ((Get-Command Initialize-Configuration -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Information "Configuration initialization function was found. Running...";
|
||||||
|
Initialize-Configuration $context;
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = Enable-WindowsOptionalFeature -Online -All -FeatureName "NetFx3";
|
||||||
|
|
||||||
|
. "$configPath/Windows/Install.ps1" $context;
|
||||||
|
. "$configPath/Explorer/Install.ps1" $context;
|
||||||
|
. "$configPath/OpenSSH/Install.ps1" $context;
|
||||||
|
. "$configPath/chocolatey/Install.ps1";
|
||||||
|
|
||||||
|
$context.RemoveDesktopIcon("*Microsoft Edge*");
|
||||||
|
$context.SetStage($prerequisitesStage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
# Always install updates
|
||||||
|
default {
|
||||||
|
Write-Host "Starting Installation and Restoration of Windows";
|
||||||
|
Update-WindowsInstallation $context;
|
||||||
|
}
|
||||||
|
$prerequisitesStage {
|
||||||
|
Write-Host "Installing prerequisites for installing software";
|
||||||
|
|
||||||
|
if (-not $(Get-Command winget)) {
|
||||||
|
choco install -y winget;
|
||||||
|
}
|
||||||
|
|
||||||
|
Install-Module -AcceptLicense -Force "NuGet";
|
||||||
|
Import-Module NuGet;
|
||||||
|
|
||||||
|
Install-Firefox $context;
|
||||||
|
choco install -y selenium-gecko-driver;
|
||||||
|
$null = Install-Package -Force Selenium.WebDriver -RequiredVersion 4.10.0 -SkipDependencies;
|
||||||
|
|
||||||
|
winget install --accept-source-agreements --accept-package-agreements -e --id AutoHotkey.AutoHotkey;
|
||||||
|
|
||||||
|
$context.SetStage($driverStage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$driverStage {
|
||||||
|
Write-Host "Installing drivers";
|
||||||
|
|
||||||
|
if ((Get-Command Install-PortValhallaDrivers -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Information "Driver installation function was found. Starting installation";
|
||||||
|
Install-PortValhallaDrivers $context;
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Information "Finished installing drivers";
|
||||||
|
$context.SetStage($softwareStage);
|
||||||
|
$context.Reboot();
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
$softwareStage {
|
||||||
|
Write-Host "Setting up software with default app associations";
|
||||||
|
. "$softwarePath/WinSCP/Install.ps1" $context;
|
||||||
|
. "$softwarePath/Thunderbird/Install.ps1" $context;
|
||||||
|
|
||||||
|
Write-Host "Installing default settings for new users";
|
||||||
|
. "$softwarePath/aliae/Install.ps1" $context;
|
||||||
|
. "$softwarePath/posh-git/Install.ps1";
|
||||||
|
. "$softwarePath/Terminal-Icons/Install.ps1";
|
||||||
|
. "$softwarePath/Oh My Posh/Install.ps1" $context;
|
||||||
|
$context.SetStage($userStage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$userStage {
|
||||||
|
Install-PersonalUsers $context;
|
||||||
|
$context.SetStage($restorationStage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$restorationStage {
|
||||||
|
Restore-WindowsInstallation $context;
|
||||||
|
$finished = $true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
Remove-Item -Recurse $context.RootDir;
|
|
||||||
$context.Cleanup();
|
|
||||||
}
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ function Start-Setup {
|
||||||
foreach ($xpath in @("./ua:AutoLogon/ua:Username",
|
foreach ($xpath in @("./ua:AutoLogon/ua:Username",
|
||||||
"./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/ua:Name",
|
"./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/ua:Name",
|
||||||
"./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/ua:DisplayName")) {
|
"./ua:UserAccounts/ua:LocalAccounts/ua:LocalAccount/ua:DisplayName")) {
|
||||||
$oobeSettings.SelectSingleNode($xpath, $namespace).InnerText = $valhallaConfig.setupUser;
|
$oobeSettings.SelectSingleNode($xpath, $namespace).InnerText = $valhallaConfig.setupUser.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Add-StartupCommand `
|
Add-StartupCommand `
|
||||||
|
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -53,6 +53,7 @@ $null = New-Module {
|
||||||
function Get-StartupCommand {
|
function Get-StartupCommand {
|
||||||
($env:PWSH_PATH ? "`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);" : "") +
|
($env:PWSH_PATH ? "`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);" : "") +
|
||||||
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
||||||
|
($env:BACKUP_ARCHIVE ? "`$env:BACKUP_ARCHIVE = $(ConvertTo-Injection (Resolve-Path $env:BACKUP_ARCHIVE));" : "") +
|
||||||
"`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +
|
"`$env:INSTALLER_SCRIPT = $(ConvertTo-Injection (Resolve-Path $env:INSTALLER_SCRIPT));" +
|
||||||
"`$env:CONFIG_MODULE = $(ConvertTo-Injection (Resolve-Path $env:CONFIG_MODULE));" +
|
"`$env:CONFIG_MODULE = $(ConvertTo-Injection (Resolve-Path $env:CONFIG_MODULE));" +
|
||||||
"& `$env:INSTALLER_SCRIPT;";
|
"& `$env:INSTALLER_SCRIPT;";
|
||||||
|
@ -166,18 +167,22 @@ $null = New-Module {
|
||||||
#>
|
#>
|
||||||
function Restart-Intermediate {
|
function Restart-Intermediate {
|
||||||
param(
|
param(
|
||||||
[Parameter(ParameterSetName="Default")]
|
[Parameter(ParameterSetName="None")]
|
||||||
|
[switch] $NoRegister,
|
||||||
|
[Parameter(ParameterSetName="Default", Mandatory)]
|
||||||
[switch] $DefaultUser,
|
[switch] $DefaultUser,
|
||||||
[Parameter(ParameterSetName="Current", Mandatory)]
|
[Parameter(ParameterSetName="Current", Mandatory)]
|
||||||
[switch] $CurrentUser
|
[switch] $CurrentUser
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($DefaultUser.IsPresent) {
|
if (-not $NoRegister.IsPresent) {
|
||||||
Register-Setup -DefaultUser;
|
if ($DefaultUser.IsPresent) {
|
||||||
} elseif ($CurrentUser.IsPresent) {
|
Register-Setup -DefaultUser;
|
||||||
Register-Setup -User;
|
} elseif ($CurrentUser.IsPresent) {
|
||||||
} else {
|
Register-Setup -User;
|
||||||
Register-Setup;
|
} else {
|
||||||
|
Register-Setup;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Restart-Computer -Force;
|
Restart-Computer -Force;
|
||||||
|
|
171
scripts/Windows/Scripts/Restoration.ps1
Normal file
171
scripts/Windows/Scripts/Restoration.ps1
Normal file
|
@ -0,0 +1,171 @@
|
||||||
|
using namespace System.Collections.Generic;
|
||||||
|
. "$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";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $Path) {
|
||||||
|
$Path = "Files";
|
||||||
|
}
|
||||||
|
|
||||||
|
$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,
|
||||||
|
[string[]] $Include,
|
||||||
|
[string[]] $Exclude
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($env:BACKUP_ARCHIVE) {
|
||||||
|
[List[string]] $argumentList = @();
|
||||||
|
$dir = New-TemporaryDirectory;
|
||||||
|
$targetPath = & $pathResolver @PSBoundParameters;
|
||||||
|
$fullPath = Join-Path $dir $targetPath;
|
||||||
|
$null = New-Item -ItemType Directory -Force (Split-Path -Parent $fullPath);
|
||||||
|
|
||||||
|
if (Test-Path -PathType Container $Source) {
|
||||||
|
$null = New-Item -ItemType Junction $fullPath -Target $Source;
|
||||||
|
} elseif (Test-Path -PathType Leaf $Source) {
|
||||||
|
$null = New-Item -ItemType Directory -Force $fullPath;
|
||||||
|
Copy-Item $Source $fullPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = @(
|
||||||
|
@("i", $Include),
|
||||||
|
@("x", $Exclude)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($option in $options) {
|
||||||
|
$indicator = $option[0];
|
||||||
|
$list = $option[1];
|
||||||
|
|
||||||
|
foreach ($pattern in $list) {
|
||||||
|
$argumentList.Add("-$indicator!`"$(Join-Path $targetPath $pattern)`"");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-Process `
|
||||||
|
-NoNewWindow `
|
||||||
|
-Wait `
|
||||||
|
-WorkingDirectory $dir `
|
||||||
|
-FilePath 7z `
|
||||||
|
-ArgumentList (
|
||||||
|
@(
|
||||||
|
"a",
|
||||||
|
(Get-ValhallaBackupArchive),
|
||||||
|
"-xr!desktop.ini",
|
||||||
|
"-xr!thumbs.db",
|
||||||
|
"-xr!Thumbs.db"
|
||||||
|
) + $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
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($env:BACKUP_ARCHIVE) {
|
||||||
|
$dir = New-TemporaryDirectory;
|
||||||
|
$sourcePath = & $pathResolver @PSBoundParameters;
|
||||||
|
$filePath = Join-Path $dir $sourcePath;
|
||||||
|
7z x "-o$dir" (Get-ValhallaBackupArchive) $sourcePath @ArgumentList;
|
||||||
|
|
||||||
|
if (Test-Path $filePath) {
|
||||||
|
if (Test-Path -PathType Container $filePath) {
|
||||||
|
$filePath = "$filePath/*";
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-Item -Recurse $filePath $Target -Force;
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove-Item -Recurse -Force $dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -22,11 +22,11 @@ function Update-WindowsInstallation {
|
||||||
catch { }
|
catch { }
|
||||||
|
|
||||||
if ((Get-WURebootStatus -Silent)) {
|
if ((Get-WURebootStatus -Silent)) {
|
||||||
Write-Information "A Reboot is Required!";
|
Write-Host "A Reboot is Required!";
|
||||||
Write-Information "Windows will reboot now and the installation will be continued automatically.";
|
Write-Host "Windows will reboot now and the installation will be continued automatically.";
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
Write-Information "Updating Windows finished successfully!";
|
Write-Host "Updating Windows finished successfully!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,122 @@ using namespace System.Management.Automation.Host;
|
||||||
using namespace System.Security.Principal;
|
using namespace System.Security.Principal;
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
|
. "$PSScriptRoot/../Scripts/Deployment.ps1";
|
||||||
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
|
. "$PSScriptRoot/../../Common/Scripts/Config.ps1";
|
||||||
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
|
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
|
||||||
$loggedInUserOption = "LoggedInUser";
|
$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) {
|
||||||
|
$userInfo = @{
|
||||||
|
name = $name;
|
||||||
|
msAccount = $msAccount;
|
||||||
|
};
|
||||||
|
|
||||||
|
New-ValhallaUser @userInfo;
|
||||||
|
|
||||||
|
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
|
.SYNOPSIS
|
||||||
Creates a new user for the PortValhalla setup.
|
Creates a new user for the PortValhalla setup.
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The name of the user to create.
|
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 {
|
function New-ValhallaUser {
|
||||||
param(
|
param(
|
||||||
[string] $Name
|
[string] $Name,
|
||||||
|
[switch] $MSAccount
|
||||||
)
|
)
|
||||||
|
|
||||||
function Add-MicrosoftAccount {
|
function Add-MicrosoftAccount {
|
||||||
|
@ -83,13 +185,18 @@ $null = New-Module {
|
||||||
Set-MSAccountName ([string]$newUser);
|
Set-MSAccountName ([string]$newUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
$msAccount = Get-UserConfig -UserName $Name "microsoftAccount";
|
if ($MSAccount) {
|
||||||
|
|
||||||
if ($msAccount) {
|
|
||||||
if (Test-Admin) {
|
if (Test-Admin) {
|
||||||
Write-Host "Preparing environment for creating MS Account";
|
Write-Host "Preparing environment for creating MS Account";
|
||||||
|
Register-Setup -DefaultUser;
|
||||||
Enable-OneShotListener;
|
Enable-OneShotListener;
|
||||||
Enable-UAC;
|
Enable-UAC;
|
||||||
|
|
||||||
|
# Reset Windows activation status
|
||||||
|
# Otherwise the login won't work - Windows is fricking frustrating.
|
||||||
|
slmgr /upk;
|
||||||
|
slmgr /cpky;
|
||||||
|
slmgr /rearm;
|
||||||
Restart-Intermediate -CurrentUser;
|
Restart-Intermediate -CurrentUser;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +204,7 @@ $null = New-Module {
|
||||||
|
|
||||||
Write-Host "Creating personal user ``$Name``…";
|
Write-Host "Creating personal user ``$Name``…";
|
||||||
|
|
||||||
if ($msAccount) {
|
if ($MSAccount) {
|
||||||
Add-MicrosoftAccount $Name;
|
Add-MicrosoftAccount $Name;
|
||||||
Set-SetupOption $loggedInUserOption $env:UserName;
|
Set-SetupOption $loggedInUserOption $env:UserName;
|
||||||
Invoke-OneShot ([OneShotTask]::InitializeMSAccount);
|
Invoke-OneShot ([OneShotTask]::InitializeMSAccount);
|
||||||
|
@ -114,7 +221,6 @@ $null = New-Module {
|
||||||
function Initialize-UserCreation {
|
function Initialize-UserCreation {
|
||||||
$name = (@(Get-Users))[(Get-CurrentUser)];
|
$name = (@(Get-Users))[(Get-CurrentUser)];
|
||||||
$msAccount = Get-UserConfig -UserName $name "microsoftAccount";
|
$msAccount = Get-UserConfig -UserName $name "microsoftAccount";
|
||||||
$displayName = Get-UserConfig -UserName $Name "displayName";
|
|
||||||
|
|
||||||
Write-Host "Initializing user ``$name``…";
|
Write-Host "Initializing user ``$name``…";
|
||||||
|
|
||||||
|
@ -122,10 +228,6 @@ $null = New-Module {
|
||||||
name = $name;
|
name = $name;
|
||||||
};
|
};
|
||||||
|
|
||||||
if ($displayName) {
|
|
||||||
$userArguments.fullName = $displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
$adminGroup = @{
|
$adminGroup = @{
|
||||||
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||||
};
|
};
|
||||||
|
|
115
scripts/Windows/Scripts/WSL.ps1
Normal file
115
scripts/Windows/Scripts/WSL.ps1
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
. "$PSScriptRoot/../Scripts/Security.ps1";
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the name of the WSL distribution used for managing the configuration.
|
||||||
|
#>
|
||||||
|
function Get-WslDistributionName {
|
||||||
|
return "ValhallaUbuntu";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the path to the directory containing the WSL distribution.
|
||||||
|
#>
|
||||||
|
function Get-WslDistributionPath {
|
||||||
|
return "$env:ProgramData/PortValhalla/$(Get-WslDistributionName)";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the path to the virtual hard disk of the WSL distribution.
|
||||||
|
#>
|
||||||
|
function Get-WslDistributionDisk {
|
||||||
|
return "$(Get-WslDistributionPath)/ext4.vhdx";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks whether `wsl` is installed properly.
|
||||||
|
#>
|
||||||
|
function Test-Wsl {
|
||||||
|
& { $null = wsl --status; $?; };
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks whether any WSL distributions are installed for the current user.
|
||||||
|
#>
|
||||||
|
function Test-WslDistributions {
|
||||||
|
& { $null = wsl -l; $?; };
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks whether the managed distribution is installed.
|
||||||
|
#>
|
||||||
|
function Test-WslDistribution {
|
||||||
|
& { $null = wsl -d (Get-WslDistributionName) -e true; $?; };
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Installs `wsl` on the system.
|
||||||
|
#>
|
||||||
|
function Install-Wsl {
|
||||||
|
wsl --install --no-launch;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Installs a Ubuntu distribution to a shared directory.
|
||||||
|
#>
|
||||||
|
function Install-WslDistribution {
|
||||||
|
$dir = Get-WslDistributionPath;
|
||||||
|
$root = Split-Path -Parent $dir;
|
||||||
|
$registryPath = "HKCU:/Software/Microsoft/Windows/CurrentVersion/Lxss";
|
||||||
|
$key = Get-Item $registryPath;
|
||||||
|
|
||||||
|
if ($key) {
|
||||||
|
$key = $key | Rename-Item -NewName "$(Split-Path -Leaf $key)_" -PassThru;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not (Test-Path $root)) {
|
||||||
|
$null = New-Item -ItemType Directory $root;
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-Item -Recurse (Get-AppxPackage "*Ubuntu*").InstallLocation $dir;
|
||||||
|
Set-UserPermissions $dir;
|
||||||
|
& "$dir\ubuntu.exe" install --root;
|
||||||
|
wsl --shutdown;
|
||||||
|
Remove-Item -Recurse -Force $registryPath;
|
||||||
|
|
||||||
|
if ($key) {
|
||||||
|
Move-Item $key.PSPath $registryPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Uninstalls the managed WSL distribution.
|
||||||
|
#>
|
||||||
|
function Uninstall-WslDistribution {
|
||||||
|
wsl --unregister (Get-WslDistributionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Registers the managed WSL distribution.
|
||||||
|
#>
|
||||||
|
function Register-WslDistribution {
|
||||||
|
wsl --import-in-place (Get-WslDistributionName) (Get-WslDistributionDisk);
|
||||||
|
wsl --set-default (Get-WslDistributionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Unregisters the managed WSL distribution.
|
||||||
|
#>
|
||||||
|
function Unregister-WslDistribution {
|
||||||
|
$wslDisk = Get-WslDistributionDisk;
|
||||||
|
wsl --shutdown;
|
||||||
|
$tempDisk = Rename-Item $wslDisk "ext4_.vhdx" -PassThru;
|
||||||
|
Uninstall-WslDistribution;
|
||||||
|
Move-Item $tempDisk $wslDisk;
|
||||||
|
}
|
|
@ -3,13 +3,81 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
|
||||||
|
$null = New-Module {
|
||||||
|
param ($Parameters)
|
||||||
|
$configPath = "$env:LocalAppData/LGHUB";
|
||||||
|
|
||||||
|
Export-ModuleMember -Function @();
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Stops the running Logitech G Hub instance.
|
||||||
|
#>
|
||||||
|
function Stop-LGHub {
|
||||||
|
[OutputType([string])]
|
||||||
|
param()
|
||||||
|
|
||||||
|
$hubName = "lghub_system_tray.exe";
|
||||||
|
$lghubPath = $(Get-Process | Where-Object { $_.Path -and ((Split-Path -Leaf $_.Path) -eq $hubName) })[0].Path;
|
||||||
|
|
||||||
|
$mainProcesses = Get-Process | Where-Object {
|
||||||
|
$_.Path -and
|
||||||
|
(@("lghub.exe", "lghub_agent.exe", $hubName) -contains (Split-Path -Leaf $_.Path)) -and
|
||||||
|
(($_.Parent.ProcessName -eq "explorer") -or ($null -eq $_.Parent))
|
||||||
|
};
|
||||||
|
|
||||||
|
$null = $mainProcesses | ForEach-Object { $_.Kill($true) };
|
||||||
|
return $lghubPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Edits the Logitech G Hub configuration.
|
||||||
|
#>
|
||||||
|
function Edit-LGHubConfig {
|
||||||
|
param(
|
||||||
|
[scriptblock] $Action
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Stopping Logitech G Hub";
|
||||||
|
$path = Stop-LGHub;
|
||||||
|
& $Action;
|
||||||
|
|
||||||
|
if ($path) {
|
||||||
|
Write-Host "Restarting Logitech G Hub";
|
||||||
|
Start-Process $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Installer {
|
||||||
|
Install-ChocoPackage lghub;
|
||||||
|
Remove-DesktopIcon "*G HUB*";
|
||||||
|
} `
|
||||||
|
-UserBackup {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Edit-LGHubConfig {
|
||||||
|
Add-BackupArtifacts -User $Arguments.Name -Source $configPath -Path "LGHub" `
|
||||||
|
-Include @("settings.db", "icon_cache")
|
||||||
|
};
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Edit-LGHubConfig {
|
||||||
|
Expand-BackupArtifacts -User $Arguments.Name -Path "LGHub" -Target $configPath;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
|
||||||
Install-ChocoPackage lghub;
|
|
||||||
Remove-DesktopIcon "*G HUB*";
|
|
||||||
};
|
|
||||||
|
|
||||||
# ToDo: Add restoration
|
# ToDo: Add restoration
|
||||||
|
|
|
@ -3,30 +3,123 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../Scripts/PowerManagement.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
& {
|
||||||
|
param($Parameters)
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the path to the Nextcloud configuration file.
|
||||||
|
#>
|
||||||
|
function Get-ConfigFile {
|
||||||
|
return "$env:APPDATA/Nextcloud/nextcloud.cfg";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Adds a new nextcloud sync to the current user.
|
||||||
|
#>
|
||||||
|
function Add-NextcloudSync {
|
||||||
|
param(
|
||||||
|
[string] $RemotePath,
|
||||||
|
[string] $LocalPath,
|
||||||
|
[switch] $VirtualFiles
|
||||||
|
)
|
||||||
|
|
||||||
|
Write-Host "Adding a Nextcloud sync";
|
||||||
|
Write-Host "$RemotePath <=> $LocalPath";
|
||||||
|
$configName = "Folders";
|
||||||
|
$virtualName = "WithPlaceholders";
|
||||||
|
$LocalPath = $LocalPath.Replace("\", "/");
|
||||||
|
$RemotePath = $RemotePath.Replace("\", "/");
|
||||||
|
$oldContent = Get-Content (Get-ConfigFile);
|
||||||
|
$additionalSettings = @();
|
||||||
|
$pattern = "^\d+\\$configName(?:$virtualName)?\\(\d+)";
|
||||||
|
|
||||||
|
$folderID = (
|
||||||
|
$oldContent | `
|
||||||
|
Where-Object { $_ -match "$pattern" } | `
|
||||||
|
ForEach-Object { $_ -replace "$pattern.*$","`$1" } | `
|
||||||
|
Sort-Object -Unique | `
|
||||||
|
Measure-Object -Maximum).Maximum + 1;
|
||||||
|
|
||||||
|
if ($VirtualFiles.IsPresent) {
|
||||||
|
$configName += $virtualName;
|
||||||
|
$additionalSettings = @("0\$configName\$folderID\virtualFilesMode=wincfapi");
|
||||||
|
}
|
||||||
|
|
||||||
|
$newSettings = (
|
||||||
|
@(
|
||||||
|
"0\$configName\$folderID\localPath=$LocalPath",
|
||||||
|
"0\$configName\$folderID\targetPath=$RemotePath"
|
||||||
|
) + $additionalSettings
|
||||||
|
) -join "`n";
|
||||||
|
|
||||||
|
& {
|
||||||
|
$accountSectionEntered = $false;
|
||||||
|
$accountSectionLeft = $false;
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt $oldContent.Count; $i++) {
|
||||||
|
$line = $oldContent[$i];
|
||||||
|
|
||||||
|
if ($line -eq "[Accounts]") {
|
||||||
|
$accountSectionEntered = $true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($line -eq "" -and $accountSectionEntered) {
|
||||||
|
$accountSectionLeft = $true;
|
||||||
|
$newSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
$line;
|
||||||
|
|
||||||
|
if (
|
||||||
|
(-not $accountSectionLeft) -and
|
||||||
|
($i -eq ($oldContent.Count - 1))) {
|
||||||
|
$newSettings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} | Set-Content (Get-ConfigFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
Install-ChocoPackage nextcloud-client -ArgumentList "-y","--params='/KeepUpdateCheck'";
|
Install-ChocoPackage nextcloud-client -ArgumentList "-y","--params='/KeepUpdateCheck'";
|
||||||
} `
|
} `
|
||||||
-UserConfigurator {
|
-UserConfigurator {
|
||||||
if (-not (Test-Path $context.GetNextcloudConfigFile())) {
|
param($Arguments)
|
||||||
Write-Information "Setting up Nextcloud configuration";
|
$user = $Arguments.Name;
|
||||||
|
|
||||||
Write-Information "Ensuring all Let's Encrypt certificates are cached";
|
& {
|
||||||
$null = Invoke-WebRequest https://valid-isrgrootx1.letsencrypt.org/;
|
$syncs = Get-UserConfig -UserName $user "nextcloud.folderSyncs";
|
||||||
|
$configExists = { (Test-Path (Get-ConfigFile) ) };
|
||||||
|
|
||||||
while (-not (Test-Path $context.GetNextcloudConfigFile())) {
|
if ($syncs.Count -gt 0) {
|
||||||
Write-Host "Nextcloud has been installed!";
|
if (-not (& $configExists)) {
|
||||||
Read-Host "Please log in in the Nextcloud app and hit enter to continue";
|
while (-not (& $configExists)) {
|
||||||
|
Read-Host "Please log in to the Nextcloud app and hit enter to continue";
|
||||||
if (-not (Test-Path $context.GetNextcloudConfigFile())) {
|
|
||||||
Write-Error "The login seems to have failed. Please try again.";
|
if (-not (& $configExists)) {
|
||||||
|
Write-Error -ErrorAction Continue "The login seems to have failed. Please try again.";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host "Stopping Nextcloud process";
|
||||||
|
$nextcloudProcess = Get-Process nextcloud;
|
||||||
|
$nextcloudPath = [string]$nextcloudProcess[0].Path;
|
||||||
|
$nextcloudProcess | Stop-Process -Force;
|
||||||
|
|
||||||
|
foreach ($sync in $syncs) {
|
||||||
|
Add-NextcloudSync -LocalPath $sync.localPath -RemotePath $sync.remotePath -VirtualFiles:$sync.virtualFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Restarting Nextcloud";
|
||||||
|
Start-Process $nextcloudPath;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
$context.Reboot();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
|
@ -21,12 +21,15 @@ Start-SoftwareInstaller @parameters -Installer {
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
$feature = "NetFx3";
|
$module = $Arguments.Name;
|
||||||
|
|
||||||
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
|
|
||||||
Write-Host "Enabling ``$feature`` feature…";
|
|
||||||
choco install --source windowsFeatures -y $feature;
|
|
||||||
}
|
|
||||||
|
|
||||||
& $Arguments.Installer @PSBoundParameters;
|
& $Arguments.Installer @PSBoundParameters;
|
||||||
|
|
||||||
|
if (-not (& { powershell -Command "Import-Module $module"; $?; })) {
|
||||||
|
$feature = "NetFx3";
|
||||||
|
|
||||||
|
if ((Get-WindowsOptionalFeature -Online -NoRestart -FeatureName $feature).State -ne "Enabled") {
|
||||||
|
Write-Host "Enabling ``$feature`` feature…";
|
||||||
|
choco install --source windowsFeatures -y $feature;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,14 @@ param(
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
Install-ChocoPackage retroarch;
|
Install-ChocoPackage retroarch;
|
||||||
# ToDo: Add start menu shortcut
|
} `
|
||||||
# ToDo: Add function for this purpose
|
-Configurator {
|
||||||
|
Add-StartMenuIcon "RetroArch" "C:\tools\RetroArch-Win64\retroarch.exe";
|
||||||
};
|
};
|
||||||
|
|
||||||
# ToDo: Add restoration
|
# ToDo: Add restoration
|
||||||
|
|
|
@ -12,10 +12,10 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
Write-Information "Enabling the ``$feature`` feature…";
|
Write-Information "Enabling the ``$feature`` feature…";
|
||||||
choco install --source windowsFeatures -y $feature;
|
choco install --source windowsFeatures -y $feature;
|
||||||
}
|
}
|
||||||
|
|
||||||
Install-WingetPackage Nadeo.TrackManiaNationsForever;
|
|
||||||
Remove-DesktopIcon "*TmNationsForever*";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Install-WingetPackage Nadeo.TrackManiaNationsForever;
|
||||||
|
Remove-DesktopIcon "*TmNationsForever*";
|
||||||
};
|
};
|
||||||
|
|
||||||
# ToDo: Add restoration
|
# ToDo: Add restoration
|
||||||
|
|
|
@ -11,10 +11,6 @@ param(
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
Install-ChocoPackage winscp;
|
Install-ChocoPackage winscp;
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
|
|
37
scripts/Windows/Software/Windows/Home.exclude.txt
Normal file
37
scripts/Windows/Software/Windows/Home.exclude.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
Pictures/Feedback
|
||||||
|
Documents/BeamNG.drive
|
||||||
|
Documents/Default.rdp
|
||||||
|
Documents/den4b/ReNamer
|
||||||
|
Documents/Dolphin Emulator
|
||||||
|
Documents/eFisc
|
||||||
|
Documents/IISExpress
|
||||||
|
Documents/KINGDOM HEARTS HD 1.5+2.5 ReMIX
|
||||||
|
Documents/ManiaPlanet
|
||||||
|
Documents/MetaX
|
||||||
|
Documents/MuseScore3
|
||||||
|
Documents/My Web Sites
|
||||||
|
Documents/OneNote-Notizbücher
|
||||||
|
Documents/PCSX2
|
||||||
|
Documents/PowerShell
|
||||||
|
Documents/PPSSPP
|
||||||
|
Documents/PS Vita
|
||||||
|
Documents/PSV Packages
|
||||||
|
Documents/PSV Updates
|
||||||
|
Documents/Repositories
|
||||||
|
Documents/Rise of the Tomb Raider
|
||||||
|
Documents/S2
|
||||||
|
Documents/SEGA
|
||||||
|
Documents/SEGA Mega Drive Classics
|
||||||
|
Documents/SQL Server Management Studio
|
||||||
|
Documents/Square Enix
|
||||||
|
Documents/TI-Nspire CX
|
||||||
|
Documents/TmForever
|
||||||
|
Documents/TrackMania
|
||||||
|
Documents/UltraVNC
|
||||||
|
Documents/Visual Studio 2017
|
||||||
|
Documents/Visual Studio 2019
|
||||||
|
Documents/Visual Studio 2022
|
||||||
|
Documents/Viwizard M4V Converter
|
||||||
|
Documents/WindowsPowerShell
|
||||||
|
Documents/Zoom
|
||||||
|
Music/iTunes
|
|
@ -5,13 +5,41 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../Scripts/Registry.ps1";
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Config.ps1";
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
$null = New-Module {
|
||||||
|
param($Parameters)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../Scripts/Registry.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Config.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
|
|
||||||
|
$userFolders = @(
|
||||||
|
"Pictures",
|
||||||
|
"Documents",
|
||||||
|
"Downloads",
|
||||||
|
"Music",
|
||||||
|
"Videos"
|
||||||
|
);
|
||||||
|
|
||||||
|
$userExclusions = @(
|
||||||
|
"Documents/Eigene*",
|
||||||
|
"Documents/My Games",
|
||||||
|
"Documents/My Music",
|
||||||
|
"Documents/My Pictures",
|
||||||
|
"Documents/My Videos"
|
||||||
|
);
|
||||||
|
|
||||||
|
[string[]] $homeExclusions = Get-Content "$PSScriptRoot/Home.exclude.txt";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Backup {
|
||||||
|
Add-BackupArtifacts -Source "$env:PUBLIC" -Path "Public" `
|
||||||
|
-Include ($userFolders) `
|
||||||
|
-Exclude ($userExclusions + @("Documents/Hyper-V", "Documents/reWASD"));
|
||||||
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
$dir = New-TemporaryDirectory;
|
$dir = New-TemporaryDirectory;
|
||||||
Push-Location $dir;
|
Push-Location $dir;
|
||||||
|
@ -54,7 +82,7 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
)
|
)
|
||||||
|
|
||||||
$path = "$($Key.PSPath)\Software\Microsoft\Lighting";
|
$path = "$($Key.PSPath)\Software\Microsoft\Lighting";
|
||||||
$null = New-Item $path;
|
$null = New-Item $path -ErrorAction SilentlyContinue;
|
||||||
Set-ItemProperty $path -Name "AmbientLightingEnabled" -Value 0 -Type "DWord";
|
Set-ItemProperty $path -Name "AmbientLightingEnabled" -Value 0 -Type "DWord";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -136,4 +164,20 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
|
|
||||||
Pop-Location;
|
Pop-Location;
|
||||||
Remove-Item -Recurse $dir;
|
Remove-Item -Recurse $dir;
|
||||||
|
Expand-BackupArtifacts -Path "Public" -Target $env:PUBLIC;
|
||||||
|
} `
|
||||||
|
-UserBackup {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Add-BackupArtifacts -User $Arguments.Name -Source $HOME -Path "Home" -Include ($userFolders) -Exclude ($userExclusions + $homeExclusions);
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Expand-BackupArtifacts -User $Arguments.Name -Path "Home" -Target $HOME;
|
||||||
};
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
|
@ -17,10 +17,6 @@ param (
|
||||||
|
|
||||||
Start-SoftwareInstaller @Parameters `
|
Start-SoftwareInstaller @Parameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
$params = "/WindowsTerminalProfile";
|
$params = "/WindowsTerminalProfile";
|
||||||
$defaultBranch = Get-Config "valhalla.git.defaultBranch";
|
$defaultBranch = Get-Config "valhalla.git.defaultBranch";
|
||||||
|
|
||||||
|
|
|
@ -8,23 +8,7 @@ param(
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
$file = "osu!lazer.exe";
|
Install-WingetPackage "ppy.osu";
|
||||||
$processName = "osu!";
|
|
||||||
$dir = New-TemporaryDirectory;
|
|
||||||
|
|
||||||
Push-Location $dir;
|
|
||||||
Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $file;
|
|
||||||
Start-Process -FilePath $file;
|
|
||||||
|
|
||||||
while (-not (Get-Process -ErrorAction SilentlyContinue $processName)) {
|
|
||||||
Start-Sleep 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Start-Sleep 10;
|
|
||||||
Get-Process $processName | Stop-Process -Force;
|
|
||||||
Pop-Location;
|
|
||||||
Remove-Item -Recurse $dir;
|
|
||||||
|
|
||||||
Remove-DesktopIcon "*osu*";
|
Remove-DesktopIcon "*osu*";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
4
scripts/Windows/Types/WindowsInstallerAction.ps1
Normal file
4
scripts/Windows/Types/WindowsInstallerAction.ps1
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
enum WindowsInstallerAction {
|
||||||
|
Backup
|
||||||
|
Install
|
||||||
|
}
|
|
@ -16,6 +16,7 @@ begin
|
||||||
argparse --name (status filename) -x "iso,usb" "iso" "usb" "debug" -- $argv
|
argparse --name (status filename) -x "iso,usb" "iso" "usb" "debug" -- $argv
|
||||||
or exit 1
|
or exit 1
|
||||||
|
|
||||||
|
set -l mountDir "/mnt"
|
||||||
set -l setupLabel "winiso-valhalla"
|
set -l setupLabel "winiso-valhalla"
|
||||||
set -l projectPath "PortValhalla"
|
set -l projectPath "PortValhalla"
|
||||||
set -l systemDrivePath "sources/\$OEM\$/\$1"
|
set -l systemDrivePath "sources/\$OEM\$/\$1"
|
||||||
|
@ -23,9 +24,9 @@ begin
|
||||||
set -l localProjectPath "$systemDrivePath/$projectPath"
|
set -l localProjectPath "$systemDrivePath/$projectPath"
|
||||||
set -l cacheDir ~/.cache/winiso-valhalla
|
set -l cacheDir ~/.cache/winiso-valhalla
|
||||||
set -l winpe "$cacheDir/winpe.iso"
|
set -l winpe "$cacheDir/winpe.iso"
|
||||||
set -l winPath "/media/win"
|
set -l winPath "$mountDir/win"
|
||||||
set -l winpePath "/media/winpe"
|
set -l winpePath "$mountDir/winpe"
|
||||||
set -l valhallaPath "/media/winiso-valhalla"
|
set -l valhallaPath "$mountDir/winiso-valhalla"
|
||||||
set -l winpeOverlay (mktemp -d)
|
set -l winpeOverlay (mktemp -d)
|
||||||
set -l winOverlay (mktemp -d)
|
set -l winOverlay (mktemp -d)
|
||||||
set -l upperDir (mktemp -d)
|
set -l upperDir (mktemp -d)
|
||||||
|
@ -202,7 +203,7 @@ begin
|
||||||
|
|
||||||
find "$projectPath/profiles" -type f -name "*.nix" | while read -l file
|
find "$projectPath/profiles" -type f -name "*.nix" | while read -l file
|
||||||
set -l CONFIG_MODULE "$file"
|
set -l CONFIG_MODULE "$file"
|
||||||
getConfig "valhalla.windows" --json > "$file.json"
|
getConfig "valhalla.windows.config" --json > "$file.json"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -228,8 +229,8 @@ begin
|
||||||
-output "$isoFile" \
|
-output "$isoFile" \
|
||||||
"$valhallaPath"
|
"$valhallaPath"
|
||||||
else
|
else
|
||||||
set -l bootPath "/media/boot"
|
set -l bootPath "$mountDir/boot"
|
||||||
set -l dataPath "/media/data"
|
set -l dataPath "$mountDir/data"
|
||||||
|
|
||||||
set -a mountPaths \
|
set -a mountPaths \
|
||||||
"$bootPath" \
|
"$bootPath" \
|
||||||
|
|
Loading…
Reference in a new issue