Skip to content

Commit a7d8b40

Browse files
authored
Merge branch 'main' into create-pull-request/patch
2 parents 4d078cb + 5b6a175 commit a7d8b40

7 files changed

+43
-20
lines changed

docs/requirements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ custom installer via the --kexec flag which connects to your VPN.
3636
[different kexec image](./howtos/INDEX.md#using-your-own-kexec-image)
3737
manually.
3838
- **Memory Requirements:**
39-
- At least 1 GB of RAM (excluding swap space).
39+
- At least 1.5 GB of RAM (excluding swap space).

src/nixos-anywhere.sh

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -619,32 +619,55 @@ runKexec() {
619619
fi
620620
621621
step Switching system into kexec
622-
runSsh sh <<SSH
623-
set -efu ${enableDebug}
624-
$maybeSudo rm -rf /root/kexec
625-
$maybeSudo mkdir -p /root/kexec
626-
SSH
627622
628623
# no way to reach global ipv4 destinations, use gh-v6.com automatically if github url
629624
if [[ ${hasIpv6Only} == "y" ]] && [[ $kexecUrl == "https://github.com/"* ]]; then
630625
kexecUrl=${kexecUrl/"github.com"/"gh-v6.com"}
631626
fi
632627
628+
# Define common remote commands template
629+
local remoteCommandTemplate="
630+
set -eu ${enableDebug}
631+
${maybeSudo} rm -rf /root/kexec
632+
${maybeSudo} mkdir -p /root/kexec
633+
%TAR_COMMAND%
634+
TMPDIR=/root/kexec setsid sudo /root/kexec/kexec/run --kexec-extra-flags \"$kexecExtraFlags\"
635+
"
636+
637+
# Define upload commands
638+
local localUploadCommand=()
639+
local remoteUploadCommand=()
640+
633641
if [[ -f $kexecUrl ]]; then
634-
runSsh "${maybeSudo} tar -C /root/kexec -xvzf-" <"$kexecUrl"
635-
elif [[ ${hasCurl} == "y" ]]; then
636-
runSsh "curl --fail -Ss -L '${kexecUrl}' | ${maybeSudo} tar -C /root/kexec -xvzf-"
637-
elif [[ ${hasWget} == "y" ]]; then
638-
runSsh "wget '${kexecUrl}' -O- | ${maybeSudo} tar -C /root/kexec -xvzf-"
642+
localUploadCommand=(cat "$kexecUrl")
643+
elif [[ $hasWget == "y" ]]; then
644+
remoteUploadCommand=(wget "$kexecUrl" -O-)
645+
elif [[ $hasCurl == "y" ]]; then
646+
remoteUploadCommand=(curl --fail -Ss -L "$kexecUrl")
639647
else
640-
curl --fail -Ss -L "${kexecUrl}" | runSsh "${maybeSudo} tar -C /root/kexec -xvzf-"
648+
# Fallback to local curl
649+
localUploadCommand=(curl --fail -Ss -L "${kexecUrl}")
641650
fi
642651
643-
runSsh <<SSH
644-
TMPDIR=/root/kexec setsid ${maybeSudo} /root/kexec/kexec/run --kexec-extra-flags "${kexecExtraFlags}"
645-
SSH
652+
local tarCommand
653+
local remoteCommands
654+
if [[ ${#localUploadCommand[@]} -eq 0 ]]; then
655+
# Use remote command for download and execution
656+
tarCommand="$(printf '%q ' "${remoteUploadCommand[@]}") | ${maybeSudo} tar -C /root/kexec -xvzf-"
657+
658+
remoteCommands=${remoteCommandTemplate//'%TAR_COMMAND%'/$tarCommand}
659+
660+
runSsh sh -c "$remoteCommands"
661+
else
662+
# Use local command with pipe to remote
663+
tarCommand="${maybeSudo} tar -C /root/kexec -xvzf-"
664+
remoteCommands=${remoteCommandTemplate//'%TAR_COMMAND%'/$tarCommand}
665+
666+
"${localUploadCommand[@]}" | runSsh sh -c "$remoteCommands"
667+
fi
646668
647669
# use the default SSH port to connect at this point
670+
local i
648671
for i in "${!sshArgs[@]}"; do
649672
if [[ ${sshArgs[i]} == "-p" ]]; then
650673
sshArgs[i + 1]=$postKexecSshPort

tests/from-nixos-build-on-remote.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
installer = ./modules/installer.nix;
77
installed = {
88
services.openssh.enable = true;
9-
virtualisation.memorySize = 1024;
9+
virtualisation.memorySize = 1500;
1010

1111
users.users.root.openssh.authorizedKeys.keyFiles = [ ./modules/ssh-keys/ssh.pub ];
1212
};

tests/from-nixos-generate-config.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
};
1010
installed = {
1111
services.openssh.enable = true;
12-
virtualisation.memorySize = 1024;
12+
virtualisation.memorySize = 1500;
1313

1414
users.users.root.openssh.authorizedKeys.keyFiles = [ ./modules/ssh-keys/ssh.pub ];
1515
};

tests/from-nixos-separated-phases.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
installer = ./modules/installer.nix;
55
installed = {
66
services.openssh.enable = true;
7-
virtualisation.memorySize = 1024;
7+
virtualisation.memorySize = 1500;
88

99
users.users.nixos = {
1010
isNormalUser = true;

tests/from-nixos-with-sudo.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
installer = ./modules/installer.nix;
55
installed = {
66
services.openssh.enable = true;
7-
virtualisation.memorySize = 1024;
7+
virtualisation.memorySize = 1500;
88

99
users.users.nixos = {
1010
isNormalUser = true;

tests/from-nixos.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
installer = ./modules/installer.nix;
77
installed = {
88
services.openssh.enable = true;
9-
virtualisation.memorySize = 1024;
9+
virtualisation.memorySize = 1500;
1010

1111
users.users.root.openssh.authorizedKeys.keyFiles = [ ./modules/ssh-keys/ssh.pub ];
1212
};

0 commit comments

Comments
 (0)