Compare commits
189 commits
bce3ff17a3
...
879c4bc5d4
Author | SHA1 | Date | |
---|---|---|---|
Manuel Thalmann | 879c4bc5d4 | ||
Manuel Thalmann | 2025fa8afd | ||
Manuel Thalmann | c483d13e73 | ||
Manuel Thalmann | cc657ca0d8 | ||
Manuel Thalmann | 36332b92c5 | ||
Manuel Thalmann | 11cc9b1c65 | ||
Manuel Thalmann | 07ce2f2de5 | ||
Manuel Thalmann | e08e9559e1 | ||
Manuel Thalmann | dde27d8fde | ||
Manuel Thalmann | 74d6e80560 | ||
Manuel Thalmann | 14cdf638f5 | ||
Manuel Thalmann | abb07af518 | ||
Manuel Thalmann | 4342645275 | ||
Manuel Thalmann | 54cbbaf548 | ||
Manuel Thalmann | fde93b0b9a | ||
Manuel Thalmann | 2d8e1e9572 | ||
Manuel Thalmann | 15d38ca5ed | ||
Manuel Thalmann | f47d858806 | ||
Manuel Thalmann | f4cc0514dd | ||
Manuel Thalmann | eb0ca51bb5 | ||
Manuel Thalmann | 000fb9237e | ||
Manuel Thalmann | 0fecb0546c | ||
Manuel Thalmann | ab4d874aae | ||
Manuel Thalmann | 7b2eb20220 | ||
Manuel Thalmann | 185b19f6fd | ||
Manuel Thalmann | 3c01f7802d | ||
Manuel Thalmann | 6096a088f3 | ||
Manuel Thalmann | 0b60d65696 | ||
Manuel Thalmann | d1de499daf | ||
Manuel Thalmann | 8fa4396b2a | ||
Manuel Thalmann | ace3d59d39 | ||
Manuel Thalmann | 28b32263c0 | ||
Manuel Thalmann | 7c84dfdedd | ||
Manuel Thalmann | 0e2a70903f | ||
Manuel Thalmann | 044c20461c | ||
Manuel Thalmann | 4eb25a2d71 | ||
Manuel Thalmann | 9ccf2806ec | ||
Manuel Thalmann | e09d5b1613 | ||
Manuel Thalmann | 909fd1a2e5 | ||
Manuel Thalmann | 5741d30539 | ||
Manuel Thalmann | 03d158a5ff | ||
Manuel Thalmann | 8ef5920789 | ||
Manuel Thalmann | 4f9957dad4 | ||
Manuel Thalmann | c292a3c7fc | ||
Manuel Thalmann | 6022adac79 | ||
Manuel Thalmann | 9a37921063 | ||
Manuel Thalmann | e0b5abe72b | ||
Manuel Thalmann | 0f67360232 | ||
Manuel Thalmann | fd53dd903e | ||
Manuel Thalmann | fb633298ba | ||
Manuel Thalmann | 2afaff1999 | ||
Manuel Thalmann | 94f5657ea7 | ||
Manuel Thalmann | beb97a95f5 | ||
Manuel Thalmann | f9a68c631c | ||
Manuel Thalmann | 3a0f841160 | ||
Manuel Thalmann | 6c615c4707 | ||
Manuel Thalmann | 8b0048c7ee | ||
Manuel Thalmann | 273f3c9965 | ||
Manuel Thalmann | 4f8c3b1c4d | ||
Manuel Thalmann | 496620d367 | ||
Manuel Thalmann | 1ac885964e | ||
Manuel Thalmann | 493944f358 | ||
Manuel Thalmann | 5daeb40d88 | ||
Manuel Thalmann | 2728c45ac5 | ||
Manuel Thalmann | fa5b462312 | ||
Manuel Thalmann | cfbe29eb0e | ||
Manuel Thalmann | 64e6e62c29 | ||
Manuel Thalmann | ff925b57d7 | ||
Manuel Thalmann | dd11967f95 | ||
Manuel Thalmann | a4577812b3 | ||
Manuel Thalmann | 1da7ad2a44 | ||
Manuel Thalmann | a9f2abf033 | ||
Manuel Thalmann | 758502ae08 | ||
Manuel Thalmann | e064c55087 | ||
Manuel Thalmann | 196e530627 | ||
Manuel Thalmann | e89a34b304 | ||
Manuel Thalmann | 576e52d604 | ||
Manuel Thalmann | 4900b6b081 | ||
Manuel Thalmann | 21907e77f6 | ||
Manuel Thalmann | e63d263247 | ||
Manuel Thalmann | d10c040e4e | ||
Manuel Thalmann | 147f67e11c | ||
Manuel Thalmann | a4819bf1c6 | ||
Manuel Thalmann | b495406999 | ||
Manuel Thalmann | 3dd2c7de8f | ||
Manuel Thalmann | bedde68d66 | ||
Manuel Thalmann | 3b0baae206 | ||
Manuel Thalmann | 60e47dc297 | ||
Manuel Thalmann | ab4b6dc63c | ||
Manuel Thalmann | 0ad9e94a1f | ||
Manuel Thalmann | 896c6fb2fb | ||
Manuel Thalmann | 87fc264f6b | ||
Manuel Thalmann | 1d5b147b21 | ||
Manuel Thalmann | 0bdf6e33ed | ||
Manuel Thalmann | e24dbe89f9 | ||
Manuel Thalmann | 4c6f9d8dbf | ||
Manuel Thalmann | 689e55b6d7 | ||
Manuel Thalmann | e40d22676c | ||
Manuel Thalmann | 8ccef0e870 | ||
Manuel Thalmann | 361827218b | ||
Manuel Thalmann | fedd304543 | ||
Manuel Thalmann | fd1a6f2973 | ||
Manuel Thalmann | 4c9568f974 | ||
Manuel Thalmann | cf04b3d320 | ||
Manuel Thalmann | 865fc519f0 | ||
Manuel Thalmann | 1445192c55 | ||
Manuel Thalmann | 4d7cc6f567 | ||
Manuel Thalmann | 727a80b24c | ||
Manuel Thalmann | c81f63b416 | ||
Manuel Thalmann | 3aa6967734 | ||
Manuel Thalmann | fc2bf2276c | ||
Manuel Thalmann | 720ec85bf0 | ||
Manuel Thalmann | 47f6d45da6 | ||
Manuel Thalmann | 7d6c3d6a60 | ||
Manuel Thalmann | 6cade00931 | ||
Manuel Thalmann | b2f5dd6fc1 | ||
Manuel Thalmann | 3c4f794d0a | ||
Manuel Thalmann | 9b5c9d1126 | ||
Manuel Thalmann | b303844e4a | ||
Manuel Thalmann | 2afc7a0c69 | ||
Manuel Thalmann | 834aaa2d5b | ||
Manuel Thalmann | fe48bbe881 | ||
Manuel Thalmann | 110d55a302 | ||
Manuel Thalmann | f063536b7d | ||
Manuel Thalmann | 06c9f61030 | ||
Manuel Thalmann | 317509167d | ||
Manuel Thalmann | 51655b2291 | ||
Manuel Thalmann | 539780ba3c | ||
Manuel Thalmann | 899eddf507 | ||
Manuel Thalmann | d82c3ae1e9 | ||
Manuel Thalmann | b441e9231a | ||
Manuel Thalmann | 83165588f9 | ||
Manuel Thalmann | d00d571194 | ||
Manuel Thalmann | 977fe76248 | ||
Manuel Thalmann | 187f0d465a | ||
Manuel Thalmann | 4c587f87b1 | ||
Manuel Thalmann | d871b48864 | ||
Manuel Thalmann | 7feae37eb9 | ||
Manuel Thalmann | d2dbe59071 | ||
Manuel Thalmann | d029018563 | ||
Manuel Thalmann | 72d46420f4 | ||
Manuel Thalmann | f5359efad7 | ||
Manuel Thalmann | 8e3abf6087 | ||
Manuel Thalmann | 4f89c167cb | ||
Manuel Thalmann | 4d56597f86 | ||
Manuel Thalmann | 4dccba5632 | ||
Manuel Thalmann | fae955e126 | ||
Manuel Thalmann | 59e61b6ea8 | ||
Manuel Thalmann | 8eecac02bf | ||
Manuel Thalmann | 345b3fb1df | ||
Manuel Thalmann | d8596f0a58 | ||
Manuel Thalmann | df57160ef5 | ||
Manuel Thalmann | 2f59726682 | ||
Manuel Thalmann | 7dbf75e591 | ||
Manuel Thalmann | 0b2824cf9e | ||
Manuel Thalmann | bd8224b3f4 | ||
Manuel Thalmann | 5c0e462cc7 | ||
Manuel Thalmann | 7015a69d16 | ||
Manuel Thalmann | 0a23112e2c | ||
Manuel Thalmann | d684d1ec42 | ||
Manuel Thalmann | 40b3472700 | ||
Manuel Thalmann | 24ff14ca99 | ||
Manuel Thalmann | 60074b9ad0 | ||
Manuel Thalmann | 73c0f0913e | ||
Manuel Thalmann | ff8b949b35 | ||
Manuel Thalmann | 6a73d54056 | ||
Manuel Thalmann | 0d8ea792fc | ||
Manuel Thalmann | f3e70d2908 | ||
Manuel Thalmann | a3a3b5e9b4 | ||
Manuel Thalmann | cb0af07f0c | ||
Manuel Thalmann | 36dd010efb | ||
Manuel Thalmann | 1e198093cc | ||
Manuel Thalmann | d6a85c8cda | ||
Manuel Thalmann | fac547f4be | ||
Manuel Thalmann | 1ff78c6769 | ||
Manuel Thalmann | 18a0b3d577 | ||
Manuel Thalmann | 318a880b5f | ||
Manuel Thalmann | fcfc58ff7e | ||
Manuel Thalmann | 580cbd2f2a | ||
Manuel Thalmann | a9090b9b9c | ||
Manuel Thalmann | 908a847bbe | ||
Manuel Thalmann | df0a2847c4 | ||
Manuel Thalmann | dfc70a2b0c | ||
Manuel Thalmann | 6db6fd02ee | ||
Manuel Thalmann | b504ee0979 | ||
Manuel Thalmann | 234a0f17d5 | ||
Manuel Thalmann | 77ed70468e | ||
Manuel Thalmann | e0771278a5 | ||
Manuel Thalmann | 2fd325d580 |
|
@ -23,7 +23,7 @@ automated_script() {
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
printf '%s: downloading %s\n' "$0" "${script}"
|
printf '%s: downloading %s\n' "$0" "${script}"
|
||||||
curl "${script}" --location --retry-connrefused --retry 10 -s -o /tmp/startup_script
|
curl "${script}" --location --retry-connrefused --retry 10 --fail -s -o /tmp/startup_script
|
||||||
rt=$?
|
rt=$?
|
||||||
else
|
else
|
||||||
cp "${script}" /tmp/startup_script
|
cp "${script}" /tmp/startup_script
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
diff --git a/airootfs/root/.zlogin b/airootfs/root/.zlogin
|
diff --git a/airootfs/root/.zlogin b/airootfs/root/.zlogin
|
||||||
index bf6bc8f..76e5893 100755
|
index bf6bc8f..a0dae7b 100755
|
||||||
--- a/airootfs/root/.zlogin
|
--- a/airootfs/root/.zlogin
|
||||||
+++ b/airootfs/root/.zlogin
|
+++ b/airootfs/root/.zlogin
|
||||||
@@ -4,3 +4,18 @@ if grep -Fqa 'accessibility=' /proc/cmdline &> /dev/null; then
|
@@ -4,3 +4,19 @@ if grep -Fqa 'accessibility=' /proc/cmdline &> /dev/null; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
~/.automated_script.sh
|
~/.automated_script.sh
|
||||||
|
@ -16,13 +16,14 @@ index bf6bc8f..76e5893 100755
|
||||||
+
|
+
|
||||||
+git diff -p -R --no-ext-diff --no-color --diff-filter=M \
|
+git diff -p -R --no-ext-diff --no-color --diff-filter=M \
|
||||||
+ | grep -E "^(diff|(old|new) mode)" --color=never \
|
+ | grep -E "^(diff|(old|new) mode)" --color=never \
|
||||||
|
+ | sed "/^diff/{ x; d; }; x; /./{ p; z; }; x;" \
|
||||||
+ | git apply
|
+ | git apply
|
||||||
+
|
+
|
||||||
+popd > /dev/null
|
+popd > /dev/null
|
||||||
+
|
+
|
||||||
+loadkeys de_CH-latin1
|
+loadkeys de_CH-latin1
|
||||||
diff --git a/packages.x86_64 b/packages.x86_64
|
diff --git a/packages.x86_64 b/packages.x86_64
|
||||||
index 9e876e7..b89ab30 100755
|
index 9e876e7..c5db92a 100755
|
||||||
--- a/packages.x86_64
|
--- a/packages.x86_64
|
||||||
+++ b/packages.x86_64
|
+++ b/packages.x86_64
|
||||||
@@ -30,8 +30,10 @@ ethtool
|
@@ -30,8 +30,10 @@ ethtool
|
||||||
|
@ -36,7 +37,15 @@ index 9e876e7..b89ab30 100755
|
||||||
gnu-netcat
|
gnu-netcat
|
||||||
gpart
|
gpart
|
||||||
gpm
|
gpm
|
||||||
@@ -75,6 +77,7 @@ nbd
|
@@ -45,6 +47,7 @@ irssi
|
||||||
|
iw
|
||||||
|
iwd
|
||||||
|
jfsutils
|
||||||
|
+jq
|
||||||
|
kitty-terminfo
|
||||||
|
ldns
|
||||||
|
less
|
||||||
|
@@ -75,6 +78,7 @@ nbd
|
||||||
ndisc6
|
ndisc6
|
||||||
nfs-utils
|
nfs-utils
|
||||||
nilfs-utils
|
nilfs-utils
|
||||||
|
|
10
flake.nix
10
flake.nix
|
@ -6,7 +6,7 @@
|
||||||
flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a";
|
flake-utils.url = "github:numtide/flake-utils?ref=b1d9ab70662946ef0850d488da1c9019f3a9752a";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, flake-utils, nixpkgs }: flake-utils.lib.eachDefaultSystem (
|
outputs = { self, flake-utils, nixpkgs }: (flake-utils.lib.eachDefaultSystem (
|
||||||
system:
|
system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
|
@ -32,5 +32,11 @@
|
||||||
packages = {
|
packages = {
|
||||||
archiso = pkgs.archiso;
|
archiso = pkgs.archiso;
|
||||||
};
|
};
|
||||||
});
|
})) // {
|
||||||
|
valhalla = {
|
||||||
|
"DerGeret Windows" = import ./profiles/DerGeret/config.nix;
|
||||||
|
"der-geret Arch Linux" = import ./profiles/DerGeret/Arch/config.nix;
|
||||||
|
"manu-surface Arch Linux" = import ./profiles/ManuSurface/Arch/config.nix;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
{ lib, ... }: {
|
|
||||||
options = {
|
|
||||||
valhalla = {
|
|
||||||
git = (import ./git/options.nix) { inherit lib; };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
{ lib, ... }:
|
|
||||||
let
|
|
||||||
inherit (lib)
|
|
||||||
mkOption
|
|
||||||
types
|
|
||||||
;
|
|
||||||
in {
|
|
||||||
defaultBranch = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
description = "The name of the default branch in git.";
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
flow = {
|
|
||||||
mainBranch = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
description = "The name of the stable branch in git flow.";
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
devBranch = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
description = "The name of the development branch in git flow.";
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
aliases = mkOption {
|
|
||||||
type = types.attrsOf types.str;
|
|
||||||
description = "Git command aliases to install.";
|
|
||||||
default = {};
|
|
||||||
};
|
|
||||||
}
|
|
52
lib/modules/os.nix
Normal file
52
lib/modules/os.nix
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
valhalla = mkOption {
|
||||||
|
type = types.submodule (
|
||||||
|
{ extendModules, ... }:
|
||||||
|
let
|
||||||
|
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 { };
|
||||||
|
windowsVariant = osVariant.extendModules { };
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
linux = mkOption {
|
||||||
|
inherit (linuxVariant) type;
|
||||||
|
description = "The options for setting up Linux.";
|
||||||
|
default = {};
|
||||||
|
visible = "shallow";
|
||||||
|
};
|
||||||
|
|
||||||
|
windows = mkOption {
|
||||||
|
inherit (windowsVariant) type;
|
||||||
|
description = "The options for setting up Windows.";
|
||||||
|
default = {};
|
||||||
|
visible = "shallow";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
description = "Configuration for PortValhalla.";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
59
lib/modules/packages/git.nix
Normal file
59
lib/modules/packages/git.nix
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
|
gitType = types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
defaultBranch = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The name of the default branch in newly created repositories.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
flow = {
|
||||||
|
mainBranch = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The name of the stable branch in git flow.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
devBranch = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The name of the development branch in git flow.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
aliases = mkOption {
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
description = "The git command aliases to install.";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
gitOption = mkOption {
|
||||||
|
type = gitType;
|
||||||
|
description = "The git related options.";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
valhalla = {
|
||||||
|
git = gitOption;
|
||||||
|
|
||||||
|
users = mkOption {
|
||||||
|
type = types.attrsOf (types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
git = gitOption;
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
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 = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
60
lib/modules/packages/oh-my-posh.nix
Normal file
60
lib/modules/packages/oh-my-posh.nix
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
|
themeType = types.submodule (
|
||||||
|
{ config, ... }: {
|
||||||
|
options = {
|
||||||
|
source = mkOption {
|
||||||
|
type = types.nullOr types.path;
|
||||||
|
description = "The path to the oh-my-posh theme to use.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
name = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The name of the theme.";
|
||||||
|
default = if (config.source != null)
|
||||||
|
then
|
||||||
|
lib.strings.removeSuffix ".omp" (lib.strings.removeSuffix ".json" (builtins.baseNameOf config.source))
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
ompType = types.submodule (
|
||||||
|
{ config, ... }: {
|
||||||
|
options = {
|
||||||
|
theme = mkOption {
|
||||||
|
type = types.either types.str themeType;
|
||||||
|
description = "The default theme.";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
additionalThemes = mkOption {
|
||||||
|
type = types.listOf themeType;
|
||||||
|
description = "A set of additional themes to install.";
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
valhalla.users = mkOption {
|
||||||
|
type = types.attrsOf (types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
oh-my-posh = mkOption {
|
||||||
|
type = ompType;
|
||||||
|
description = "The Oh My Posh configuration to apply.";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
40
lib/modules/packages/rclone.nix
Normal file
40
lib/modules/packages/rclone.nix
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkOption
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
|
syncType = types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
dirName = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The name of the directory to sync the remote files to.";
|
||||||
|
};
|
||||||
|
|
||||||
|
cacheDuration = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The amount of time to keep cached files.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
valhalla.linux.users = mkOption {
|
||||||
|
type = types.attrsOf (types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
rclone = {
|
||||||
|
configurations = mkOption {
|
||||||
|
type = types.attrsOf syncType;
|
||||||
|
description = "The configurations of the rclone mounts.";
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,84 +1,56 @@
|
||||||
{ 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;
|
||||||
|
|
||||||
linuxOptions = {
|
userType = types.submodule (
|
||||||
defaultShell = mkOption {
|
{ ... } : {
|
||||||
type = types.nullOr types.str;
|
|
||||||
description = "The default shell of the user.";
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
rclone = {
|
|
||||||
configurations = mkOption {
|
|
||||||
type = types.attrsOf syncType;
|
|
||||||
description = "The configurations of the rclone mounts.";
|
|
||||||
default = {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
syncType = types.submodule (
|
|
||||||
{ ... }: {
|
|
||||||
options = {
|
options = {
|
||||||
dirName = mkOption {
|
displayName = mkOption {
|
||||||
type = types.str;
|
type = types.nullOr types.str;
|
||||||
description = "The name of the directory to sync the remote files to.";
|
description = "The human-readable name of the user.";
|
||||||
|
default = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
cacheDuration = mkOption {
|
mailAddress = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
description = "The amount of time to keep cached files.";
|
description = "The mail address of the user.";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
groups = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
description = "The additional groups of the user.";
|
||||||
|
default = [];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
linuxUserType = types.submodule (
|
||||||
|
{ ... }: {
|
||||||
|
options = {
|
||||||
|
defaultShell = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The default shell of the user.";
|
||||||
default = null;
|
default = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
mkUserType = { options }: (
|
winUserType = types.submodule (
|
||||||
types.submodule (
|
{ ... }: {
|
||||||
{ ... }: {
|
options = {
|
||||||
options = {
|
microsoftAccount = mkOption {
|
||||||
displayName = mkOption {
|
type = types.bool;
|
||||||
type = types.nullOr types.str;
|
description = "A value indicating whether this user is a Microsoft Account.";
|
||||||
description = "The human-readable name of the user.";
|
default = false;
|
||||||
default = null;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
mailAddress = mkOption {
|
|
||||||
type = types.nullOr types.str;
|
|
||||||
description = "The mail address of the user.";
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
groups = mkOption {
|
|
||||||
type = types.listOf types.str;
|
|
||||||
description = "The additional groups of the user.";
|
|
||||||
default = [];
|
|
||||||
};
|
|
||||||
|
|
||||||
git = (import ./git/options.nix) { inherit lib; };
|
|
||||||
} // options;
|
|
||||||
}));
|
|
||||||
|
|
||||||
userType = mkUserType {
|
|
||||||
options = linuxOptions;
|
|
||||||
};
|
|
||||||
|
|
||||||
winUserType = mkUserType {
|
|
||||||
options = {
|
|
||||||
microsoftAccount = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
description = "A value indicating whether this user is a Microsoft Account.";
|
|
||||||
default = false;
|
|
||||||
};
|
};
|
||||||
};
|
});
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
valhalla = {
|
valhalla = {
|
||||||
|
@ -88,25 +60,31 @@
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
windows.users = mkOption {
|
linux.users = mkOption {
|
||||||
type = types.attrsOf winUserType;
|
type = types.attrsOf linuxUserType;
|
||||||
description = "The users to create on the Windows machine.";
|
};
|
||||||
default = (lib.attrsets.concatMapAttrs (
|
|
||||||
name: options:
|
windows = mkOption {
|
||||||
if builtins.elem name (builtins.attrNames linuxOptions)
|
type = types.submoduleWith {
|
||||||
then {}
|
modules = [
|
||||||
else {
|
({ config, options, ... }: {
|
||||||
${capitalize name} = (lib.attrsets.concatMapAttrs (
|
options = {
|
||||||
name: value:
|
users = mkOption {
|
||||||
if builtins.elem name (builtins.attrNames linuxOptions)
|
type = types.attrsOf winUserType;
|
||||||
then {}
|
|
||||||
else {
|
|
||||||
${name} = value;
|
|
||||||
}
|
|
||||||
) options) // {
|
|
||||||
groups = [];
|
|
||||||
};
|
};
|
||||||
}) cfg.users);
|
|
||||||
|
winUsers = mkOption {
|
||||||
|
type = options.users.type;
|
||||||
|
description = "Blablabla";
|
||||||
|
default = (lib.attrsets.concatMapAttrs (
|
||||||
|
name: options: {
|
||||||
|
${capitalize name} = options;
|
||||||
|
}) config.users);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,9 +6,13 @@
|
||||||
;
|
;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
./git.nix
|
./packages/git.nix
|
||||||
|
./packages/nextcloud.nix
|
||||||
|
./packages/oh-my-posh.nix
|
||||||
|
./packages/rclone.nix
|
||||||
./hardware.nix
|
./hardware.nix
|
||||||
./i18n.nix
|
./i18n.nix
|
||||||
|
./os.nix
|
||||||
./partition.nix
|
./partition.nix
|
||||||
./software.nix
|
./software.nix
|
||||||
./users.nix
|
./users.nix
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
mkOption
|
mkDefault
|
||||||
mkEnableOption
|
mkEnableOption
|
||||||
mkIf
|
mkIf
|
||||||
|
mkOption
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
setupUser = config.valhalla.setupUser.name;
|
|
||||||
capitalize = (import ../text.nix { inherit lib; }).capitalize;
|
capitalize = (import ../text.nix { inherit lib; }).capitalize;
|
||||||
|
in {
|
||||||
winType = types.submodule (
|
options = {
|
||||||
{ config, ... }: {
|
valhalla = {
|
||||||
options = {
|
windows = {
|
||||||
setupUser = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "The name of the user for setting up Windows.";
|
|
||||||
default = capitalize setupUser;
|
|
||||||
};
|
|
||||||
|
|
||||||
dualboot = {
|
dualboot = {
|
||||||
enable = mkEnableOption "dual boot";
|
enable = mkEnableOption "dual boot";
|
||||||
|
|
||||||
|
@ -41,19 +35,13 @@
|
||||||
dynamicLighting = mkEnableOption "dynamic lighting";
|
dynamicLighting = mkEnableOption "dynamic lighting";
|
||||||
adware = mkEnableOption "adware"; # Fuck you for displaying ads on an OS I fricking paid for!
|
adware = mkEnableOption "adware"; # Fuck you for displaying ads on an OS I fricking paid for!
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
dualboot.linuxPercentage = mkIf (!config.dualboot.enable) 0;
|
valhalla.windows = {
|
||||||
};
|
setupUser.name = mkDefault (capitalize config.valhalla.setupUser.name);
|
||||||
});
|
dualboot.linuxPercentage = mkIf (!config.valhalla.windows.dualboot.enable) (mkDefault 0);
|
||||||
in {
|
|
||||||
options = {
|
|
||||||
valhalla = {
|
|
||||||
windows = mkOption {
|
|
||||||
type = winType;
|
|
||||||
description = "The options for setting up Windows.";
|
|
||||||
default = {};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,8 +11,9 @@
|
||||||
linuxPercentage = 30;
|
linuxPercentage = 30;
|
||||||
};
|
};
|
||||||
|
|
||||||
users.Manuel = {
|
users.manuel = {
|
||||||
microsoftAccount = true;
|
microsoftAccount = true;
|
||||||
|
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 {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
fs = import ../../lib/modules/partition/fs.nix;
|
fs = import ../../lib/modules/partition/fs.nix;
|
||||||
in {
|
in {
|
||||||
imports = [
|
imports = [
|
||||||
|
../manuel/config.nix
|
||||||
../../lib/modules/valhalla.nix
|
../../lib/modules/valhalla.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -39,14 +40,17 @@
|
||||||
manuel = {
|
manuel = {
|
||||||
displayName = "Manuel Thalmann";
|
displayName = "Manuel Thalmann";
|
||||||
mailAddress = "m@nuth.ch";
|
mailAddress = "m@nuth.ch";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
linux.users.manuel = {
|
||||||
|
defaultShell = "fish";
|
||||||
|
|
||||||
groups = [
|
groups = [
|
||||||
"wheel"
|
"wheel"
|
||||||
"nix-users"
|
"nix-users"
|
||||||
];
|
];
|
||||||
|
|
||||||
defaultShell = "fish";
|
|
||||||
|
|
||||||
rclone = {
|
rclone = {
|
||||||
configurations = {
|
configurations = {
|
||||||
nextcloud = {
|
nextcloud = {
|
||||||
|
@ -57,6 +61,25 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
windows.users.manuel = {
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
23
profiles/manuel/config.nix
Normal file
23
profiles/manuel/config.nix
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{ ... }: {
|
||||||
|
imports = [
|
||||||
|
../../lib/modules/valhalla.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
config = {
|
||||||
|
valhalla = {
|
||||||
|
users.manuel = {
|
||||||
|
oh-my-posh = {
|
||||||
|
theme = {
|
||||||
|
source = ./manuel.omp.json;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
partition = {
|
||||||
|
os = {
|
||||||
|
partitions = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
173
profiles/manuel/manuel.omp.json
Normal file
173
profiles/manuel/manuel.omp.json
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
|
||||||
|
"version": 2,
|
||||||
|
"blocks": [
|
||||||
|
{
|
||||||
|
"type": "prompt",
|
||||||
|
"alignment": "left",
|
||||||
|
"segments": [
|
||||||
|
{
|
||||||
|
"type": "os",
|
||||||
|
"style": "diamond",
|
||||||
|
"leading_diamond": "\ue0b6",
|
||||||
|
"trailing_diamond": "\ue0b4",
|
||||||
|
"background_templates": [
|
||||||
|
"{{ if eq .OS \"ubuntu\" }}#EA531A{{ end }}",
|
||||||
|
"{{ if eq .OS \"debian\" }}#D80150{{ end }}",
|
||||||
|
"{{ if eq .OS \"arch\" }}#1793D1{{ end }}"
|
||||||
|
],
|
||||||
|
"foreground": "p:white",
|
||||||
|
"template": "{{ if ne .OS \"windows\" }}{{ .Icon }} {{ end }}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "session",
|
||||||
|
"style": "diamond",
|
||||||
|
"leading_diamond": "\ue0b6",
|
||||||
|
"trailing_diamond": "\ue0b0",
|
||||||
|
"background": "p:yellow",
|
||||||
|
"foreground": "p:black",
|
||||||
|
"properties": {
|
||||||
|
"display_host": false
|
||||||
|
},
|
||||||
|
"template": " {{ if .SSHSession }}\ueb39 {{ end }}{{ .UserName }} "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"style": "powerline",
|
||||||
|
"powerline_symbol": "\ue0b0",
|
||||||
|
"background": "p:orange",
|
||||||
|
"foreground": "p:black",
|
||||||
|
"properties": {
|
||||||
|
"home_icon": "~",
|
||||||
|
"style": "folder"
|
||||||
|
},
|
||||||
|
"template": " \udb80\ude4b {{ path .Path .Location }} "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "dotnet",
|
||||||
|
"style": "powerline",
|
||||||
|
"powerline_symbol": "\ue0b0",
|
||||||
|
"foreground": "p:black",
|
||||||
|
"background": "#00ffff",
|
||||||
|
"template": " \udb81\ude10 {{ .Full }} "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "java",
|
||||||
|
"style": "powerline",
|
||||||
|
"powerline_symbol": "\ue0b0",
|
||||||
|
"background": "#4063d8",
|
||||||
|
"template": " \udb82\udf37 {{ .Full }} "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "python",
|
||||||
|
"style": "powerline",
|
||||||
|
"powerline_symbol": "\ue0b0",
|
||||||
|
"background": "#906cff",
|
||||||
|
"template": " \udb80\udf20 {{ .Full }} "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"style": "powerline",
|
||||||
|
"powerline_symbol": "\ue0b0",
|
||||||
|
"trailing_diamond": "\ue0b4",
|
||||||
|
"background": "p:green",
|
||||||
|
"background_templates": [
|
||||||
|
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}",
|
||||||
|
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}",
|
||||||
|
"{{ if gt .Ahead 0 }}#49416D{{ end }}",
|
||||||
|
"{{ if gt .Behind 0 }}#7A306C{{ end }}"
|
||||||
|
],
|
||||||
|
"foreground": "p:black",
|
||||||
|
"foreground_templates": [
|
||||||
|
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:black{{ end }}",
|
||||||
|
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:white{{ end }}",
|
||||||
|
"{{ if gt .Ahead 0 }}p:white{{ end }}"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"branch_max_length": 25,
|
||||||
|
"fetch_stash_count": true,
|
||||||
|
"fetch_status": true,
|
||||||
|
"fetch_upstream_icon": true,
|
||||||
|
"upstream_icons": {
|
||||||
|
"codeberg.org": "\uf330 ",
|
||||||
|
"git.nuth.ch": "\uf335",
|
||||||
|
"git.jonascosta.ch": "\uf339 ",
|
||||||
|
"git.romhackersworld.eu": "\uf339 ",
|
||||||
|
"aur.archlinux.org": "\uf303 "
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"templates": [
|
||||||
|
"{{ if .UpstreamURL }} {{ url .UpstreamIcon .UpstreamURL }}{{ end }}",
|
||||||
|
" {{ .HEAD }} ",
|
||||||
|
"{{ if .BranchStatus }}{{ .BranchStatus }} {{ end }}",
|
||||||
|
"{{ if .Working.Changed }} \uf044 {{ .Working.String }} {{ end }}",
|
||||||
|
"{{ if and (.Working.Changed) (or (.Staging.Changed) (gt .StashCount 0)) }} | {{ end }}",
|
||||||
|
"{{ if .Staging.Changed }} \uf046 {{ .Staging.String }} {{ end }}",
|
||||||
|
"{{ if and (.Staging.Changed) (gt .StashCount 0) }} | {{ end }}",
|
||||||
|
"{{ if gt .StashCount 0 }} \udb80\udd93 {{ .StashCount }}{{ end }} "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "node",
|
||||||
|
"style": "powerline",
|
||||||
|
"powerline_symbol": "\ue0b0",
|
||||||
|
"background": "#6ca35e",
|
||||||
|
"foreground": "p:white",
|
||||||
|
"properties": {
|
||||||
|
"fetch_version": true
|
||||||
|
},
|
||||||
|
"template": " \udb80\udf99 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} "
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "root",
|
||||||
|
"style": "powerline",
|
||||||
|
"powerline_symbol": "\ue0b0",
|
||||||
|
"background": "p:yellow",
|
||||||
|
"foreground": "p:white",
|
||||||
|
"properties": {
|
||||||
|
"root_icon": "\uf0e7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "executiontime",
|
||||||
|
"style": "plain",
|
||||||
|
"background": "#83769c",
|
||||||
|
"foreground": "p:white",
|
||||||
|
"properties": {
|
||||||
|
"always_enabled": true
|
||||||
|
},
|
||||||
|
"template": "<transparent>\ue0b0</> \udb81\udead {{ .FormattedMs }}\u2800"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"style": "diamond",
|
||||||
|
"background": "p:blue",
|
||||||
|
"trailing_diamond": "\ue0b4",
|
||||||
|
"background_templates": [
|
||||||
|
"{{ if gt .Code 0 }}p:red{{ end }}"
|
||||||
|
],
|
||||||
|
"foreground": "p:white",
|
||||||
|
"properties": {
|
||||||
|
"always_enabled": true
|
||||||
|
},
|
||||||
|
"template": "<parentBackground>\ue0b0</> {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} "
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"transient_prompt": {
|
||||||
|
"background": "transparent",
|
||||||
|
"foreground": "p:black",
|
||||||
|
"template": "<p:yellow,transparent>\ue0b6</><,p:yellow> {{ .Folder }} </><p:yellow,transparent>\ue0b0</> "
|
||||||
|
},
|
||||||
|
"final_space": true,
|
||||||
|
"palette": {
|
||||||
|
"black": "#262B44",
|
||||||
|
"blue": "#4B95E9",
|
||||||
|
"green": "#59C9A5",
|
||||||
|
"orange": "#F07623",
|
||||||
|
"red": "#D81E5B",
|
||||||
|
"white": "#E0DEF4",
|
||||||
|
"yellow": "#F3AE35"
|
||||||
|
}
|
||||||
|
}
|
|
@ -68,19 +68,19 @@ $null = New-Module {
|
||||||
$downloadChecker = {
|
$downloadChecker = {
|
||||||
$files = Get-ChildItem $dir;
|
$files = Get-ChildItem $dir;
|
||||||
|
|
||||||
if ((@($files)).Count -gt 0) {
|
if ((@($files)).Count -eq 1) {
|
||||||
foreach ($file in $files) {
|
$file = $files[0];
|
||||||
try {
|
|
||||||
$stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None);
|
try {
|
||||||
|
$stream = [System.IO.File]::Open($file.FullName, [System.IO.FileMode]::Open, [System.IO.FileAccess]::ReadWrite, [System.IO.FileShare]::None);
|
||||||
if ($stream) {
|
|
||||||
$stream.Close();
|
if ($stream) {
|
||||||
}
|
$stream.Close();
|
||||||
}
|
|
||||||
catch {
|
|
||||||
return $true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
return $true;
|
||||||
|
}
|
||||||
|
|
||||||
return $false;
|
return $false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -90,18 +90,28 @@ $null = New-Module {
|
||||||
|
|
||||||
$browser = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($options);
|
$browser = [OpenQA.Selenium.Firefox.FirefoxDriver]::new($options);
|
||||||
$browser.Navigate().GoToUrl($URL);
|
$browser.Navigate().GoToUrl($URL);
|
||||||
$null = & $downloadAction -Browser $browser;
|
|
||||||
|
while (-not ($browser.ExecuteScript("return document.readyState;") -eq "complete")) {
|
||||||
while (& $downloadChecker) {
|
Start-Sleep 0.1;
|
||||||
Write-Host "Waiting for the download to finish…";
|
}
|
||||||
Start-Sleep 1;
|
|
||||||
|
try {
|
||||||
|
$null = & $downloadAction -Browser $browser;
|
||||||
|
|
||||||
|
while (& $downloadChecker) {
|
||||||
|
Write-Host "Waiting for the download to finish…";
|
||||||
|
Start-Sleep 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$file = Get-ChildItem $dir;
|
||||||
|
$result = Move-Item $file $OutDir -PassThru;
|
||||||
|
$browser.Quit();
|
||||||
|
Remove-Item -Recurse $dir;
|
||||||
|
$result;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Error $Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = Get-ChildItem $dir;
|
|
||||||
$result = Move-Item $file $OutDir -PassThru;
|
|
||||||
$browser.Quit();
|
|
||||||
Remove-Item -Recurse $dir;
|
|
||||||
$result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,12 +127,16 @@ $null = New-Module {
|
||||||
|
|
||||||
.PARAMETER OutDir
|
.PARAMETER OutDir
|
||||||
The directory to download the file to.
|
The directory to download the file to.
|
||||||
|
|
||||||
|
.PARAMETER Timeout
|
||||||
|
The number of seconds to wait before clicking the download button.
|
||||||
#>
|
#>
|
||||||
function Start-BrowserDownload {
|
function Start-BrowserDownload {
|
||||||
param(
|
param(
|
||||||
[string] $URL,
|
[string] $URL,
|
||||||
[string] $ButtonSelector,
|
[string] $ButtonSelector,
|
||||||
[string] $OutDir = $null
|
[string] $OutDir = $null,
|
||||||
|
[double] $Timeout = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
Start-CustomBrowserDownload @PSBoundParameters -Action {
|
Start-CustomBrowserDownload @PSBoundParameters -Action {
|
||||||
|
@ -130,7 +144,28 @@ $null = New-Module {
|
||||||
[OpenQA.Selenium.Firefox.FirefoxDriver] $Browser
|
[OpenQA.Selenium.Firefox.FirefoxDriver] $Browser
|
||||||
)
|
)
|
||||||
|
|
||||||
$Browser.FindElement([OpenQA.Selenium.By]::CssSelector($ButtonSelector)).Click();
|
$selector = [OpenQA.Selenium.By]::CssSelector($ButtonSelector);
|
||||||
|
[OpenQA.Selenium.IWebElement] $element = $null;
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt 5; $i++) {
|
||||||
|
$element = $Browser.FindElement($selector);
|
||||||
|
|
||||||
|
if ($element) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
Start-Sleep 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Timeout -gt 0) {
|
||||||
|
Start-Sleep $Timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element) {
|
||||||
|
$Browser.FindElement($selector).Click();
|
||||||
|
} else {
|
||||||
|
Write-Error "Unable to find download button!";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,19 +2,33 @@ 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
|
||||||
|
Cleanup
|
||||||
|
Completed
|
||||||
|
}
|
||||||
|
|
||||||
|
enum SetupStage {
|
||||||
Configure
|
Configure
|
||||||
Install
|
Install
|
||||||
CreateUser
|
CreateUser
|
||||||
ConfigureUser
|
}
|
||||||
|
|
||||||
|
enum UserStage {
|
||||||
|
Create
|
||||||
|
Configure
|
||||||
|
Cleanup
|
||||||
|
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] $userStageOption = "UserStage";
|
||||||
|
[string] $accountOption = "MSAccount";
|
||||||
[string] $finishedOption = "Finished";
|
[string] $finishedOption = "Finished";
|
||||||
[RegistryKey] $key = $null;
|
[RegistryKey] $key = $null;
|
||||||
|
|
||||||
|
@ -30,14 +44,36 @@ $null = New-Module {
|
||||||
[string] $Path
|
[string] $Path
|
||||||
)
|
)
|
||||||
|
|
||||||
$job = Start-Job {
|
& {
|
||||||
$env:Value = Resolve-Path $Using:Path;
|
$ErrorActionPreference = 'Continue';
|
||||||
$env:WSLENV = "Value/p";
|
$completed = $false;
|
||||||
$result = wsl -- bash -c 'echo "$Value"';
|
|
||||||
wsl -e printf "%q" "$result";
|
|
||||||
};
|
|
||||||
|
|
||||||
Receive-Job -Wait $job;
|
while (-not $completed) {
|
||||||
|
$job = Start-Job {
|
||||||
|
$env:Value = Resolve-Path $Using:Path;
|
||||||
|
$env:WSLENV = "Value/p";
|
||||||
|
$result = wsl -- bash -c 'echo "$Value"';
|
||||||
|
wsl -e printf "%q" "$result";
|
||||||
|
};
|
||||||
|
|
||||||
|
$result = Receive-Job -Wait $job;
|
||||||
|
|
||||||
|
|
||||||
|
if ((Split-Path -Leaf $Path) -ne (Split-Path -Leaf $result)) {
|
||||||
|
Write-Error "The result of the path conversion of ``$Path`` was unexpected: ``$result``";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($job.State -ne ([System.Management.Automation.JobState]::Completed)) {
|
||||||
|
Write-Error "An error occurred while converting ``$Path`` to a Linux path.`nOutput: ``$result``";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$completed = $true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -79,15 +115,33 @@ $null = New-Module {
|
||||||
|
|
||||||
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
$scriptPath = "$PSScriptRoot/../../Common/Scripts/config.fish";
|
||||||
|
|
||||||
if (-not $IsWindows) {
|
if ($env:CONFIG_MODULE) {
|
||||||
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
$output = & {
|
||||||
fish -c ". $escapedPath; $Script";
|
if (-not $IsWindows) {
|
||||||
} else {
|
$escapedPath = (fish -c 'string escape $argv' "$scriptPath");
|
||||||
function fish {
|
fish -c ". $escapedPath; $Script";
|
||||||
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
|
} else {
|
||||||
|
function fish {
|
||||||
|
wsl --shell-type login -- nix --extra-experimental-features "nix-command flakes" run nixpkgs`#fish -- $args
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script";
|
||||||
|
|
||||||
|
if (-not $?) {
|
||||||
|
Write-Error "The configuration could not be retrieved!";
|
||||||
|
} else {
|
||||||
|
$output;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fish -c ". $(ConvertTo-LinuxPath $scriptPath); $Script" | ConvertFrom-Json;
|
if (-not ($output -and ($output | Test-Json))) {
|
||||||
|
Write-Error "The value ``$output`` is not valid JSON.";
|
||||||
|
} else {
|
||||||
|
$output | ConvertFrom-Json;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +162,22 @@ $null = New-Module {
|
||||||
Invoke-ConfigScript "getConfig $Name --json $ArgumentList";
|
Invoke-ConfigScript "getConfig $Name --json $ArgumentList";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the name of the config root.
|
||||||
|
#>
|
||||||
|
function Get-ConfigRootName {
|
||||||
|
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.
|
||||||
|
@ -120,13 +190,13 @@ $null = New-Module {
|
||||||
#>
|
#>
|
||||||
function Get-UserConfig {
|
function Get-UserConfig {
|
||||||
param(
|
param(
|
||||||
[string] $UserName = $env:UserName,
|
[string] $UserName = ($IsWindows ? $env:UserName : $env:USER),
|
||||||
[Parameter(Mandatory, Position = 0)]
|
[Parameter(Mandatory, Position = 0)]
|
||||||
[string] $Name
|
[string] $Name
|
||||||
)
|
)
|
||||||
|
|
||||||
if ((Get-Users) -contains $UserName) {
|
if ((Get-Users) -contains $UserName) {
|
||||||
Get-Config "valhalla.windows.users.$UserName.$Name";
|
Get-Config "$(Get-UserRootName).$UserName.$Name";
|
||||||
} else {
|
} else {
|
||||||
return $null;
|
return $null;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +224,7 @@ $null = New-Module {
|
||||||
function Get-Users {
|
function Get-Users {
|
||||||
[OutputType([string[]])]
|
[OutputType([string[]])]
|
||||||
param()
|
param()
|
||||||
Get-Attributes "valhalla.windows.users";
|
Get-Attributes "$(Get-UserRootName)";
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -164,7 +234,7 @@ $null = New-Module {
|
||||||
function Get-SetupUser {
|
function Get-SetupUser {
|
||||||
[OutputType([string])]
|
[OutputType([string])]
|
||||||
param()
|
param()
|
||||||
Get-Config "valhalla.windows.setupUser";
|
Get-Config "$(Get-ConfigRootName).setupUser.name";
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -210,11 +280,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;
|
||||||
}
|
}
|
||||||
|
@ -229,7 +332,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
|
||||||
)
|
)
|
||||||
|
@ -238,7 +341,86 @@ $null = New-Module {
|
||||||
$Name = ([SetupStage]$Name).ToString();
|
$Name = ([SetupStage]$Name).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
$null = Set-SetupOption $stageOption $Name;
|
$null = Set-SetupOption $setupStageOption $Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the current user to set up.
|
||||||
|
#>
|
||||||
|
function Get-CurrentUser {
|
||||||
|
return (Get-SetupOption $userOption) ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets the index of the current user to set up.
|
||||||
|
|
||||||
|
.PARAMETER Value
|
||||||
|
The index of the user to set up.
|
||||||
|
#>
|
||||||
|
function Set-CurrentUser {
|
||||||
|
param(
|
||||||
|
[int] $Value
|
||||||
|
)
|
||||||
|
|
||||||
|
Set-SetupOption $userOption $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the name of the current stage of the user setup.
|
||||||
|
#>
|
||||||
|
function Get-UserStage {
|
||||||
|
$stage = Get-SetupOption $userStageOption;
|
||||||
|
|
||||||
|
if ($null -ne $stage) {
|
||||||
|
$stage = [UserStage]$stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets the current stage of the user setup.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the stage to set.
|
||||||
|
#>
|
||||||
|
function Set-UserStage {
|
||||||
|
param(
|
||||||
|
$Name
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not (($null -eq $Name) -or ($Name -is [string]))) {
|
||||||
|
$Name = ([UserStage]$Name).ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
$null = Set-SetupOption $userStageOption $Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the name of the microsoft account to create.
|
||||||
|
#>
|
||||||
|
function Get-MSAccountName {
|
||||||
|
return Get-SetupOption $accountOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets the name of the microsoft account to create.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the microsoft account to create.
|
||||||
|
#>
|
||||||
|
function Set-MSAccountName {
|
||||||
|
param(
|
||||||
|
[string] $Name
|
||||||
|
)
|
||||||
|
|
||||||
|
Set-SetupOption $accountOption $Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -246,7 +428,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -273,7 +455,15 @@ $null = New-Module {
|
||||||
[string] $Name
|
[string] $Name
|
||||||
)
|
)
|
||||||
|
|
||||||
Get-Config "valhalla.software.$Name";
|
Get-Config "$(Get-ConfigRootName).software.$Name";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Checks whether the running system is a QEMU virtual machine.
|
||||||
|
#>
|
||||||
|
function Test-Qemu {
|
||||||
|
((Get-WmiObject win32_computersystem).Manufacturer) -eq "QEMU";
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -281,7 +471,7 @@ $null = New-Module {
|
||||||
Checks whether the current user is the setup user.
|
Checks whether the current user is the setup user.
|
||||||
#>
|
#>
|
||||||
function Test-SetupUser {
|
function Test-SetupUser {
|
||||||
$env:UserName -eq (Get-Config "valhalla.windows.setupUser");
|
($IsWindows ? $env:UserName : $env:USER) -eq (Get-SetupUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
|
@ -1,9 +1,16 @@
|
||||||
. "$PSScriptRoot/Config.ps1";
|
using namespace System.Management.Automation.Host;
|
||||||
|
|
||||||
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
. "$PSScriptRoot/../Types/OneShotTask.ps1";
|
||||||
. "$PSScriptRoot/../../Windows/Scripts/PowerManagement.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;
|
||||||
|
@ -11,25 +18,262 @@ $null = New-Module {
|
||||||
# ToDo: Store "ProgramData/PortValhalla" path somewhere as const
|
# ToDo: Store "ProgramData/PortValhalla" path somewhere as const
|
||||||
$errorPath = "$env:ProgramData/PortValhalla/error.txt";
|
$errorPath = "$env:ProgramData/PortValhalla/error.txt";
|
||||||
|
|
||||||
|
$getUserName = {
|
||||||
|
"$(Get-SetupUser)OneShot";
|
||||||
|
};
|
||||||
|
|
||||||
$taskSetter = {
|
$taskSetter = {
|
||||||
param([Nullable[OneShotTask]] $Task)
|
param([Nullable[OneShotTask]] $Task)
|
||||||
Set-SetupOption $taskOption ([string]$Task);
|
Set-SetupOption $taskOption ([string]$Task);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the PowerShell modules required for operating.
|
||||||
|
#>
|
||||||
|
function Get-RequiredModules {
|
||||||
|
$modules = @(
|
||||||
|
@("PSScriptAnalyzer")
|
||||||
|
) + (& {
|
||||||
|
if (-not $IsWindows) {
|
||||||
|
@()
|
||||||
|
} else {
|
||||||
|
@(
|
||||||
|
@("KnownFolders"),
|
||||||
|
@("PSWindowsUpdate"),
|
||||||
|
@("LocalAccounts", $true),
|
||||||
|
@("NuGet")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for ($i = 0; $i -lt $modules.Count; $i++) {
|
||||||
|
if ($modules[$i] -is [string]) {
|
||||||
|
$modules[$i] = @($modules[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function Start-Operation {
|
function Start-Operation {
|
||||||
param(
|
param(
|
||||||
|
[switch] $NonInteractive,
|
||||||
|
[switch] $NoImplicitCleanup,
|
||||||
[scriptblock] $Action
|
[scriptblock] $Action
|
||||||
)
|
)
|
||||||
|
|
||||||
$Global:ErrorActionPreference = 'Inquire';
|
$cleanup = { };
|
||||||
$env:WSLENV = "CONFIG_MODULE/p";
|
$taskPending = $false;
|
||||||
|
|
||||||
if ($env:CONFIG_MODULE) {
|
if (-not $Global:InOperation) {
|
||||||
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
if ($env:DEBUG) {
|
||||||
|
Set-PSDebug -Trace 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($IsWindows -and ($null -ne (Get-OneShotTask))) {
|
||||||
|
$taskPending = $true;
|
||||||
|
[switch] $NonInteractive = $true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$Global:InOperation = $true;
|
||||||
|
$Global:ErrorActionPreference = $NonInteractive.IsPresent ? 'Continue' : 'Inquire';
|
||||||
|
|
||||||
|
if ($IsWindows) {
|
||||||
|
$env:WSLENV = "CONFIG_MODULE/p";
|
||||||
|
|
||||||
|
if ($env:CONFIG_MODULE) {
|
||||||
|
$env:CONFIG_MODULE = Resolve-Path $env:CONFIG_MODULE;
|
||||||
|
}
|
||||||
|
|
||||||
|
New-Alias -Force "sudo" gsudo;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $NoImplicitCleanup.IsPresent) {
|
||||||
|
$cleanup = {
|
||||||
|
Clear-OperationResources;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
& {
|
||||||
|
$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) {
|
||||||
|
$liveScriptOption = "LiveScripts";
|
||||||
|
|
||||||
|
if (($null -eq (Get-SetupOption $liveScriptOption)) -and (Test-Qemu)) {
|
||||||
|
$result = $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);
|
||||||
|
|
||||||
|
Set-SetupOption $liveScriptOption $result;
|
||||||
|
|
||||||
|
if ($result -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/../../Windows/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 {
|
||||||
|
foreach ($module in (Get-RequiredModules)) {
|
||||||
|
$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 -AllowClobber $module[0] @parameters;
|
||||||
|
Import-Module $module[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$initialized = $true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
New-Alias -Force "sudo" gsudo;
|
if ($taskPending) {
|
||||||
& $Action;
|
Start-OneShot;
|
||||||
|
} else {
|
||||||
|
& $Action;
|
||||||
|
}
|
||||||
|
|
||||||
|
& $cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -37,7 +281,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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -46,12 +296,23 @@ $null = New-Module {
|
||||||
#>
|
#>
|
||||||
function Enable-OneShotListener {
|
function Enable-OneShotListener {
|
||||||
$tempTask = "PortValhalla Temp";
|
$tempTask = "PortValhalla Temp";
|
||||||
$action = New-ScheduledTaskAction -Execute "pwsh" -Argument (Get-StartupArguments);
|
$user = & $getUserName;
|
||||||
|
$password = [string]([guid]::NewGuid());
|
||||||
|
|
||||||
|
$adminGroup = @{
|
||||||
|
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||||
|
};
|
||||||
|
|
||||||
|
$null = New-LocalUser -Name $user -Password (ConvertTo-SecureString -AsPlainText $password);
|
||||||
|
Add-LocalGroupMember -Member $user @adminGroup;
|
||||||
|
$path = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList";
|
||||||
|
$null = New-Item -Force -ErrorAction SilentlyContinue $path;
|
||||||
|
Set-ItemProperty $path -Name $user -Value 0;
|
||||||
|
|
||||||
|
$action = New-ScheduledTaskAction -Execute "pwsh" -Argument "-Command & { $([string](Get-StartupCommand)) } 2>&1 | Tee-Object -FilePath `$env:ProgramData/PortValhalla/OneShotTask.log";
|
||||||
schtasks /Create /SC ONEVENT /EC $logName /MO "*[System[Provider[@Name='$logName'] and EventID=$($oneShotTrigger)]]" /TR cmd.exe /TN $tempTask;
|
schtasks /Create /SC ONEVENT /EC $logName /MO "*[System[Provider[@Name='$logName'] and EventID=$($oneShotTrigger)]]" /TR cmd.exe /TN $tempTask;
|
||||||
$trigger = (Get-ScheduledTask $tempTask).Triggers;
|
$trigger = (Get-ScheduledTask $tempTask).Triggers;
|
||||||
$principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest;
|
$null = Register-ScheduledTask -Force $oneShotTaskName -Action $action -Trigger $trigger -RunLevel Highest -User $user -Password $password;
|
||||||
$task = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger;
|
|
||||||
$null = Register-ScheduledTask -Force $oneShotTaskName -InputObject $task;
|
|
||||||
$null = Unregister-ScheduledTask -Confirm:$false $tempTask;
|
$null = Unregister-ScheduledTask -Confirm:$false $tempTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,6 +322,10 @@ $null = New-Module {
|
||||||
#>
|
#>
|
||||||
function Disable-OneShotListener {
|
function Disable-OneShotListener {
|
||||||
Unregister-ScheduledTask -Confirm:$false $oneShotTaskName;
|
Unregister-ScheduledTask -Confirm:$false $oneShotTaskName;
|
||||||
|
$user = Get-LocalUser (& $getUserName);
|
||||||
|
[string] $sid = $user.SID;
|
||||||
|
Remove-LocalUser $user;
|
||||||
|
Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -75,8 +340,6 @@ $null = New-Module {
|
||||||
[OneShotTask] $Task
|
[OneShotTask] $Task
|
||||||
)
|
)
|
||||||
|
|
||||||
$currentStage = Get-Stage;
|
|
||||||
Set-Stage ([SetupStage]::OneShot);
|
|
||||||
& $taskSetter $Task;
|
& $taskSetter $Task;
|
||||||
|
|
||||||
& {
|
& {
|
||||||
|
@ -99,16 +362,19 @@ $null = New-Module {
|
||||||
};
|
};
|
||||||
|
|
||||||
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "Starting OneShot task ``$(Get-OneShotTask)``…";
|
Write-EventLog -LogName $logName -Source $logName -EventId $oneShotTrigger -Message "Starting OneShot task ``$(Get-OneShotTask)``…";
|
||||||
Remove-Event -EventIdentifier (Wait-Event -SourceIdentifier $identifier).EventIdentifier;
|
|
||||||
$null = Wait-Event -SourceIdentifier $identifier;
|
|
||||||
};
|
|
||||||
|
|
||||||
Set-Stage $currentStage;
|
for ($i = 0; $i -lt 2; $i++) {
|
||||||
|
Remove-Event -EventIdentifier (Wait-Event -SourceIdentifier $identifier).EventIdentifier;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (Test-Path $errorPath) {
|
if (Test-Path $errorPath) {
|
||||||
$errorMessage = Get-Content $errorPath;
|
$errorMessage = Get-Content $errorPath;
|
||||||
Remove-Item $errorPath;
|
Remove-Item $errorPath;
|
||||||
throw $errorMessage;
|
|
||||||
|
if ($errorMessage) {
|
||||||
|
Write-Error $errorMessage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,19 +385,43 @@ $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 @PSBoundParameters;
|
Write-Host "Running OneShot task ``$(Get-OneShotTask)``";
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
$null = Uninstall-Package Selenium.WebDriver -ErrorAction Continue;
|
||||||
|
Uninstall-ChocoPackage 7zip.portable gsudo selenium-gecko-driver yq;
|
||||||
|
Uninstall-WingetPackage AutoHotkey.AutoHotkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($module in (Get-RequiredModules)) {
|
||||||
|
Uninstall-Module -Force -Name $module[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -51,6 +51,7 @@ function Write-PSScript {
|
||||||
|
|
||||||
Import-Module PSScriptAnalyzer;
|
Import-Module PSScriptAnalyzer;
|
||||||
$dirName = Split-Path -Parent $FileName;
|
$dirName = Split-Path -Parent $FileName;
|
||||||
|
$Script = ($Script -split "\r?\n") -join [System.Environment]::NewLine;
|
||||||
$content = Invoke-Formatter -ScriptDefinition $Script;
|
$content = Invoke-Formatter -ScriptDefinition $Script;
|
||||||
$exists = Test-Path -PathType Leaf $FileName;
|
$exists = Test-Path -PathType Leaf $FileName;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,64 @@ $null = New-Module {
|
||||||
. "$PSScriptRoot/../Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../Types/InstallerAction.ps1";
|
||||||
$userArgument = "name";
|
$userArgument = "name";
|
||||||
|
|
||||||
|
$chocoRunner = {
|
||||||
|
param(
|
||||||
|
[string] $Action = 'install',
|
||||||
|
[string[]] $ArgumentList,
|
||||||
|
[scriptblock] $Guard = { $true },
|
||||||
|
[Parameter(Position = 0)]
|
||||||
|
[string] $Name,
|
||||||
|
[Parameter(ValueFromRemainingArguments = $true)]
|
||||||
|
[string[]] $AdditionalNames = @()
|
||||||
|
)
|
||||||
|
|
||||||
|
[System.Collections.ArrayList] $Names = @();
|
||||||
|
$null = $Names.Add($Name);
|
||||||
|
$Names.AddRange($AdditionalNames);
|
||||||
|
|
||||||
|
if (-not ($Force.IsPresent)) {
|
||||||
|
for ($i = $Names.Count - 1; $i -ge 0; $i--) {
|
||||||
|
$name = $Names[$i];
|
||||||
|
|
||||||
|
if (-not (& $Guard $name)) {
|
||||||
|
$Names.RemoveAt($i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Names.Count -ge 1) {
|
||||||
|
choco $Action -y @ArgumentList @Names;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$wingetRunner = {
|
||||||
|
param(
|
||||||
|
[string] $Action = 'install',
|
||||||
|
[string[]] $ArgumentList,
|
||||||
|
[scriptblock] $Guard = { $true },
|
||||||
|
[Parameter(Position = 0)]
|
||||||
|
[string] $Name,
|
||||||
|
[Parameter(ValueFromRemainingArguments = $true)]
|
||||||
|
[string[]] $AdditionalNames = @()
|
||||||
|
)
|
||||||
|
|
||||||
|
[System.Collections.ArrayList] $Names = @();
|
||||||
|
$null = $Names.Add($Name);
|
||||||
|
$Names.AddRange($AdditionalNames);
|
||||||
|
|
||||||
|
foreach ($name in $Names) {
|
||||||
|
if ($Force.IsPresent -or (& $Guard $name $PSBoundParameters)) {
|
||||||
|
winget $Action `
|
||||||
|
--accept-source-agreements `
|
||||||
|
--source winget `
|
||||||
|
$ArgumentList `
|
||||||
|
--exact --id $name ;
|
||||||
|
} else {
|
||||||
|
Write-Host "Package ``$name`` is already installed"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Installs the specified packages using chocolatey.
|
Installs the specified packages using chocolatey.
|
||||||
|
@ -26,24 +84,39 @@ $null = New-Module {
|
||||||
[string[]] $AdditionalNames = @()
|
[string[]] $AdditionalNames = @()
|
||||||
)
|
)
|
||||||
|
|
||||||
[System.Collections.ArrayList] $Names = @();
|
& $chocoRunner @PSBoundParameters -Guard {
|
||||||
$null = $Names.Add($Name);
|
param($Name)
|
||||||
$Names.AddRange($AdditionalNames);
|
if (Test-ChocoPackage $Name) {
|
||||||
|
Write-Host "Package ``$Name`` is already installed"
|
||||||
if (-not ($Force.IsPresent)) {
|
$false;
|
||||||
for ($i = $Names.Count - 1; $i -ge 0; $i--) {
|
} else {
|
||||||
$name = $Names[$i];
|
$true;
|
||||||
|
|
||||||
if (Test-ChocoPackage $name) {
|
|
||||||
Write-Host "Package ``$name`` is already installed"
|
|
||||||
$Names.RemoveAt($i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if ($Names.Count -ge 1) {
|
<#
|
||||||
choco install -y @ArgumentList @Names;
|
.SYNOPSIS
|
||||||
}
|
Uninstalls the specified packages using chocolatey.
|
||||||
|
#>
|
||||||
|
function Uninstall-ChocoPackage {
|
||||||
|
param(
|
||||||
|
[string[]] $ArgumentList,
|
||||||
|
[Parameter(Position=0)]
|
||||||
|
[string] $Name,
|
||||||
|
[Parameter(ValueFromRemainingArguments = $true)]
|
||||||
|
[string[]] $AdditionalNames = @()
|
||||||
|
)
|
||||||
|
|
||||||
|
& $chocoRunner @PSBoundParameters -Action 'uninstall' -Guard {
|
||||||
|
param($Name)
|
||||||
|
if (Test-ChocoPackage $Name) {
|
||||||
|
$true;
|
||||||
|
} else {
|
||||||
|
Write-Host "Package ``$Name`` is not installed";
|
||||||
|
$false;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -63,21 +136,41 @@ $null = New-Module {
|
||||||
[string[]] $AdditionalNames = @()
|
[string[]] $AdditionalNames = @()
|
||||||
)
|
)
|
||||||
|
|
||||||
[System.Collections.ArrayList] $Names = @();
|
& $wingetRunner @PSBoundParameters `
|
||||||
$null = $Names.Add($Name);
|
-ArgumentList @($PSBoundParameters.ArgumentList + @("--accept-package-agreements")) `
|
||||||
$Names.AddRange($AdditionalNames);
|
-Guard {
|
||||||
|
param($Name, $Parameters)
|
||||||
|
if (Test-WingetPackage @Parameters) {
|
||||||
|
Write-Host "Package ``$Name`` is already installed"
|
||||||
|
$false;
|
||||||
|
} else {
|
||||||
|
$true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($name in $Names) {
|
<#
|
||||||
if ($Force.IsPresent -or -not (Test-WingetPackage $name)) {
|
.SYNOPSIS
|
||||||
winget install `
|
Uninstalls the specified packages using `winget`.
|
||||||
--accept-source-agreements --accept-package-agreements `
|
#>
|
||||||
--source winget `
|
function Uninstall-WingetPackage {
|
||||||
$ArgumentList `
|
param(
|
||||||
--exact --id $name ;
|
[string[]] $ArgumentList,
|
||||||
|
[Parameter(Position=0)]
|
||||||
|
[string] $Name,
|
||||||
|
[Parameter(ValueFromRemainingArguments = $true)]
|
||||||
|
[string[]] $AdditionalNames = @()
|
||||||
|
)
|
||||||
|
|
||||||
|
& $wingetRunner @PSBoundParameters -Action 'uninstall' -Guard {
|
||||||
|
param($Name, $Parameters)
|
||||||
|
if (Test-WingetPackage @Parameters) {
|
||||||
|
$true;
|
||||||
} else {
|
} else {
|
||||||
Write-Host "Package ``$name`` is already installed"
|
Write-Host "Package ``$Name`` is not installed"
|
||||||
|
$false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -197,8 +290,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,31 +330,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;
|
|
||||||
}
|
|
||||||
# ToDo: Automatically configure after installation
|
|
||||||
} elseif ($Action -eq ([InstallerAction]::Configure)) {
|
|
||||||
if ($Configurator) {
|
|
||||||
Write-Host "Configuring $Name…";
|
|
||||||
& $Configurator @argumentList;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-SetupUser)) {
|
switch ($Action) {
|
||||||
$argumentList.Add("action", [InstallerAction]::ConfigureUser);
|
([InstallerAction]::Backup) {
|
||||||
& $installHandler @argumentList;
|
if ($Backup) {
|
||||||
|
Write-Host "Backing up $Name…";
|
||||||
|
& $Backup @argumentList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} elseif ($Action -eq ([InstallerAction]::ConfigureUser)) {
|
([InstallerAction]::Install) {
|
||||||
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
|
if ($Installer) {
|
||||||
$Arguments.Add($userArgument, ($env:UserName));
|
Write-Host "Installing $Name…";
|
||||||
|
& $Installer @argumentList;
|
||||||
|
}
|
||||||
|
|
||||||
|
& $installHandler @argumentList -Action ([InstallerAction]::Configure);
|
||||||
|
|
||||||
|
if ($UserConfigurator -and (-not (Test-SetupUser))) {
|
||||||
|
& $installHandler @argumentList -Action ([InstallerAction]::ConfigureUser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
([InstallerAction]::Configure) {
|
||||||
if ($UserConfigurator) {
|
if ($Configurator) {
|
||||||
Write-Host "Configuring $Name for user ``$($Arguments[$userArgument])``…";
|
Write-Host "Configuring $Name…";
|
||||||
& $UserConfigurator @argumentList;
|
& $Configurator @argumentList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
if ((-not $Arguments.ContainsKey($userArgument)) -or (-not $Arguments[$userArgument])) {
|
||||||
|
$Arguments.Add($userArgument, ($IsWindows ? $env:UserName : $env:USER));
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = $Arguments[$userArgument];
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,10 +53,11 @@ function Test-ChocoPackage {
|
||||||
function Test-WingetPackage {
|
function Test-WingetPackage {
|
||||||
[OutputType([bool])]
|
[OutputType([bool])]
|
||||||
param(
|
param(
|
||||||
[string] $ID
|
[string] $Name,
|
||||||
|
[string[]] $ArgumentList
|
||||||
)
|
)
|
||||||
|
|
||||||
& { $null = winget list --accept-source-agreements -e --id $ID; $?; };
|
& { $null = winget list --accept-source-agreements -e --id $Name @ArgumentList; $?; };
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -79,10 +80,14 @@ function Test-Command {
|
||||||
Checks whether `winget` is working properly.
|
Checks whether `winget` is working properly.
|
||||||
#>
|
#>
|
||||||
function Test-Winget {
|
function Test-Winget {
|
||||||
(Test-Command winget) -and -not (
|
(Test-Command winget) -and (
|
||||||
[System.Linq.Enumerable]::Any(
|
& {
|
||||||
[string[]](winget source update winget),
|
$output = winget source update winget;
|
||||||
[System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; }));
|
|
||||||
|
$? -and -not ([System.Linq.Enumerable]::Any(
|
||||||
|
[string[]]($output),
|
||||||
|
[System.Func[string,bool]]{ param($line) $line -eq "Cancelled"; }));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
@ -99,3 +104,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.
|
||||||
|
|
|
@ -3,18 +3,12 @@ param (
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../aliae/Manage.ps1";
|
||||||
. "$PSScriptRoot/../PowerShell/Profile.ps1";
|
. "$PSScriptRoot/../PowerShell/Profile.ps1";
|
||||||
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
& $Installer -Action ([InstallerAction]::Configure);
|
|
||||||
} `
|
|
||||||
-Configurator {
|
-Configurator {
|
||||||
Add-PowerShellProfileStatement `
|
Add-PowerShellProfileStatement `
|
||||||
-System `
|
-System `
|
||||||
|
@ -25,4 +19,39 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
(Get-ScriptInitializer "oh-my-posh init pwsh"),
|
(Get-ScriptInitializer "oh-my-posh init pwsh"),
|
||||||
(Get-ScriptInitializer "oh-my-posh completion powershell")
|
(Get-ScriptInitializer "oh-my-posh completion powershell")
|
||||||
) -join [System.Environment]::NewLine)
|
) -join [System.Environment]::NewLine)
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
$theme = Get-UserConfig "oh-my-posh.theme";
|
||||||
|
|
||||||
|
if ($theme) {
|
||||||
|
$varName = "POSH_THEME";
|
||||||
|
|
||||||
|
if ($theme -isnot [string]) {
|
||||||
|
$root = "$($IsWindows ? $env:AppData : "~/.config")/oh-my-posh";
|
||||||
|
$path = Join-Path $root "$($theme.name).omp.json";
|
||||||
|
$null = New-Item -Force -ItemType Directory $root;
|
||||||
|
|
||||||
|
Set-Content $path (
|
||||||
|
& {
|
||||||
|
if ($IsWindows) {
|
||||||
|
wsl cat $theme.source
|
||||||
|
} else {
|
||||||
|
cat $theme.source
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$theme = [string] $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($IsWindows) {
|
||||||
|
[System.Environment]::SetEnvironmentVariable($varName, $path, "User");
|
||||||
|
} else {
|
||||||
|
. "$PSScriptRoot/../aliae/Manage.ps1";
|
||||||
|
Add-EnvironmentVariable -User $Arguments.Name $varName $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,13 +8,6 @@ param (
|
||||||
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
& $Installer -Action ([InstallerAction]::Configure);
|
|
||||||
} `
|
|
||||||
-Configurator {
|
-Configurator {
|
||||||
[string] $globalDir = $null;
|
[string] $globalDir = $null;
|
||||||
$indicator = "# Profile Files";
|
$indicator = "# Profile Files";
|
||||||
|
|
|
@ -8,11 +8,18 @@ $null = New-Module {
|
||||||
|
|
||||||
.PARAMETER Name
|
.PARAMETER Name
|
||||||
The name of the module to install.
|
The name of the module to install.
|
||||||
|
|
||||||
|
.PARAMETER NativeOnly
|
||||||
|
A value indicating whether the module is installed in Windows PowerShell only.
|
||||||
|
|
||||||
|
.PARAMETER NoProfile
|
||||||
|
A value indicating whether the module is not added to the profile script of users.
|
||||||
#>
|
#>
|
||||||
function Get-ModuleInstallerComponents {
|
function Get-ModuleInstallerComponents {
|
||||||
param(
|
param(
|
||||||
[string] $Name,
|
[string] $Name,
|
||||||
[switch] $NativeOnly
|
[switch] $NativeOnly,
|
||||||
|
[switch] $NoProfile
|
||||||
)
|
)
|
||||||
|
|
||||||
@{
|
@{
|
||||||
|
@ -27,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;
|
||||||
|
@ -41,7 +55,7 @@ $null = New-Module {
|
||||||
& $Installer -Action ([InstallerAction]::Configure) @PSBoundParameters;
|
& $Installer -Action ([InstallerAction]::Configure) @PSBoundParameters;
|
||||||
};
|
};
|
||||||
|
|
||||||
configurator = {
|
configurator = ($NoProfile.IsPresent) ? { } : {
|
||||||
param(
|
param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
15
scripts/Common/Software/aliae/Constants.ps1
Normal file
15
scripts/Common/Software/aliae/Constants.ps1
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets a powershell expression which points to the global `aliae` configuration.
|
||||||
|
#>
|
||||||
|
function Get-GlobalConfigExpression {
|
||||||
|
return "`"$($IsWindows ? "`$env:ProgramData" : "/etc")/aliae/aliae.yml`"";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the path to the global `aliae` configuration.
|
||||||
|
#>
|
||||||
|
function Get-GlobalConfigPath {
|
||||||
|
return & ([scriptblock]::Create((Get-GlobalConfigExpression)));
|
||||||
|
}
|
50
scripts/Common/Software/aliae/Main.ps1
Normal file
50
scripts/Common/Software/aliae/Main.ps1
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
param(
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/Constants.ps1";
|
||||||
|
. "$PSScriptRoot/../PowerShell/Profile.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
|
-Configurator {
|
||||||
|
. "$PSScriptRoot/Constants.ps1";
|
||||||
|
$pathExpression = Get-GlobalConfigExpression;
|
||||||
|
$path = Get-GlobalConfigPath;
|
||||||
|
$null = New-Item -Force -ItemType Directory (Split-Path -Parent $path);
|
||||||
|
Copy-Item -Force "$PSScriptRoot/aliae.yml" $path;
|
||||||
|
|
||||||
|
Add-PowerShellProfileStatement `
|
||||||
|
-System `
|
||||||
|
-Category "aliae" `
|
||||||
|
-Script (
|
||||||
|
@(
|
||||||
|
{
|
||||||
|
#aliae
|
||||||
|
},
|
||||||
|
"`$globalPath = $pathExpression",
|
||||||
|
{
|
||||||
|
$userPath = & {
|
||||||
|
if ($env:ALIAE_CONFIG) {
|
||||||
|
$env:ALIAE_CONFIG;
|
||||||
|
} else {
|
||||||
|
"~/.aliae.yaml";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Test-Path $globalPath) {
|
||||||
|
$null = & ([scriptblock]::Create((aliae init pwsh --config $globalPath))) *>&1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Path $userPath) {
|
||||||
|
$null = & ([scriptblock]::Create((aliae init pwsh))) *>&1;
|
||||||
|
}
|
||||||
|
|
||||||
|
aliae completion powershell | Out-String | Invoke-Expression;
|
||||||
|
}
|
||||||
|
) -join [System.Environment]::NewLine)
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
Copy-Item -Force "$PSScriptRoot/aliae.yml" ~/.aliae.yml;
|
||||||
|
};
|
98
scripts/Common/Software/aliae/Manage.ps1
Normal file
98
scripts/Common/Software/aliae/Manage.ps1
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
$null = New-Module {
|
||||||
|
. "$PSScriptRoot/Constants.ps1";
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Adds an alias to an existing `aliae` configuration.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the alias to add.
|
||||||
|
|
||||||
|
.PARAMETER Value
|
||||||
|
The script the alias should point to.
|
||||||
|
|
||||||
|
.PARAMETER User
|
||||||
|
The user to add the alias to.
|
||||||
|
#>
|
||||||
|
function Add-Alias {
|
||||||
|
param(
|
||||||
|
[string] $Name,
|
||||||
|
[string] $Value,
|
||||||
|
[string] $User
|
||||||
|
)
|
||||||
|
|
||||||
|
Edit-Config `
|
||||||
|
-Variables @{
|
||||||
|
Name = "$Name";
|
||||||
|
Value = "$Value";
|
||||||
|
} `
|
||||||
|
".alias |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]" `
|
||||||
|
-User $User;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Adds an environment variable to an existing `aliae` configuration.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
The name of the variable to add.
|
||||||
|
|
||||||
|
.PARAMETER Value
|
||||||
|
The value of the variable.
|
||||||
|
#>
|
||||||
|
function Add-EnvironmentVariable {
|
||||||
|
param(
|
||||||
|
[string] $Name,
|
||||||
|
[string] $Value,
|
||||||
|
[string] $User
|
||||||
|
)
|
||||||
|
|
||||||
|
Edit-Config `
|
||||||
|
-Variables @{
|
||||||
|
Name = "$Name";
|
||||||
|
Value = "$Value";
|
||||||
|
} `
|
||||||
|
".env |= [((. // [])[] | select(.name != env.Name))] + [{ name: env.Name, value: env.Value }]" `
|
||||||
|
-User $User;
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Edits the underlying `aliae` configuration.
|
||||||
|
|
||||||
|
.PARAMETER Script
|
||||||
|
The yq script to run over the configuration.
|
||||||
|
|
||||||
|
.PARAMETER User
|
||||||
|
The user to edit the configuration for.
|
||||||
|
#>
|
||||||
|
function Edit-Config {
|
||||||
|
param(
|
||||||
|
[string] $Script,
|
||||||
|
[hashtable] $Variables,
|
||||||
|
[string] $User
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($User) {
|
||||||
|
$path = "$($IsWindows ? "~" : "$(sudo -u $User bash -c "realpath ~")")/.aliae.yaml";
|
||||||
|
} else {
|
||||||
|
$path = Get-GlobalConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-Job {
|
||||||
|
$file = New-TemporaryFile;
|
||||||
|
$variables = $using:Variables;
|
||||||
|
|
||||||
|
foreach ($key in $variables.Keys) {
|
||||||
|
Set-Item "Env:\$key" $variables[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
sudo -u $using:User cp $using:path $file;
|
||||||
|
yq -yi $using:Script $file;
|
||||||
|
sudo -u $using:User cp $file $using:path;
|
||||||
|
Remove-Item $file;
|
||||||
|
} | Receive-Job -Wait;
|
||||||
|
}
|
||||||
|
|
||||||
|
Export-ModuleMember -Function Add-Alias,Add-EnvironmentVariable;
|
||||||
|
};
|
|
@ -1,22 +1,4 @@
|
||||||
alias:
|
alias: []
|
||||||
- name: totsch
|
env: []
|
||||||
value: git
|
|
||||||
env:
|
|
||||||
- name: POSH_THEME
|
|
||||||
value: '{{ if eq .OS "windows" }}{{ .Home }}/Nextcloud/.omp{{ else }}/usr/local/share/oh-my-posh/themes{{ end }}/manuel.omp.json'
|
|
||||||
path: []
|
path: []
|
||||||
script:
|
script: []
|
||||||
- value: |
|
|
||||||
# Profile Files
|
|
||||||
$profileRoot = Split-Path -Parent $PROFILE;
|
|
||||||
$profilePaths = @(
|
|
||||||
"$profileRoot/conf.d/*.ps1",
|
|
||||||
"{{ if eq .OS "windows" }}$env:ProgramData{{ else }}/etc{{ end }}/powershell/conf.d/*.ps1"
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($profilePath in $profilePaths) {
|
|
||||||
if (Test-Path $profilePath) {
|
|
||||||
Get-Item $profilePath | ForEach-Object { . $_; };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if: match .Shell "pwsh"
|
|
||||||
|
|
|
@ -10,28 +10,35 @@ begin
|
||||||
function configureSW -V dir
|
function configureSW -V dir
|
||||||
source "$dir/../bash/profile.fish"
|
source "$dir/../bash/profile.fish"
|
||||||
source "$dir/../fish/profile.fish"
|
source "$dir/../fish/profile.fish"
|
||||||
set -l file /etc/aliae/aliae.yml
|
set -l file (pwsh -CommandWithArgs '. $args[0]; Get-GlobalConfigPath' "$dir/Constants.ps1");
|
||||||
echo "export ALIAE_CONFIG=$(string escape "$file")" | sudo tee /etc/profile.d/aliae.sh > /dev/null
|
|
||||||
sudo install -Dm644 "$dir/aliae.yml" "$file"
|
sudo install -Dm644 "$dir/aliae.yml" "$file"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
printf %s\n \
|
printf %s\n \
|
||||||
"# aliae" \
|
"if [ -f $(string escape $file) ]" \
|
||||||
'eval "$(aliae init bash)"' \
|
'then' \
|
||||||
|
" eval \"\$(aliae init bash --config $(string escape $file))\"" \
|
||||||
|
'fi' \
|
||||||
|
'' \
|
||||||
|
'if [ -n "$ALIAE_CONFIG" ] && [ -f "$ALIAE_CONFIG" ] || [ -f ~/.aliae.yaml ]' \
|
||||||
|
'then' \
|
||||||
|
' eval "$(aliae init bash)"' \
|
||||||
|
'fi' \
|
||||||
|
'' \
|
||||||
'eval "$(aliae completion bash)"'
|
'eval "$(aliae completion bash)"'
|
||||||
end | installBashProfile "aliae" "aliae"
|
end | installBashProfile "aliae" "aliae"
|
||||||
|
|
||||||
begin
|
|
||||||
printf %s\n "" \
|
|
||||||
"# aliae" \
|
|
||||||
'eval "$(aliae init bash)"' \
|
|
||||||
'eval "$(aliae completion bash)"'
|
|
||||||
end | sudo tee /etc/skel/.bashrc > /dev/null
|
|
||||||
|
|
||||||
if type -q fish
|
if type -q fish
|
||||||
begin
|
begin
|
||||||
printf %s\n \
|
printf %s\n \
|
||||||
"aliae init fish | source" \
|
"if [ -f $(string escape $file) ]" \
|
||||||
|
" eval \"\$(aliae init bash --config $(string escape $file))\"" \
|
||||||
|
'end' \
|
||||||
|
'' \
|
||||||
|
'if [ -n "$ALIAE_CONFIG" ] && [ -f "$ALIAE_CONFIG" ] || [ -f ~/.aliae.yaml ]' \
|
||||||
|
' aliae init fish | source' \
|
||||||
|
'end' \
|
||||||
|
'' \
|
||||||
"aliae completion fish | source"
|
"aliae completion fish | source"
|
||||||
end | installFishProfile "aliae" "aliae"
|
end | installFishProfile "aliae" "aliae"
|
||||||
end
|
end
|
||||||
|
|
126
scripts/Common/Software/git/Manage.ps1
Normal file
126
scripts/Common/Software/git/Manage.ps1
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
param (
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/System.ps1";
|
||||||
|
. "$PSScriptRoot/../../Types/InstallerAction.ps1";
|
||||||
|
|
||||||
|
$null = New-Module {
|
||||||
|
param(
|
||||||
|
[hashtable] $Parameters
|
||||||
|
)
|
||||||
|
|
||||||
|
$configure = {
|
||||||
|
param(
|
||||||
|
[string] $User
|
||||||
|
)
|
||||||
|
|
||||||
|
$root = "valhalla";
|
||||||
|
|
||||||
|
if ($User) {
|
||||||
|
$root = "$root$($IsWindows ? ".windows" : '').users.$User";
|
||||||
|
$sudoArgs = @("-u", $User);
|
||||||
|
$configArgs = @("--global");
|
||||||
|
} else {
|
||||||
|
$sudoArgs = @();
|
||||||
|
$configArgs = @("--system");
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the specified git configuration.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
THe name of the configuration to get.
|
||||||
|
#>
|
||||||
|
function Get-GitConfig {
|
||||||
|
param(
|
||||||
|
[string] $Name
|
||||||
|
)
|
||||||
|
|
||||||
|
Get-Config "$root.git.$Name";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Sets a configuration option in git.
|
||||||
|
#>
|
||||||
|
function Set-GitConfig {
|
||||||
|
sudo @sudoArgs git config @configArgs $args;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((-not $IsWindows) -or $User) {
|
||||||
|
$branch = Get-GitConfig "defaultBranch";
|
||||||
|
|
||||||
|
if ($branch) {
|
||||||
|
Set-GitConfig "init.defaultBranch" $branch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($User) {
|
||||||
|
$displayName = Get-UserConfig "displayName";
|
||||||
|
$mailAddress = Get-UserConfig "mailAddress";
|
||||||
|
|
||||||
|
if ($displayName) {
|
||||||
|
Set-GitConfig "user.name" $displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($mailAddress) {
|
||||||
|
Set-GitConfig "user.email" $mailAddress;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Git Flow
|
||||||
|
. {
|
||||||
|
$dir = New-TemporaryDirectory;
|
||||||
|
$key = "flow";
|
||||||
|
$mainBranch = Get-GitConfig "$key.mainBranch";
|
||||||
|
$devBranch = Get-GitConfig "$key.devBranch";
|
||||||
|
|
||||||
|
& {
|
||||||
|
git -C "$dir" init;
|
||||||
|
git -C "$dir" config user.name "PortValhalla";
|
||||||
|
git -C "$dir" config user.email "no-reply@valhal.la";
|
||||||
|
git -C "$dir" commit --allow-empty -m "Initial commit";
|
||||||
|
git -C "$dir" branch master;
|
||||||
|
git -C "$dir" branch dev;
|
||||||
|
git -C "$dir" flow init --defaults;
|
||||||
|
} | Out-Null;
|
||||||
|
|
||||||
|
if ($mainBranch) {
|
||||||
|
git -C "$dir" branch $mainBranch | Out-Null;;
|
||||||
|
sudo @sudoArgs git -C "$dir" flow config set @configArgs master $mainBranch;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($devBranch) {
|
||||||
|
git -C "$dir" branch $devBranch | Out-Null;
|
||||||
|
sudo @sudoArgs git -C "$dir" flow config set @configArgs develop $devBranch;
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove-Item -Recurse -Force $dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Aliases
|
||||||
|
[PSCustomObject] $aliases = Get-GitConfig "aliases";
|
||||||
|
|
||||||
|
if ($aliases) {
|
||||||
|
foreach ($alias in ($aliases | Get-Member -MemberType Properties)) {
|
||||||
|
Set-GitConfig "alias.$($alias.Name)" $aliases.$($alias.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Configurator {
|
||||||
|
& $configure @PSBoundParameters;
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
& $configure -User $Arguments.Name;
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
26
scripts/Common/Software/vscode/Main.ps1
Normal file
26
scripts/Common/Software/vscode/Main.ps1
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
param(
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/SoftwareManagement.ps1";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
$Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
$bins = @("codium", "codium-insiders", "code", "code-insiders");
|
||||||
|
$extensions = @("zokugun.sync-settings", "zokugun.vsix-manager");
|
||||||
|
$user = $Arguments.Name;
|
||||||
|
|
||||||
|
foreach ($bin in $bins) {
|
||||||
|
if (Test-Command "$bin") {
|
||||||
|
foreach ($extension in $extensions) {
|
||||||
|
sudo -u "$user" "$bin" --install-extension "$extension";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -2,19 +2,9 @@
|
||||||
begin
|
begin
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/../../Scripts/software.fish"
|
source "$dir/../../Scripts/software.fish"
|
||||||
source "$dir/../../../Common/Software/aliae/main.fish"
|
|
||||||
|
|
||||||
function userConfig -a name
|
function userConfig -V dir -a name
|
||||||
set -l bins codium codium-insiders code code-insiders
|
pwsh "$dir/Main.ps1" ConfigureUser;
|
||||||
set -l extensions zokugun.{sync-settings,vsix-manager}
|
|
||||||
|
|
||||||
for bin in $bins
|
|
||||||
if type -q "$bin"
|
|
||||||
for extension in $extensions
|
|
||||||
sudo -u "$name" "$bin" --install-extension "$extension"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
runInstaller $argv
|
runInstaller $argv
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
enum InstallerAction {
|
enum InstallerAction {
|
||||||
|
Backup
|
||||||
Install
|
Install
|
||||||
Configure
|
Configure
|
||||||
|
BackupUser
|
||||||
ConfigureUser
|
ConfigureUser
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
enum OneShotTask {
|
enum OneShotTask {
|
||||||
|
InitializeMSAccount
|
||||||
DisableUAC
|
DisableUAC
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,664 +0,0 @@
|
||||||
#!/bin/pwsh
|
|
||||||
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
|
|
||||||
[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-Command "gsudo")) {
|
|
||||||
Install-ChocoPackage gsudo;
|
|
||||||
refreshenv;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Command "git")) {
|
|
||||||
Install-ChocoPackage git;
|
|
||||||
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 (-not (Test-Winget)) {
|
|
||||||
. "$PSScriptRoot/../Software/winget/Manage.ps1";
|
|
||||||
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 -Force (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 -AcceptLicense -Force PSWindowsUpdate;
|
|
||||||
Install-Module -AcceptLicense -Force PSScriptAnalyzer;
|
|
||||||
. "$PSScriptRoot/../Software/PinnedItem/Manage.ps1";
|
|
||||||
};
|
|
||||||
|
|
||||||
Set-Stage ([SetupStage]::Configure);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
([SetupStage]::OneShot) {
|
|
||||||
Write-Host "Running a OneShot task";
|
|
||||||
|
|
||||||
Start-OneShot {
|
|
||||||
Write-Host "task is-a running!";
|
|
||||||
switch (Get-OneShotTask) {
|
|
||||||
([OneShotTask]::DisableUAC) {
|
|
||||||
Disable-UAC;
|
|
||||||
Register-Setup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default {
|
|
||||||
if (-not (& { $null = wsl -l; $? })) {
|
|
||||||
wsl --import-in-place "PortValhalla" "$wslLocation/ext4.vhdx";
|
|
||||||
wsl --set-default "PortValhalla";
|
|
||||||
}
|
|
||||||
|
|
||||||
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(
|
|
||||||
[InstallerAction] $Action = $null
|
|
||||||
)
|
|
||||||
|
|
||||||
[bool] $install = $null;
|
|
||||||
$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";
|
|
||||||
|
|
||||||
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.elgatoWave") {
|
|
||||||
if (-not (Test-ChocoPackage wavelink)) {
|
|
||||||
Install-ChocoPackage wavelink -ArgumentList '--install-arguments="/norestart"';
|
|
||||||
Remove-DesktopIcon "*Wave Link*";
|
|
||||||
Restart-Intermediate;
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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/OpenSSH/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/PowerShell/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/chocolatey/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/zoxide/Manage.ps1" @arguments;
|
|
||||||
& "$commonSoftware/posh-git/Manage.ps1" @arguments;
|
|
||||||
& "$commonSoftware/Terminal-Icons/Manage.ps1" @arguments;
|
|
||||||
& "$commonSoftware/Oh My Posh/Manage.ps1" @arguments;
|
|
||||||
|
|
||||||
if ($install) {
|
|
||||||
Install-ChocoPackage `
|
|
||||||
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 `
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 "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/Manage.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 `
|
|
||||||
jellyfin-media-player `
|
|
||||||
vlc `
|
|
||||||
;
|
|
||||||
|
|
||||||
Remove-DesktopIcon "VLC*";
|
|
||||||
Install-WingetPackage Ytmdesktop.Ytmdesktop;
|
|
||||||
Remove-DesktopIcon "Youtube Music*";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Test-Collection "coding") {
|
|
||||||
if ($install) {
|
|
||||||
Install-ChocoPackage vscode -ArgumentList "--params","/NoDesktopIcon";
|
|
||||||
Install-ChocoPackage vscodium -ArgumentList "--params","/NoDesktopIcon /AssociateWithFiles";
|
|
||||||
|
|
||||||
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 `
|
|
||||||
steam `
|
|
||||||
rayman-controlpanel `
|
|
||||||
ppsspp `
|
|
||||||
;
|
|
||||||
|
|
||||||
Remove-DesktopIcon "*Epic Games*";
|
|
||||||
Remove-DesktopIcon "*Steam*";
|
|
||||||
Remove-DesktopIcon "*PPSSPP *-Bit*";
|
|
||||||
|
|
||||||
Install-ChocoPackage ubisoft-connect -ArgumentList "--ignore-checksums";
|
|
||||||
Remove-DesktopIcon "*Ubisoft Connect*";
|
|
||||||
|
|
||||||
Install-WingetPackage ElectronicArts.EADesktop;
|
|
||||||
Remove-DesktopIcon "EA.*";
|
|
||||||
}
|
|
||||||
|
|
||||||
& "$softwarePath/TrackMania Nations Forever/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/TrackMania United Forever/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/ManiaPlanet/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/osu!/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/osu!lazer/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/RetroArch/Manage.ps1" @arguments;
|
|
||||||
& "$softwarePath/reWASD/Manage.ps1" @arguments;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Get-Stage) {
|
|
||||||
([SetupStage]::Configure) {
|
|
||||||
if (Get-Config "valhalla.windows.dualboot.enable") {
|
|
||||||
# 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-ItemProperty $timeZoneKey -Name $timeZoneOption;
|
|
||||||
$stopped = ($service.Status -eq "Stopped");
|
|
||||||
|
|
||||||
$setUpdate = { param([int] $Value) Set-ItemProperty $timeZoneKey -Name $timeZoneOption $Value };
|
|
||||||
& $setUpdate 3;
|
|
||||||
Start-Service $service;
|
|
||||||
w32tm /resync /force;
|
|
||||||
& $setUpdate $autoUpdate;
|
|
||||||
|
|
||||||
if ($stopped) {
|
|
||||||
Stop-Service $service;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-Stage ([SetupStage]::Install);
|
|
||||||
}
|
|
||||||
([SetupStage]::Install) {
|
|
||||||
Write-Host "Entering install phase";
|
|
||||||
Deploy-SoftwareAction;
|
|
||||||
Set-Stage ([SetupStage]::CreateUser);
|
|
||||||
}
|
|
||||||
([SetupStage]::CreateUser) {
|
|
||||||
Start-ValhallaUserSetup;
|
|
||||||
Set-Stage ([SetupStage]::ConfigureUser);
|
|
||||||
}
|
|
||||||
([SetupStage]::ConfigureUser) {
|
|
||||||
$userOption = "CurrentUser";
|
|
||||||
|
|
||||||
function Get-CurrentUser {
|
|
||||||
(Get-SetupOption $userOption) ?? 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Set-CurrentUser {
|
|
||||||
param([int] $Value)
|
|
||||||
Set-SetupOption $userOption $Value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[string[]] $users = Get-Users;
|
|
||||||
$currentUser = Get-CurrentUser;
|
|
||||||
|
|
||||||
if (Test-Admin) {
|
|
||||||
Disable-BootMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($currentUser -lt $users.Count) {
|
|
||||||
$user = Get-LocalUser $users[$currentUser];
|
|
||||||
$msAccount = Get-UserConfig -UserName "$user" -Name "microsoftAccount";
|
|
||||||
|
|
||||||
$adminGroup = @{
|
|
||||||
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
|
||||||
};
|
|
||||||
|
|
||||||
Add-LocalGroupMember `
|
|
||||||
@adminGroup `
|
|
||||||
$user `
|
|
||||||
-ErrorAction SilentlyContinue;
|
|
||||||
|
|
||||||
if ($env:UserName -ne "$user") {
|
|
||||||
Disable-LocalUser $env:UserName;
|
|
||||||
Enable-LocalUser $user;
|
|
||||||
|
|
||||||
if ($msAccount) {
|
|
||||||
Enable-UAC;
|
|
||||||
Disable-Autologin;
|
|
||||||
Enable-OneShotListener;
|
|
||||||
Set-BootMessage -Caption "Please Log In" -Message "Please log in using your new Microsoft Account ``$user``.";
|
|
||||||
} else {
|
|
||||||
Set-AutologinUser "$user";
|
|
||||||
}
|
|
||||||
|
|
||||||
Restart-Intermediate -DefaultUser;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$configure = {
|
|
||||||
Deploy-SoftwareAction -Action ([InstallerAction]::ConfigureUser);
|
|
||||||
Remove-LocalGroupMember -Member "$user" @adminGroup -ErrorAction SilentlyContinue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($msAccount) {
|
|
||||||
if (-not (Test-Admin)) {
|
|
||||||
Invoke-OneShot DisableUAC;
|
|
||||||
Restart-Computer;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
& $configure;
|
|
||||||
Clear-SetupRegistration;
|
|
||||||
Disable-OneShotListener;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
& $configure;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-CurrentUser ($currentUser + 1);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-IsFinished $true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,276 @@
|
||||||
#!/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/Legacy.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/Scripting.ps1";
|
||||||
}
|
. "$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 ([WindowsInstallerAction]::Install);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Starts the installation loop.
|
||||||
|
#>
|
||||||
|
function Start-InstallationLoop {
|
||||||
|
param(
|
||||||
|
[WindowsInstallerAction] $Action
|
||||||
|
)
|
||||||
|
|
||||||
function Read-Path()
|
while ((Get-Stage) -ne ([WindowsInstallerStage]::Completed)) {
|
||||||
{
|
switch (Get-Stage) {
|
||||||
$backupPath = Read-Host -Prompt "Please enter the path to the archive to load the backup from.";
|
($null) {
|
||||||
|
Set-Stage ([WindowsInstallerStage]::Initialize);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
([WindowsInstallerStage]::Initialize) {
|
||||||
|
$env:BACKUP_ARCHIVE = pwsh -Command Write-Host (
|
||||||
|
Read-Host (
|
||||||
|
& {
|
||||||
|
switch ($Action) {
|
||||||
|
([WindowsInstallerAction]::Backup) {
|
||||||
|
"Please select the path you wish to store your backup at"
|
||||||
|
}
|
||||||
|
([WindowsInstallerAction]::Install) {
|
||||||
|
"Please select an archive you wish to restore from, if you wish to restore from a backup"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
if ($backupPath -and (-not (Test-Path -PathType Leaf $backupPath)))
|
Set-Stage ([WindowsInstallerStage]::Run);
|
||||||
{
|
break;
|
||||||
Write-Host "No file could be found at the specified path.";
|
}
|
||||||
return Read-Path;
|
([WindowsInstallerStage]::Run) {
|
||||||
}
|
switch ($Action) {
|
||||||
else
|
([WindowsInstallerAction]::Install) {
|
||||||
{
|
while (-not (Get-IsFinished)) {
|
||||||
return $backupPath;
|
if (Test-Admin) {
|
||||||
|
$null = Import-Module PSWindowsUpdate;
|
||||||
|
|
||||||
|
Invoke-Hook "Invoke-WindowsUpdate" -Fallback {
|
||||||
|
Update-WindowsInstallation;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((Get-WURebootStatus -Silent)) {
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Get-SetupStage) {
|
||||||
|
($null) {
|
||||||
|
Set-SetupStage ([SetupStage]::Configure);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
([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);
|
||||||
|
Restart-Intermediate;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
([SetupStage]::CreateUser) {
|
||||||
|
Install-ValhallaUsers;
|
||||||
|
Set-IsFinished $true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-Stage ([WindowsInstallerStage]::Cleanup);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
([WindowsInstallerStage]::Cleanup) {
|
||||||
|
$taskName = "PortValhalla Cleaner";
|
||||||
|
$setupUser = Get-SetupUser;
|
||||||
|
Clear-OperationResources;
|
||||||
|
Remove-Item -Recurse -Force "C:\ProgramData\PortValhalla";
|
||||||
|
Get-SetupConfigKey | Remove-Item -Recurse -Force;
|
||||||
|
Disable-Autologin;
|
||||||
|
Disable-LocalUser $setupUser;
|
||||||
|
|
||||||
|
$script = {
|
||||||
|
param(
|
||||||
|
$TaskName,
|
||||||
|
$UserName
|
||||||
|
)
|
||||||
|
|
||||||
|
$user = Get-LocalUser $UserName;
|
||||||
|
[string] $sid = $user.SID;
|
||||||
|
Remove-LocalUser $user;
|
||||||
|
Get-CimInstance Win32_UserProfile | Where-Object { $_.SID -eq $sid } | Remove-CimInstance;
|
||||||
|
Unregister-ScheduledTask -Confirm:$false $TaskName;
|
||||||
|
};
|
||||||
|
|
||||||
|
$trigger = New-ScheduledTaskTrigger -AtStartup;
|
||||||
|
$task = New-ScheduledTaskAction -Execute "pwsh" -Argument "-Command & { $script } $(ConvertTo-Injection $taskName) $(ConvertTo-Injection $setupUser)";
|
||||||
|
$null = Register-ScheduledTask -Force $taskName -Action $task -Trigger $trigger -RunLevel Highest -User "SYSTEM";
|
||||||
|
Set-Stage ([WindowsInstallerStage]::Completed);
|
||||||
|
Restart-Intermediate -NoRegister;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
|
@ -186,6 +186,20 @@ function Start-Setup {
|
||||||
Move-PartitionRange -Disk $Disk -1 -1 ($To + 1)
|
Move-PartitionRange -Disk $Disk -1 -1 ($To + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Add-StartupCommand {
|
||||||
|
param(
|
||||||
|
[string] $Script,
|
||||||
|
[string] $Description
|
||||||
|
)
|
||||||
|
|
||||||
|
$installationCommand = $oobeSettings.SelectSingleNode("./ua:FirstLogonCommands/ua:SynchronousCommand[last()]", $namespace);
|
||||||
|
$newCommand = $installationCommand.ParentNode.AppendChild($installationCommand.CloneNode($true));
|
||||||
|
$newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = $Script;
|
||||||
|
$orderElement = $newCommand.SelectSingleNode("./ua:Order", $namespace);
|
||||||
|
$orderElement.InnerText = ([int]($orderElement.InnerText) + 1);
|
||||||
|
$newCommand.SelectSingleNode("./ua:Description", $namespace).InnerText = $Description;
|
||||||
|
}
|
||||||
|
|
||||||
# Collect necessary variables
|
# Collect necessary variables
|
||||||
$winpePass = Get-PassSettings "windowsPE";
|
$winpePass = Get-PassSettings "windowsPE";
|
||||||
$setupConfig = Get-Component $winpePass "Microsoft-Windows-Setup";
|
$setupConfig = Get-Component $winpePass "Microsoft-Windows-Setup";
|
||||||
|
@ -210,22 +224,18 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
$installationCommand = $oobeSettings.SelectSingleNode("./ua:FirstLogonCommands/ua:SynchronousCommand[last()]", $namespace);
|
Add-StartupCommand `
|
||||||
$newCommand = $installationCommand.ParentNode.AppendChild($installationCommand.CloneNode($true));
|
-Script (
|
||||||
|
"powershell -Command " +
|
||||||
$newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `
|
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
||||||
"powershell -Command " + `
|
"`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" +
|
||||||
"`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" + `
|
"`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" +
|
||||||
"`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" + `
|
"`$env:CONFIG_MODULE = $(Get-ScriptPathInjection $env:CONFIG_MODULE);" +
|
||||||
"`$env:CONFIG_MODULE = $(Get-ScriptPathInjection $env:CONFIG_MODULE);" + `
|
"& (Join-Path `$env:PWSH_PATH pwsh) `$env:INSTALLER_SCRIPT;") `
|
||||||
"& (Join-Path `$env:PWSH_PATH pwsh) `$env:INSTALLER_SCRIPT;";
|
-Description "Install PowerShell Core and git and run setup script";
|
||||||
|
|
||||||
$orderElement = $newCommand.SelectSingleNode("./ua:Order", $namespace);
|
|
||||||
$orderElement.InnerText = ([int]($orderElement.InnerText) + 1);
|
|
||||||
$newCommand.SelectSingleNode("./ua:Description", $namespace).InnerText = "Install PowerShell Core and git and run setup script";
|
|
||||||
|
|
||||||
if ($valhallaConfig.dualboot.enable) {
|
if ($valhallaConfig.dualboot.enable) {
|
||||||
$diskSize = [long](ConvertFrom-Csv (wmic diskdrive where "Index=$(Get-InstallDisk)" get Size | ForEach-Object { "$_".Trim(); })).Size;
|
$diskSize = [long](ConvertFrom-Csv (wmic diskdrive where "Index=$(Get-InstallDisk)" get Size | ForEach-Object { "$_".Trim(); })).Size;
|
||||||
|
|
|
@ -206,12 +206,6 @@
|
||||||
</SynchronousCommand> -->
|
</SynchronousCommand> -->
|
||||||
<SynchronousCommand wcm:action="add">
|
<SynchronousCommand wcm:action="add">
|
||||||
<Order>1</Order>
|
<Order>1</Order>
|
||||||
<RequiresUserInput>true</RequiresUserInput>
|
|
||||||
<CommandLine>cmd /C wmic useraccount where name="Admin" set PasswordExpires=false</CommandLine>
|
|
||||||
<Description>Password Never Expires</Description>
|
|
||||||
</SynchronousCommand>
|
|
||||||
<SynchronousCommand wcm:action="add">
|
|
||||||
<Order>2</Order>
|
|
||||||
<RequiresUserInput>false</RequiresUserInput>
|
<RequiresUserInput>false</RequiresUserInput>
|
||||||
<CommandLine>powershell -Command "Set-ExecutionPolicy -Force Bypass"</CommandLine>
|
<CommandLine>powershell -Command "Set-ExecutionPolicy -Force Bypass"</CommandLine>
|
||||||
<Description>Allow PowerShell scripts from anywhere.</Description>
|
<Description>Allow PowerShell scripts from anywhere.</Description>
|
||||||
|
|
|
@ -104,7 +104,7 @@ $null = New-Module {
|
||||||
$writer = [XmlWriter]::Create($configFile.FullName, $writerSettings);
|
$writer = [XmlWriter]::Create($configFile.FullName, $writerSettings);
|
||||||
$document.Save($writer);
|
$document.Save($writer);
|
||||||
$writer.Dispose();
|
$writer.Dispose();
|
||||||
DISM /Online "/Import-DefaultAppAssociations:$($configFile.FullName)";
|
$null = DISM /Online "/Import-DefaultAppAssociations:$($configFile.FullName)";
|
||||||
Remove-Item $configFile;
|
Remove-Item $configFile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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-Icons/Manage.ps1" @arguments;
|
||||||
|
& "$softwarePath/Oh My Posh/Manage.ps1" @arguments;
|
||||||
|
|
||||||
|
if (Get-Config "valhalla.windows.dualboot") {
|
||||||
|
& "$softwarePath/Ext4Fsd/Main.ps1" @arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($install) {
|
||||||
|
Install-ChocoPackage `
|
||||||
|
procexp `
|
||||||
|
procmon `
|
||||||
|
;
|
||||||
|
|
||||||
|
Install-WingetPackage `
|
||||||
|
KDE.KDEConnect `
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Common Software
|
||||||
|
if (Test-Collection "common") {
|
||||||
|
& "$softwarePath/WinSCP/Manage.ps1" @arguments;
|
||||||
|
& "$softwarePath/Thunderbird/Manage.ps1" @arguments;
|
||||||
|
& "$softwarePath/PuTTY/Manage.ps1" @arguments;
|
||||||
|
|
||||||
|
if ($install) {
|
||||||
|
Install-ChocoPackage `
|
||||||
|
7zip `
|
||||||
|
chocolateygui `
|
||||||
|
DefaultProgramsEditor `
|
||||||
|
bitwarden `
|
||||||
|
keepass `
|
||||||
|
;
|
||||||
|
|
||||||
|
Install-WingetPackage `
|
||||||
|
SomePythonThings.WingetUIStore `
|
||||||
|
;
|
||||||
|
|
||||||
|
Remove-DesktopIcon "UniGetUI*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Collection "desktopExperience") {
|
||||||
|
if ($install) {
|
||||||
|
# Fonts
|
||||||
|
Install-ChocoPackage nerd-fonts-CascadiaCode;
|
||||||
|
|
||||||
|
# Internet Access
|
||||||
|
Install-WingetPackage Brave.Brave kamranahmedse.pennywise;
|
||||||
|
Remove-DesktopIcon "*Brave*";
|
||||||
|
Remove-TaskbarItem "*Brave*";
|
||||||
|
Remove-DesktopIcon "Pennywise*";
|
||||||
|
|
||||||
|
# Tools
|
||||||
|
Install-SetupPackage -Source "https://github.com/mRemoteNG/mRemoteNG/releases/download/2023.03.03-v1.77.3-nb/mRemoteNG-Installer-1.77.3.nb-1784.msi" -ArgumentList "/Quiet";
|
||||||
|
Remove-DesktopIcon "mRemoteNG*";
|
||||||
|
|
||||||
|
Install-ChocoPackage `
|
||||||
|
gimp `
|
||||||
|
gpu-z `
|
||||||
|
windirstat `
|
||||||
|
winmerge `
|
||||||
|
handbrake `
|
||||||
|
hwmonitor `
|
||||||
|
qbittorrent `
|
||||||
|
imgburn `
|
||||||
|
inkscape `
|
||||||
|
krita `
|
||||||
|
MetaX `
|
||||||
|
obs-studio `
|
||||||
|
;
|
||||||
|
|
||||||
|
Remove-DesktopIcon "GIMP*";
|
||||||
|
Remove-DesktopIcon "GPU-Z*";
|
||||||
|
Remove-DesktopIcon "WinDirStat*";
|
||||||
|
Remove-DesktopIcon "*HWMonior*";
|
||||||
|
Remove-DesktopIcon "ImgBurn*";
|
||||||
|
Remove-DesktopIcon "InkScape*";
|
||||||
|
Remove-DesktopIcon "Krita*";
|
||||||
|
Remove-DesktopIcon "MetaX*";
|
||||||
|
Remove-DesktopIcon "OBS Studio*";
|
||||||
|
|
||||||
|
Install-WingetPackage `
|
||||||
|
AntSoftware.AntRenamer `
|
||||||
|
AppWork.JDownloader `
|
||||||
|
;
|
||||||
|
|
||||||
|
Remove-DesktopIcon "JDownloader*";
|
||||||
|
}
|
||||||
|
|
||||||
|
# ToDo: Consider hiding behind own config?
|
||||||
|
& "$softwarePath/Ubiquiti UniFi Controller/Manage.ps1" @arguments;
|
||||||
|
|
||||||
|
# Internet Access
|
||||||
|
& "$softwarePath/Firefox/Manage.ps1" @arguments;
|
||||||
|
& "$softwarePath/MSEdgeRedirect/Manage.ps1" @arguments;
|
||||||
|
|
||||||
|
if (Test-Collection "fileSync") {
|
||||||
|
& "$softwarePath/Nextcloud/Main.ps1" @arguments;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Collection "socialMedia") {
|
||||||
|
if ($install) {
|
||||||
|
Install-ChocoPackage `
|
||||||
|
signal `
|
||||||
|
threema-desktop `
|
||||||
|
element-desktop `
|
||||||
|
teamspeak `
|
||||||
|
;
|
||||||
|
|
||||||
|
Remove-DesktopIcon "*Element*";
|
||||||
|
Remove-DesktopIcon "*TeamSpeak*";
|
||||||
|
|
||||||
|
Install-WingetPackage Discord.Discord;
|
||||||
|
Remove-DesktopIcon "*Discord*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Collection "media") {
|
||||||
|
if ($install) {
|
||||||
|
Install-ChocoPackage `
|
||||||
|
k-litecodecpackmega `
|
||||||
|
vlc `
|
||||||
|
;
|
||||||
|
|
||||||
|
Remove-DesktopIcon "VLC*";
|
||||||
|
# When installing Jellyfin Media Player after iCUE, Jellyfin will try to reboot automatically
|
||||||
|
Install-ChocoPackage jellyfin-media-player -ArgumentList "--install-args","/norestart";
|
||||||
|
Remove-DesktopIcon "Jellyfin Media Player*";
|
||||||
|
Install-WingetPackage Ytmdesktop.Ytmdesktop;
|
||||||
|
Remove-DesktopIcon "Youtube Music*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Collection "coding") {
|
||||||
|
if ($install) {
|
||||||
|
& "$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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ $null = New-Module {
|
||||||
[string] $path = $null;
|
[string] $path = $null;
|
||||||
|
|
||||||
if ($UserKey) {
|
if ($UserKey) {
|
||||||
$path = "$($UserKey.PSPath)\$runOncePath";
|
$path = Join-Path ($UserKey.PSPath) $runOncePath;
|
||||||
} else {
|
} else {
|
||||||
$path = $systemRunOncePath;
|
$path = $systemRunOncePath;
|
||||||
}
|
}
|
||||||
|
@ -43,22 +43,17 @@ $null = New-Module {
|
||||||
Generates a script for executing the installer.
|
Generates a script for executing the installer.
|
||||||
#>
|
#>
|
||||||
function Get-StartupScript {
|
function Get-StartupScript {
|
||||||
"pwsh " + (Get-StartupArguments);
|
"pwsh -Command " + (Get-StartupCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Generates arguments for running the installer using `pwsh`.
|
Generates a command for running the installer using `pwsh`.
|
||||||
#>
|
#>
|
||||||
function Get-StartupArguments {
|
function Get-StartupCommand {
|
||||||
"-Command " +
|
($env:PWSH_PATH ? "`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);" : "") +
|
||||||
(& {
|
($env:DEBUG ? "`$env:DEBUG = $([int]$env:DEBUG);" : "") +
|
||||||
if ($env:PWSH_PATH) {
|
($env:BACKUP_ARCHIVE ? "`$env:BACKUP_ARCHIVE = $(ConvertTo-Injection (Resolve-Path $env:BACKUP_ARCHIVE));" : "") +
|
||||||
"`$env:PWSH_PATH = $(ConvertTo-Injection $env:PWSH_PATH);"
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}) +
|
|
||||||
"`$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;";
|
||||||
|
@ -75,6 +70,8 @@ $null = New-Module {
|
||||||
param(
|
param(
|
||||||
[Parameter(ParameterSetName="System")]
|
[Parameter(ParameterSetName="System")]
|
||||||
[switch] $System,
|
[switch] $System,
|
||||||
|
[Parameter(ParameterSetName="DefaultUser", Mandatory)]
|
||||||
|
[switch] $DefaultUser,
|
||||||
[Parameter(ParameterSetName="User", Mandatory)]
|
[Parameter(ParameterSetName="User", Mandatory)]
|
||||||
[switch] $User,
|
[switch] $User,
|
||||||
[Parameter(ParameterSetName="User")]
|
[Parameter(ParameterSetName="User")]
|
||||||
|
@ -82,6 +79,18 @@ $null = New-Module {
|
||||||
[RegistryKey] $UserKey
|
[RegistryKey] $UserKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ($DefaultUser.IsPresent) {
|
||||||
|
Edit-DefaultUserKey {
|
||||||
|
param(
|
||||||
|
[RegistryKey] $Key
|
||||||
|
)
|
||||||
|
|
||||||
|
Register-Setup -UserKey $Key;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($User.IsPresent -or $UserKey) {
|
if ($User.IsPresent -or $UserKey) {
|
||||||
if (-not $UserKey) {
|
if (-not $UserKey) {
|
||||||
$UserKey = Get-Item "HKCU:\";
|
$UserKey = Get-Item "HKCU:\";
|
||||||
|
@ -96,6 +105,21 @@ $null = New-Module {
|
||||||
$key.Handle.Close();
|
$key.Handle.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Clears leftovers from past registrations.
|
||||||
|
#>
|
||||||
|
function Clear-SetupRegistration {
|
||||||
|
Edit-DefaultUserKey {
|
||||||
|
param(
|
||||||
|
[RegistryKey] $Key
|
||||||
|
)
|
||||||
|
|
||||||
|
$runOnceKey = Get-RunOnceKey $Key;
|
||||||
|
Remove-Item $runOnceKey.PSPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Sets the user to login automatically on boot.
|
Sets the user to login automatically on boot.
|
||||||
|
@ -143,21 +167,22 @@ $null = New-Module {
|
||||||
#>
|
#>
|
||||||
function Restart-Intermediate {
|
function Restart-Intermediate {
|
||||||
param(
|
param(
|
||||||
[switch] $DefaultUser
|
[Parameter(ParameterSetName="None")]
|
||||||
|
[switch] $NoRegister,
|
||||||
|
[Parameter(ParameterSetName="Default", Mandatory)]
|
||||||
|
[switch] $DefaultUser,
|
||||||
|
[Parameter(ParameterSetName="Current", Mandatory)]
|
||||||
|
[switch] $CurrentUser
|
||||||
)
|
)
|
||||||
|
|
||||||
$register = { param($UserKey) Register-Setup @PSBoundParameters; };
|
if (-not $NoRegister.IsPresent) {
|
||||||
|
if ($DefaultUser.IsPresent) {
|
||||||
if ($DefaultUser) {
|
Register-Setup -DefaultUser;
|
||||||
Edit-DefaultUserKey {
|
} elseif ($CurrentUser.IsPresent) {
|
||||||
param(
|
Register-Setup -User;
|
||||||
[RegistryKey] $Key
|
} else {
|
||||||
)
|
Register-Setup;
|
||||||
|
|
||||||
& $register $Key;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
& $register;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Restart-Computer -Force;
|
Restart-Computer -Force;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
using namespace Microsoft.Win32;
|
using namespace Microsoft.Win32;
|
||||||
|
|
||||||
$null = New-Module {
|
$null = New-Module {
|
||||||
|
$wuPolicyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate";
|
||||||
|
|
||||||
function Edit-DefaultUserKey {
|
function Edit-DefaultUserKey {
|
||||||
param(
|
param(
|
||||||
[scriptblock] $Action
|
[scriptblock] $Action
|
||||||
|
@ -53,4 +55,12 @@ $null = New-Module {
|
||||||
function Disable-BootMessage {
|
function Disable-BootMessage {
|
||||||
Set-BootMessage;
|
Set-BootMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Resets the automatic reboot state.
|
||||||
|
#>
|
||||||
|
function Reset-WindowsUpdateAutoRestart {
|
||||||
|
Remove-Item -Recurse "$wuPolicyPath";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
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) {
|
||||||
|
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) {
|
||||||
|
$null = New-Item -ItemType Directory $Target -Force;
|
||||||
|
$filePath = "$filePath/*";
|
||||||
|
}
|
||||||
|
|
||||||
|
Copy-Item -Recurse $filePath $Target -Force;
|
||||||
|
}
|
||||||
|
|
||||||
|
Remove-Item -Recurse -Force $dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
|
@ -55,7 +55,13 @@ $null = New-Module {
|
||||||
[FileSystemAccessRule]::new(
|
[FileSystemAccessRule]::new(
|
||||||
[SecurityIdentifier]::new([WellKnownSidType]::BuiltinUsersSid, $null),
|
[SecurityIdentifier]::new([WellKnownSidType]::BuiltinUsersSid, $null),
|
||||||
[FileSystemRights]::FullControl,
|
[FileSystemRights]::FullControl,
|
||||||
[InheritanceFlags]::ObjectInherit -bor [InheritanceFlags]::ContainerInherit,
|
(& {
|
||||||
|
if (Test-Path -PathType Container $Path) {
|
||||||
|
[InheritanceFlags]::ObjectInherit -bor [InheritanceFlags]::ContainerInherit
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}),
|
||||||
[PropagationFlags]::InheritOnly,
|
[PropagationFlags]::InheritOnly,
|
||||||
[AccessControlType]::Allow));
|
[AccessControlType]::Allow));
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,14 @@ function Update-WindowsInstallation {
|
||||||
Runs the Windows update loop.
|
Runs the Windows update loop.
|
||||||
#>
|
#>
|
||||||
function Start-UpdateLoop {
|
function Start-UpdateLoop {
|
||||||
Write-Host "Preparing for Windows Update";
|
|
||||||
$null = Import-Module PSWindowsUpdate;
|
$null = Import-Module PSWindowsUpdate;
|
||||||
|
$hasUpdates = $false;
|
||||||
|
Write-Host "Searching for updates…";
|
||||||
|
|
||||||
while (((Get-WindowsUpdate -IgnoreReboot).Count -gt 0)) {
|
while (((Get-WindowsUpdate -IgnoreReboot).Count -gt 0)) {
|
||||||
Write-Host "There are updates available.";
|
Write-Host "There are updates available.";
|
||||||
Write-Host "Installing updates";
|
Write-Host "Installing updates";
|
||||||
|
$hasUpdates = $true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot -ErrorAction "SilentlyContinue";
|
$null = Install-WindowsUpdate -AcceptAll -IgnoreReboot -ErrorAction "SilentlyContinue";
|
||||||
|
@ -20,14 +22,18 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (-not $hasUpdates) {
|
||||||
|
Write-Host "There are no updates available.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Start-UpdateLoop;
|
Start-UpdateLoop;
|
||||||
|
|
|
@ -1,16 +1,125 @@
|
||||||
using namespace System.Management.Automation.Host;
|
using namespace System.Management.Automation.Host;
|
||||||
|
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";
|
||||||
[string] $userOption = "SetupUser";
|
. "$PSScriptRoot/../../Common/Scripts/Operations.ps1";
|
||||||
|
$loggedInUserOption = "LoggedInUser";
|
||||||
|
|
||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Creates the configured users.
|
Installs all pending users to the system.
|
||||||
#>
|
#>
|
||||||
function Start-ValhallaUserSetup {
|
function Install-ValhallaUsers {
|
||||||
[int] $current = Get-SetupOption $userOption;
|
$users = @(Get-Users);
|
||||||
[string[]] $users = Get-Users;
|
$i = Get-CurrentUser;
|
||||||
|
|
||||||
|
for (; $i -lt $users.Count; $i++) {
|
||||||
|
Set-CurrentUser $i;
|
||||||
|
$name = $users[$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 -UserName "$name" "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
|
||||||
|
Creates a new user for the PortValhalla setup.
|
||||||
|
|
||||||
|
.PARAMETER Name
|
||||||
|
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 {
|
||||||
|
param(
|
||||||
|
[string] $Name,
|
||||||
|
[switch] $MSAccount
|
||||||
|
)
|
||||||
|
|
||||||
function Add-MicrosoftAccount {
|
function Add-MicrosoftAccount {
|
||||||
param(
|
param(
|
||||||
|
@ -27,7 +136,7 @@ $null = New-Module {
|
||||||
"Thus, you have to do it by yourself.",
|
"Thus, you have to do it by yourself.",
|
||||||
"So sorry…") -join "`n");
|
"So sorry…") -join "`n");
|
||||||
|
|
||||||
Write-Host "Create a user for ``$Name`` manually (because Windows is too stupid)…";
|
Write-Host "Create a user for ``$Name`` manually… (because Windows is too stupid)";
|
||||||
$null = Read-Host "Hit enter once you're done";
|
$null = Read-Host "Hit enter once you're done";
|
||||||
|
|
||||||
$newUsers = @(Get-LocalUser | Where-Object { -not ($currentUsers -contains $_.Name) });
|
$newUsers = @(Get-LocalUser | Where-Object { -not ($currentUsers -contains $_.Name) });
|
||||||
|
@ -55,10 +164,9 @@ $null = New-Module {
|
||||||
[ChoiceDescription[]](
|
[ChoiceDescription[]](
|
||||||
& {
|
& {
|
||||||
[ChoiceDescription]::new("&None", "None of these users is yours");
|
[ChoiceDescription]::new("&None", "None of these users is yours");
|
||||||
|
|
||||||
for ($i = 0; $i -lt $newUsers.Count; $i++) {
|
for ($i = 0; $i -lt $newUsers.Count; $i++) {
|
||||||
$name = "$($newUsers[$i])";
|
$name = "$($newUsers[$i])";
|
||||||
|
|
||||||
[ChoiceDescription]::new("&$($i + 1) - ``$name``", "Your user is ``$name``");
|
[ChoiceDescription]::new("&$($i + 1) - ``$name``", "Your user is ``$name``");
|
||||||
}
|
}
|
||||||
}), 0);
|
}), 0);
|
||||||
|
@ -75,31 +183,80 @@ $null = New-Module {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Write-Host "Renaming the new user to ``$Name``…";
|
Set-MSAccountName ([string]$newUser);
|
||||||
Rename-LocalUser $newUser $Name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ($i = $current ?? 0; $i -lt $users.Count; $i++) {
|
if ($MSAccount) {
|
||||||
Set-SetupOption $userOption $i;
|
if (Test-Admin) {
|
||||||
$name = $users[$i];
|
Write-Host "Preparing environment for creating MS Account";
|
||||||
Write-Host "Creating personal user ``$name``…";
|
Register-Setup -DefaultUser;
|
||||||
$displayName = Get-UserConfig -UserName $name "displayName";
|
Enable-OneShotListener;
|
||||||
|
Enable-UAC;
|
||||||
|
|
||||||
$userArguments = @{
|
# Reset Windows activation status
|
||||||
name = $name;
|
# Otherwise the login won't work - Windows is fricking frustrating.
|
||||||
};
|
slmgr /upk;
|
||||||
|
slmgr /cpky;
|
||||||
if ($displayName) {
|
slmgr /rearm;
|
||||||
$userArguments.fullName = $displayName;
|
Restart-Intermediate -CurrentUser;
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Get-UserConfig -UserName $name "microsoftAccount") {
|
Write-Host "Creating personal user ``$Name``…";
|
||||||
Add-MicrosoftAccount $name;
|
|
||||||
} else {
|
|
||||||
New-LocalUser -Disabled -NoPassword @userArguments;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set-LocalUser @userArguments;
|
if ($MSAccount) {
|
||||||
|
Add-MicrosoftAccount $Name;
|
||||||
|
Set-SetupOption $loggedInUserOption $env:UserName;
|
||||||
|
Invoke-OneShot ([OneShotTask]::InitializeMSAccount);
|
||||||
|
} else {
|
||||||
|
New-LocalUser -NoPassword @userArguments;
|
||||||
|
Initialize-UserCreation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Prepares the first login for initializing the current user under configuration.
|
||||||
|
#>
|
||||||
|
function Initialize-UserCreation {
|
||||||
|
$name = (@(Get-Users))[(Get-CurrentUser)];
|
||||||
|
$msAccount = Get-UserConfig -UserName $name "microsoftAccount";
|
||||||
|
|
||||||
|
Write-Host "Initializing user ``$name``…";
|
||||||
|
|
||||||
|
$userArguments = @{
|
||||||
|
name = $name;
|
||||||
|
};
|
||||||
|
|
||||||
|
$adminGroup = @{
|
||||||
|
SID = [SecurityIdentifier]::new([WellKnownSidType]::BuiltinAdministratorsSid, $null);
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($msAccount) {
|
||||||
|
$accountName = Get-MSAccountName;
|
||||||
|
Write-Host "Renaming ``$accountName`` to ``$name``…"
|
||||||
|
Rename-LocalUser $accountName $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set-LocalUser @userArguments;
|
||||||
|
|
||||||
|
if ($msAccount) {
|
||||||
|
Disable-LocalUser (Get-SetupOption $loggedInUserOption);
|
||||||
|
} else {
|
||||||
|
Disable-LocalUser $env:UserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
Add-LocalGroupMember `
|
||||||
|
@adminGroup `
|
||||||
|
$name `
|
||||||
|
-ErrorAction SilentlyContinue;
|
||||||
|
|
||||||
|
if ($msAccount) {
|
||||||
|
Disable-Autologin;
|
||||||
|
Set-BootMessage -Caption "Please Log In" -Message "Please log in using your new Microsoft Account ``$name``.";
|
||||||
|
} else {
|
||||||
|
Set-AutologinUser "$name";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
120
scripts/Windows/Scripts/WSL.ps1
Normal file
120
scripts/Windows/Scripts/WSL.ps1
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
. "$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;
|
||||||
|
$ubuntuPattern = "*Ubuntu*";
|
||||||
|
$registryPath = "HKCU:/Software/Microsoft/Windows/CurrentVersion/Lxss";
|
||||||
|
$key = Get-Item $registryPath;
|
||||||
|
|
||||||
|
if (Get-AppxPackage $ubuntuPattern) {
|
||||||
|
Install-Wsl;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 -Force (Get-AppxPackage $ubuntuPattern).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 -Force $wslDisk "ext4_.vhdx" -PassThru;
|
||||||
|
Uninstall-WslDistribution;
|
||||||
|
Move-Item $tempDisk $wslDisk;
|
||||||
|
}
|
12
scripts/Windows/Software/Ext4Fsd/Main.ps1
Normal file
12
scripts/Windows/Software/Ext4Fsd/Main.ps1
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
param (
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
|
-Installer {
|
||||||
|
Install-SetupPackage "https://github.com/bobranten/Ext4Fsd/releases/download/v0.71/Ext2Fsd-0.71-setup.exe";
|
||||||
|
};
|
|
@ -13,7 +13,6 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
)
|
)
|
||||||
|
|
||||||
Install-ChocoPackage firefox;
|
Install-ChocoPackage firefox;
|
||||||
& $Installer -Action ([InstallerAction]::Configure)
|
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
Write-Host "Making Firefox the default browser…";
|
Write-Host "Making Firefox the default browser…";
|
||||||
|
|
|
@ -3,13 +3,83 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
& {
|
||||||
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
param ($Parameters)
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
$configPath = "$env:LocalAppData/LGHUB";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
<#
|
||||||
-Installer {
|
.SYNOPSIS
|
||||||
Install-ChocoPackage lghub;
|
Stops the running Logitech G Hub instance.
|
||||||
Remove-DesktopIcon "*G HUB*";
|
#>
|
||||||
};
|
function Stop-LGHub {
|
||||||
|
[OutputType([string])]
|
||||||
|
param()
|
||||||
|
|
||||||
|
$hubName = "lghub_system_tray.exe";
|
||||||
|
|
||||||
|
$candidates = Get-Process | Where-Object { $_.Path -and ((Split-Path -Leaf $_.Path) -eq $hubName) };
|
||||||
|
|
||||||
|
if ($candidates.Count -gt 0) {
|
||||||
|
$lghubPath = $()[0].Path;
|
||||||
|
} else {
|
||||||
|
$lghubPath = $null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mainProcesses = Get-Process | Where-Object {
|
||||||
|
$_.Path -and
|
||||||
|
(@("lghub.exe", "lghub_agent.exe", "lghub_updater.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;
|
||||||
|
|
||||||
# ToDo: Add restoration
|
# ToDo: Add restoration
|
||||||
|
|
|
@ -12,7 +12,6 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
)
|
)
|
||||||
|
|
||||||
Install-ChocoPackage MSEdgeRedirect;
|
Install-ChocoPackage MSEdgeRedirect;
|
||||||
& $Installer -Action ([InstallerAction]::Configure);
|
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
$configPath = "HKLM:\SOFTWARE\Robert Maehl Software\MSEdgeRedirect";
|
$configPath = "HKLM:\SOFTWARE\Robert Maehl Software\MSEdgeRedirect";
|
||||||
|
|
|
@ -3,13 +3,44 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
& {
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
param($Parameters)
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
|
$path = "$HOME/Documents/ManiaPlanet";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @Parameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
Install-WingetPackage Nadeo.ManiaPlanet;
|
Install-WingetPackage Nadeo.ManiaPlanet;
|
||||||
Remove-DesktopIcon "ManiaPlanet*";
|
Remove-DesktopIcon "ManiaPlanet*";
|
||||||
};
|
} `
|
||||||
|
-UserBackup {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "ManiaPlanet" `
|
||||||
|
-Include @(
|
||||||
|
"Actions",
|
||||||
|
"Blocks",
|
||||||
|
"Items",
|
||||||
|
"Maps",
|
||||||
|
"Media",
|
||||||
|
"Modules",
|
||||||
|
"Packs",
|
||||||
|
"Replays",
|
||||||
|
"Scripts",
|
||||||
|
"Skins"
|
||||||
|
);
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
Expand-BackupArtifacts -User $Arguments.Name -Path "ManiaPlanet" -Target $path;
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
||||||
# ToDo: Add restoration
|
# ToDo: Add restoration
|
||||||
|
|
|
@ -22,7 +22,6 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
|
|
||||||
refreshenv;
|
refreshenv;
|
||||||
Set-UserPermissions $env:NVS_HOME;
|
Set-UserPermissions $env:NVS_HOME;
|
||||||
& $Installer -Action ([InstallerAction]::Configure);
|
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
nvs add latest;
|
nvs add latest;
|
||||||
|
|
125
scripts/Windows/Software/Nextcloud/Main.ps1
Normal file
125
scripts/Windows/Software/Nextcloud/Main.ps1
Normal file
|
@ -0,0 +1,125 @@
|
||||||
|
param(
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../Scripts/PowerManagement.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
|
||||||
|
& {
|
||||||
|
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 {
|
||||||
|
Install-ChocoPackage nextcloud-client -ArgumentList "-y","--params='/KeepUpdateCheck'";
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param($Arguments)
|
||||||
|
$user = $Arguments.Name;
|
||||||
|
|
||||||
|
& {
|
||||||
|
$syncs = Get-UserConfig -UserName $user "nextcloud.folderSyncs";
|
||||||
|
$configExists = { (Test-Path (Get-ConfigFile) ) };
|
||||||
|
|
||||||
|
if ($syncs.Count -gt 0) {
|
||||||
|
if (-not (& $configExists)) {
|
||||||
|
while (-not (& $configExists)) {
|
||||||
|
Read-Host "Please log in to the Nextcloud app and hit enter to continue";
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
|
@ -1,32 +0,0 @@
|
||||||
param(
|
|
||||||
$Action,
|
|
||||||
[hashtable] $Arguments
|
|
||||||
)
|
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
|
||||||
-Installer {
|
|
||||||
Install-ChocoPackage nextcloud-client -ArgumentList "-y","--params='/KeepUpdateCheck'";
|
|
||||||
} `
|
|
||||||
-UserConfigurator {
|
|
||||||
if (-not (Test-Path $context.GetNextcloudConfigFile())) {
|
|
||||||
Write-Information "Setting up Nextcloud configuration";
|
|
||||||
|
|
||||||
Write-Information "Ensuring all Let's Encrypt certificates are cached";
|
|
||||||
$null = Invoke-WebRequest https://valid-isrgrootx1.letsencrypt.org/;
|
|
||||||
|
|
||||||
while (-not (Test-Path $context.GetNextcloudConfigFile())) {
|
|
||||||
Write-Host "Nextcloud has been installed!";
|
|
||||||
Read-Host "Please log in in 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.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$context.Reboot();
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
@ -6,16 +6,18 @@ param (
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
& {
|
||||||
-Installer {
|
param($Parameters)
|
||||||
param(
|
$base = "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1";
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
Install-WingetPackage JanDeDobbeleer.OhMyPosh -ArgumentList "--scope","machine";
|
Start-SoftwareInstaller @Parameters `
|
||||||
& $Installer -Action ([InstallerAction]::Configure);
|
-Installer {
|
||||||
} `
|
Install-WingetPackage JanDeDobbeleer.OhMyPosh -ArgumentList "--scope","machine";
|
||||||
-Configurator {
|
} `
|
||||||
. "$PSScriptRoot/../../../Common/Software/Oh My Posh/Manage.ps1" `
|
-Configurator {
|
||||||
-Action ([InstallerAction]::Configure);
|
. $base -Action ([InstallerAction]::Configure);
|
||||||
};
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
. $base -Action ([InstallerAction]::ConfigureUser);
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
|
@ -8,13 +8,6 @@ param(
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
& $Installer -Action ([InstallerAction]::Configure)
|
|
||||||
} `
|
|
||||||
-Configurator {
|
-Configurator {
|
||||||
Set-Service ssh-agent -StartupType AutomaticDelayedStart;
|
Set-Service ssh-agent -StartupType AutomaticDelayedStart;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ param (
|
||||||
. "$PSScriptRoot/../../../Common/Software/PowerShell/Module.ps1";
|
. "$PSScriptRoot/../../../Common/Software/PowerShell/Module.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
|
||||||
$parameters = Get-ModuleInstallerComponents "PinnedItem" -NativeOnly;
|
$parameters = Get-ModuleInstallerComponents "PinnedItem" -NativeOnly -NoProfile;
|
||||||
|
|
||||||
foreach ($key in $PSBoundParameters.Keys) {
|
foreach ($key in $PSBoundParameters.Keys) {
|
||||||
$parameters.Add($key, $PSBoundParameters.TryGetValue($key));
|
$parameters.Add($key, $PSBoundParameters.TryGetValue($key));
|
||||||
|
@ -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 -NoProfile -Command "Import-Module $module; exit ([bool]`$Error)" 2> $null; $?; })) {
|
||||||
|
$feature = "NetFx3";
|
||||||
|
|
||||||
|
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
|
||||||
|
Write-Host "Enabling ``$feature`` feature…";
|
||||||
|
choco install --source windowsFeatures -y $feature;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,6 @@ param (
|
||||||
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
& $Installer -Action ([InstallerAction]::Configure);
|
|
||||||
} `
|
|
||||||
-Configurator {
|
-Configurator {
|
||||||
. "$PSScriptRoot/../../../Common/Software/PowerShell/Manage.ps1" `
|
. "$PSScriptRoot/../../../Common/Software/PowerShell/Manage.ps1" `
|
||||||
-Action ([InstallerAction]::Configure);
|
-Action ([InstallerAction]::Configure);
|
||||||
|
|
|
@ -6,10 +6,28 @@ param(
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
. "$PSScriptRoot/../../Scripts/AppAssociations.ps1";
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
. "$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 putty;
|
Install-ChocoPackage putty;
|
||||||
|
} `
|
||||||
|
-UserBackup {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
|
$dir = New-TemporaryDirectory;
|
||||||
|
$fileName = Join-Path "$dir" PuTTY.reg;
|
||||||
|
& reg export "HKCU\Software\SimonTatham\PuTTY" $fileName /y;
|
||||||
|
Add-BackupArtifacts -User $Arguments.Name -Source $fileName -Path "PuTTY/PuTTY.reg";
|
||||||
|
Remove-Item -Recurse -Force $dir;
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
|
$dir = New-TemporaryDirectory;
|
||||||
|
$fileName = Join-Path "$dir" PuTTY.reg;
|
||||||
|
Expand-BackupArtifacts -User $Arguments.Name -Path "PuTTY/PuTTY.reg" -Target $fileName;
|
||||||
|
& reg import $fileName;
|
||||||
|
Remove-Item -Recurse -Force $dir;
|
||||||
};
|
};
|
||||||
# ToDo: Add restoration
|
# ToDo: Add restoration
|
||||||
|
|
|
@ -3,13 +3,34 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
$null = New-Module {
|
||||||
-Installer {
|
param($Parameters)
|
||||||
Install-ChocoPackage retroarch;
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
# ToDo: Add start menu shortcut
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
# ToDo: Add function for this purpose
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
};
|
$path = "C:/tools/RetroArch-Win64";
|
||||||
|
|
||||||
# ToDo: Add restoration
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Backup {
|
||||||
|
Add-BackupArtifacts -Path "RetroArch" -Source $path `
|
||||||
|
-Include @(
|
||||||
|
"config",
|
||||||
|
"cores",
|
||||||
|
"downloads",
|
||||||
|
"playlists",
|
||||||
|
"recordings",
|
||||||
|
"screenshots",
|
||||||
|
"content_history.lpl",
|
||||||
|
"content_*_history.lpl",
|
||||||
|
"retroarch.cfg"
|
||||||
|
);
|
||||||
|
} `
|
||||||
|
-Installer {
|
||||||
|
Install-ChocoPackage retroarch;
|
||||||
|
} `
|
||||||
|
-Configurator {
|
||||||
|
Add-StartMenuIcon "RetroArch" "C:\tools\RetroArch-Win64\retroarch.exe";
|
||||||
|
Expand-BackupArtifacts -Path "RetroArch" -Target $path;
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
|
@ -15,7 +15,6 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
)
|
)
|
||||||
|
|
||||||
Install-ChocoPackage thunderbird -ArgumentList "--params",'"/NoTaskbarShortcut /NoDesktopShortcut"'
|
Install-ChocoPackage thunderbird -ArgumentList "--params",'"/NoTaskbarShortcut /NoDesktopShortcut"'
|
||||||
& $Installer -Action ([InstallerAction]::Configure)
|
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
Write-Host "Making Thunderbird the default mail program…";
|
Write-Host "Making Thunderbird the default mail program…";
|
||||||
|
|
|
@ -3,19 +3,42 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
& {
|
||||||
-Installer {
|
param($Parameters)
|
||||||
foreach ($feature in @("DirectPlay", "NetFx3")) {
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
Write-Information "Enabling the ``$feature`` feature…";
|
$path = "$HOME/Documents/TmForever";
|
||||||
choco install --source windowsFeatures -y $feature;
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Installer {
|
||||||
|
foreach ($feature in @("DirectPlay", "NetFx3")) {
|
||||||
|
if ((Get-WindowsOptionalFeature -Online -FeatureName $feature).State -ne "Enabled") {
|
||||||
|
Write-Information "Enabling the ``$feature`` feature…";
|
||||||
|
choco install --source windowsFeatures -y $feature;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Install-WingetPackage Nadeo.TrackManiaNationsForever;
|
Install-WingetPackage Nadeo.TrackManiaNationsForever;
|
||||||
Remove-DesktopIcon "*TmNationsForever*";
|
Remove-DesktopIcon "*TmNationsForever*";
|
||||||
}
|
} `
|
||||||
};
|
-UserBackup {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
# ToDo: Add restoration
|
$name = $Arguments.Name;
|
||||||
|
Add-BackupArtifacts -User $name -Source $path -Path "TmNationsForever" `
|
||||||
|
-Include @(
|
||||||
|
"ChallengeMusics",
|
||||||
|
"MediaTracker",
|
||||||
|
"MenuMusics",
|
||||||
|
"Painter",
|
||||||
|
"Scores",
|
||||||
|
"Skins",
|
||||||
|
"Tracks"
|
||||||
|
);
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
|
$name = $Arguments.Name;
|
||||||
|
Expand-BackupArtifacts -User $name -Path "TmNationsForever" -Target $path;
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
|
@ -3,10 +3,15 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
& {
|
||||||
|
param($Parameters)
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
|
$path = "$HOME/Documents/TrackMania";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
$file = "TmUnitedForever.exe";
|
$file = "TmUnitedForever.exe";
|
||||||
$dir = New-TemporaryDirectory;
|
$dir = New-TemporaryDirectory;
|
||||||
|
@ -28,6 +33,21 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
$null = Pop-Location;
|
$null = Pop-Location;
|
||||||
|
|
||||||
Remove-Item -Recurse $dir;
|
Remove-Item -Recurse $dir;
|
||||||
|
} `
|
||||||
|
-UserBackup {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
|
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "TmUnitedForever" `
|
||||||
|
-Include @(
|
||||||
|
"ChallengeMusics",
|
||||||
|
"MediaTracker",
|
||||||
|
"MenuMusics",
|
||||||
|
"Scores",
|
||||||
|
"Skins",
|
||||||
|
"Tracks"
|
||||||
|
);
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
|
Expand-BackupArtifacts -User $Arguments.Name -Path "TmUnitedForever" -Target $path;
|
||||||
};
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
# ToDo: Add restoration
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ param(
|
||||||
& {
|
& {
|
||||||
param($parameters)
|
param($parameters)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/SoftwareManagement.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/BrowserAutomation.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/BrowserAutomation.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
|
@ -16,19 +18,65 @@ param(
|
||||||
[System.Tuple]::Create("visualstudio2022enterprise", "VisualStudio.17.Release", "Microsoft.VisualStudio.Product.Enterprise"),
|
[System.Tuple]::Create("visualstudio2022enterprise", "VisualStudio.17.Release", "Microsoft.VisualStudio.Product.Enterprise"),
|
||||||
[System.Tuple]::Create("visualstudio2022community", "VisualStudio.17.Release", "Microsoft.VisualStudio.Product.Community")
|
[System.Tuple]::Create("visualstudio2022community", "VisualStudio.17.Release", "Microsoft.VisualStudio.Product.Community")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the path to the Visual Studio Installer.
|
||||||
|
#>
|
||||||
|
function Get-InstallerPath {
|
||||||
|
return "$((Get-KnownFolder ProgramFilesX86).Path)/Microsoft Visual Studio/Installer/vs_installer.exe";
|
||||||
|
}
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the path to the configuration file in the backup archive.
|
||||||
|
|
||||||
|
.PARAMETER PackageName
|
||||||
|
The name of the package to get the configuration for.
|
||||||
|
#>
|
||||||
|
function Get-ConfigPath {
|
||||||
|
param(
|
||||||
|
[string] $PackageName
|
||||||
|
)
|
||||||
|
|
||||||
|
return Join-Path "Visual Studio" "$PackageName.vsconfig";
|
||||||
|
}
|
||||||
|
|
||||||
Start-SoftwareInstaller @parameters `
|
Start-SoftwareInstaller @parameters `
|
||||||
|
-Backup {
|
||||||
|
foreach ($version in $versions) {
|
||||||
|
if (Test-ChocoPackage $version[0]) {
|
||||||
|
Write-Host "Backing up ``$($version[0])…";
|
||||||
|
$configFile = New-TemporaryFile;
|
||||||
|
|
||||||
|
Start-Process -FilePath (Get-InstallerPath) -Wait `
|
||||||
|
-ArgumentList @(
|
||||||
|
"export",
|
||||||
|
"--channelId", $version[1],
|
||||||
|
"--productId", $version[2],
|
||||||
|
"--config", $configFile,
|
||||||
|
"--quiet"
|
||||||
|
);
|
||||||
|
|
||||||
|
Add-BackupArtifacts -Source $configFile -Path (Get-ConfigPath $version[0]);
|
||||||
|
Remove-Item $configFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} `
|
||||||
-Installer {
|
-Installer {
|
||||||
foreach ($version in $versions) {
|
foreach ($version in $versions) {
|
||||||
$packageName = $version[0];
|
$packageName = $version[0];
|
||||||
Write-Host "Installing ``$packageName``…";
|
$file = New-TemporaryFile;
|
||||||
Install-ChocoPackage $packageName;
|
Remove-Item $file;
|
||||||
|
Expand-BackupArtifacts -Path (Get-ConfigPath $packageName) -Target $file;
|
||||||
|
|
||||||
|
if (Test-Path $file) {
|
||||||
|
Write-Host "Restoring ``$packageName``…";
|
||||||
|
Install-ChocoPackage $packageName -ArgumentList "--params","--config `"$file`"";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Remove-DesktopIcon "CocosCreator*";
|
Remove-DesktopIcon "CocosCreator*";
|
||||||
Remove-DesktopIcon "Unity Hub*";
|
Remove-DesktopIcon "Unity Hub*";
|
||||||
};
|
};
|
||||||
|
|
||||||
# ToDo: Add restoration
|
|
||||||
# Only restore version if it has been backed up
|
|
||||||
} $PSBoundParameters;
|
} $PSBoundParameters;
|
||||||
|
|
|
@ -11,12 +11,7 @@ param(
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
-Installer {
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
Install-ChocoPackage winscp;
|
Install-ChocoPackage winscp;
|
||||||
& $Installer -Action ([InstallerAction]::Configure)
|
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
Remove-DesktopIcon "WinSCP*";
|
Remove-DesktopIcon "WinSCP*";
|
||||||
|
|
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,19 +5,40 @@ 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 {
|
||||||
-Installer {
|
param($Parameters)
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
& $Installer -Action ([InstallerAction]::Configure)
|
. "$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;
|
||||||
|
@ -61,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";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -143,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;
|
||||||
|
|
23
scripts/Windows/Software/aliae/Main.ps1
Normal file
23
scripts/Windows/Software/aliae/Main.ps1
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
param (
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
|
||||||
|
& {
|
||||||
|
param($Parameters)
|
||||||
|
$base = "$PSScriptRoot/../../../Common/Software/aliae/Manage.ps1";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Installer {
|
||||||
|
Install-WingetPackage JanDeDobbeleer.Aliae;
|
||||||
|
} `
|
||||||
|
-Configurator {
|
||||||
|
. $base -Action ([InstallerAction]::Configure);
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
. $base -Action ([InstallerAction]::ConfigureUser);
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
|
@ -8,13 +8,6 @@ param(
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @PSBoundParameters `
|
||||||
-Installer {
|
|
||||||
param(
|
|
||||||
[scriptblock] $Installer
|
|
||||||
)
|
|
||||||
|
|
||||||
& $Installer -Action ([InstallerAction]::Configure)
|
|
||||||
} `
|
|
||||||
-Configurator {
|
-Configurator {
|
||||||
[string] $backup = $null;
|
[string] $backup = $null;
|
||||||
$nativeProfile = powershell -c '$PROFILE';
|
$nativeProfile = powershell -c '$PROFILE';
|
||||||
|
|
39
scripts/Windows/Software/git/Manage.ps1
Normal file
39
scripts/Windows/Software/git/Manage.ps1
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
param (
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Config.ps1";
|
||||||
|
|
||||||
|
& {
|
||||||
|
param(
|
||||||
|
[hashtable] $Parameters
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
$base = "$PSScriptRoot/../../../Common/Software/git/Manage.ps1";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Installer {
|
||||||
|
$params = "/WindowsTerminalProfile";
|
||||||
|
$defaultBranch = Get-Config "valhalla.git.defaultBranch";
|
||||||
|
|
||||||
|
if ($defaultBranch) {
|
||||||
|
$params += " /DefaultBranchName:`"$defaultBranch`"";
|
||||||
|
}
|
||||||
|
|
||||||
|
Install-ChocoPackage git -ArgumentList "--params",$params;
|
||||||
|
} `
|
||||||
|
-Configurator {
|
||||||
|
& $base ([InstallerAction]::Configure);
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
$Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
& $base ([InstallerAction]::ConfigureUser) @PSBoundParameterrs;
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
|
@ -5,10 +5,45 @@ param(
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
$null = New-Module {
|
||||||
-Installer {
|
param($Parameters)
|
||||||
Install-ChocoPackage osu;
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
Remove-DesktopIcon "*osu*";
|
Export-ModuleMember -Function @();
|
||||||
};
|
|
||||||
|
|
||||||
# ToDo: Add restoration
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Gets the path to the installation directory of osu!.
|
||||||
|
#>
|
||||||
|
function Get-InstallPath {
|
||||||
|
return "$((Get-KnownFolder -SpecialFolder ProgramFilesX86).Path)/osu!";
|
||||||
|
}
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Installer {
|
||||||
|
Install-ChocoPackage osu;
|
||||||
|
Remove-DesktopIcon "*osu*";
|
||||||
|
} `
|
||||||
|
-Backup {
|
||||||
|
Add-BackupArtifacts -Source (Get-InstallPath) -Path "osu!" `
|
||||||
|
-Include @(
|
||||||
|
"Screenshots",
|
||||||
|
"Skins",
|
||||||
|
"Songs",
|
||||||
|
"osu!.cfg",
|
||||||
|
"scores.db"
|
||||||
|
);
|
||||||
|
} `
|
||||||
|
-Configurator {
|
||||||
|
Expand-BackupArtifacts -Path "osu!" -Target (Get-InstallPath);
|
||||||
|
} `
|
||||||
|
-UserBackup {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
|
$name = $Arguments.Name;
|
||||||
|
Add-BackupArtifacts -Source "$(Get-InstallPath)/osu!.$name.cfg" -User $name -Path "osu!/osu!.cfg";
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param([hashtable] $Arguments)
|
||||||
|
$name = $Arguments.Name;
|
||||||
|
Expand-BackupArtifacts -User $name -Path "osu!/osu!.cfg" -Target "$(Get-InstallPath)/osu!.$name.cfg";
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
|
@ -3,29 +3,30 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
& {
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
param($Parameters)
|
||||||
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
|
$path = "$env:AppData/osu";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
Start-SoftwareInstaller @Parameters `
|
||||||
-Installer {
|
-UserBackup {
|
||||||
$file = "osu!lazer.exe";
|
param([hashtable] $Arguments)
|
||||||
$processName = "osu!";
|
Add-BackupArtifacts -User $Arguments.Name -Source $path -Path "osu!lazer" `
|
||||||
$dir = New-TemporaryDirectory;
|
-Include @(
|
||||||
|
"files",
|
||||||
Push-Location $dir;
|
"rulesets",
|
||||||
Invoke-WebRequest "https://github.com/ppy/osu/releases/latest/download/install.exe" -OutFile $file;
|
"screenshots",
|
||||||
Start-Process -FilePath $file;
|
"framework.ini",
|
||||||
|
"game.ini",
|
||||||
while (-not (Get-Process -ErrorAction SilentlyContinue $processName)) {
|
"input.json"
|
||||||
Start-Sleep 1;
|
);
|
||||||
}
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
Start-Sleep 10;
|
param([hashtable] $Arguments)
|
||||||
Get-Process $processName | Stop-Process -Force;
|
Install-WingetPackage "ppy.osu" -ArgumentList "--scope","user";
|
||||||
Pop-Location;
|
Remove-DesktopIcon "*osu*";
|
||||||
Remove-Item -Recurse $dir;
|
Expand-BackupArtifacts -User $Arguments.Name -Path "osu!lazer" -Target $path;
|
||||||
|
};
|
||||||
Remove-DesktopIcon "*osu*";
|
} $PSBoundParameters;
|
||||||
};
|
|
||||||
|
|
||||||
# ToDo: Add restoration
|
|
||||||
|
|
|
@ -3,20 +3,42 @@ param(
|
||||||
[hashtable] $Arguments
|
[hashtable] $Arguments
|
||||||
)
|
)
|
||||||
|
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/BrowserAutomation.ps1";
|
& {
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
param($Parameters)
|
||||||
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
. "$PSScriptRoot/../../Scripts/Restoration.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/BrowserAutomation.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";
|
||||||
|
|
||||||
Start-SoftwareInstaller @PSBoundParameters `
|
$path = "$env:Public/Documents/reWASD";
|
||||||
-Installer {
|
|
||||||
Write-Host "Downloading reWASD…";
|
|
||||||
$dir = New-TemporaryDirectory;
|
|
||||||
$file = Start-BrowserDownload -URL "https://rewasd.com/" -ButtonSelector 'a.btn-default[href="#"]' -OutDir $dir;
|
|
||||||
|
|
||||||
Write-Host "Installing reWASD…";
|
Start-SoftwareInstaller @Parameters `
|
||||||
Start-Process -Wait -FilePath $($file.FullName) -ArgumentList "/S";
|
-Backup {
|
||||||
Remove-Item -Recurse $dir;
|
Add-BackupArtifacts -Path "reWASD" -Source $path `
|
||||||
Remove-DesktopIcon "*reWASD*";
|
-Exclude @(
|
||||||
};
|
"Logs",
|
||||||
|
"Presets",
|
||||||
|
"Profiles/Destop",
|
||||||
|
"Profiles/Duality",
|
||||||
|
"Profiles/Fortnite",
|
||||||
|
"Profiles/PS4 Remote*",
|
||||||
|
"Profiles/Switch console",
|
||||||
|
"Profiles/Switch to Xbox 360",
|
||||||
|
"Profiles/Valorant",
|
||||||
|
"Profiles/xCloud"
|
||||||
|
);
|
||||||
|
} `
|
||||||
|
-Installer {
|
||||||
|
Write-Host "Downloading reWASD…";
|
||||||
|
$dir = New-TemporaryDirectory;
|
||||||
|
$file = Start-BrowserDownload -URL "https://rewasd.com/" -ButtonSelector 'a.btn-default[href="#"]' -OutDir $dir -Timeout 1;
|
||||||
|
|
||||||
# ToDo: Add restoration
|
Write-Host "Installing reWASD…";
|
||||||
|
Start-Process -Wait -FilePath $($file.FullName) -ArgumentList "/S";
|
||||||
|
Remove-Item -Recurse $dir;
|
||||||
|
Remove-DesktopIcon "*reWASD*";
|
||||||
|
} `
|
||||||
|
-Configurator {
|
||||||
|
Expand-BackupArtifacts -Path "reWASD" -Target $path;
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
||||||
|
|
28
scripts/Windows/Software/vscode/Main.ps1
Normal file
28
scripts/Windows/Software/vscode/Main.ps1
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
param(
|
||||||
|
$Action,
|
||||||
|
[hashtable] $Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
& {
|
||||||
|
param (
|
||||||
|
[hashtable] $Parameters
|
||||||
|
)
|
||||||
|
|
||||||
|
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
|
||||||
|
. "$PSScriptRoot/../../../Common/Types/InstallerAction.ps1";
|
||||||
|
$base = "$PSScriptRoot/../../../Common/Software/vscode/Main.ps1";
|
||||||
|
|
||||||
|
Start-SoftwareInstaller @Parameters `
|
||||||
|
-Installer {
|
||||||
|
Install-ChocoPackage vscode -ArgumentList "--params","/NoDesktopIcon";
|
||||||
|
Install-ChocoPackage vscodium -ArgumentList "--params","/NoDesktopIcon /AssociateWithFiles";
|
||||||
|
refreshenv;
|
||||||
|
} `
|
||||||
|
-UserConfigurator {
|
||||||
|
param(
|
||||||
|
$Arguments
|
||||||
|
)
|
||||||
|
|
||||||
|
& $base ([InstallerAction]::ConfigureUser) @PSBoundParameters;
|
||||||
|
};
|
||||||
|
} $PSBoundParameters;
|
|
@ -14,7 +14,6 @@ Start-SoftwareInstaller @PSBoundParameters `
|
||||||
|
|
||||||
Install-ChocoPackage zoxide;
|
Install-ChocoPackage zoxide;
|
||||||
Install-WingetPackage junegunn.fzf;
|
Install-WingetPackage junegunn.fzf;
|
||||||
& $Installer -Action ([InstallerAction]::Configure);
|
|
||||||
} `
|
} `
|
||||||
-Configurator {
|
-Configurator {
|
||||||
Add-PowerShellProfileStatement `
|
Add-PowerShellProfileStatement `
|
||||||
|
|
4
scripts/Windows/Types/WindowsInstallerAction.ps1
Normal file
4
scripts/Windows/Types/WindowsInstallerAction.ps1
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
enum WindowsInstallerAction {
|
||||||
|
Backup
|
||||||
|
Install
|
||||||
|
}
|
|
@ -1,11 +1,19 @@
|
||||||
#!/bin/env fish
|
#!/bin/env fish
|
||||||
begin
|
begin
|
||||||
|
set -l varName WIN11_IMAGE_PATH
|
||||||
|
set -l $varName
|
||||||
set -l dir (status dirname)
|
set -l dir (status dirname)
|
||||||
source "$dir/lib/choose-disk.fish"
|
source "$dir/lib/choose-disk.fish"
|
||||||
|
set $varName (bash -c ". $(string escape $dir)/.env; echo \$$varName" 2> /dev/null)
|
||||||
|
|
||||||
set -q WIN11_IMAGE_PATH
|
[ ! -z "$$varName" ]
|
||||||
or begin
|
or begin
|
||||||
echo "Please specify the Windows 11 ISO in the `WIN11_IMAGE_PATH` variable."
|
if [ ! -f "$dir/.env" ]
|
||||||
|
cp $dir/.env.template $dir/.env
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "Please epecify the path to the Windows 11 ISO image in your .env file located at:"
|
||||||
|
realpath --relative-to (pwd) (realpath $dir/.env)
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,6 +21,10 @@ begin
|
||||||
sed "s/\//\\\\/g"
|
sed "s/\//\\\\/g"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
argparse --name (status filename) -x "iso,usb" "iso" "usb" "debug" -- $argv
|
||||||
|
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"
|
||||||
|
@ -20,9 +32,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)
|
||||||
|
@ -131,6 +143,13 @@ begin
|
||||||
"$git[5]\\bin"
|
"$git[5]\\bin"
|
||||||
) \
|
) \
|
||||||
"set SETUP_LABEL=$setupLabel" \
|
"set SETUP_LABEL=$setupLabel" \
|
||||||
|
(
|
||||||
|
begin
|
||||||
|
if [ -n "$_flag_debug" ]
|
||||||
|
echo "set DEBUG=1"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
) \
|
||||||
"set PWSH_PATH=$(echo "$pwshPath" | mkWinPath)" \
|
"set PWSH_PATH=$(echo "$pwshPath" | mkWinPath)" \
|
||||||
"set LOCAL_PROJECT_PATH=$(echo "$localProjectPath" | mkWinPath)" \
|
"set LOCAL_PROJECT_PATH=$(echo "$localProjectPath" | mkWinPath)" \
|
||||||
"set REMOTE_PROJECT_PATH=$(echo "$projectPath" | mkWinPath)" \
|
"set REMOTE_PROJECT_PATH=$(echo "$projectPath" | mkWinPath)" \
|
||||||
|
@ -147,7 +166,7 @@ begin
|
||||||
end
|
end
|
||||||
|
|
||||||
mkdir -p "$(dirname "$winpe")"
|
mkdir -p "$(dirname "$winpe")"
|
||||||
sudo mount --mkdir "$WIN11_IMAGE_PATH" "$winPath"
|
sudo mount --mkdir $$varName "$winPath"
|
||||||
mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$winpe"
|
mkwinpeimg --iso --arch amd64 --overlay "$winpeOverlay" --windows-dir "$winPath" "$winpe"
|
||||||
sudo mount --mkdir "$winpe" "$winpePath"
|
sudo mount --mkdir "$winpe" "$winpePath"
|
||||||
|
|
||||||
|
@ -192,7 +211,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
|
||||||
|
|
||||||
|
@ -218,8 +237,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" \
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
WIN_DISK="${WIN_DISK}";
|
|
||||||
workingDir="$(pwd)";
|
|
||||||
pushd "${BASH_SOURCE%/*}" > /dev/null;
|
|
||||||
. "./.env" > /dev/null 2>&1;
|
|
||||||
|
|
||||||
if [ ! -z "$WIN11_IMAGE_PATH" ]
|
|
||||||
then
|
|
||||||
WIN11_IMAGE_PATH="$(bash -c "realpath $WIN11_IMAGE_PATH")";
|
|
||||||
fi;
|
|
||||||
|
|
||||||
if [ ! -f "$WIN11_IMAGE_PATH" ]
|
|
||||||
then
|
|
||||||
if [ ! -f "./.env" ]
|
|
||||||
then
|
|
||||||
cp .env.template .env;
|
|
||||||
fi;
|
|
||||||
|
|
||||||
echo "Please specify the path to the Windows 11 ISO image in your .env file located at:";
|
|
||||||
realpath --relative-to "$workingDir" "$(realpath .env)";
|
|
||||||
else
|
|
||||||
WIN11_IMAGE_PATH="$WIN11_IMAGE_PATH" fish ./deploy.fish;
|
|
||||||
fi;
|
|
||||||
|
|
||||||
popd > /dev/null;
|
|
Loading…
Reference in a new issue