Skip to content

Commit 5748958

Browse files
committed
also put kexec tarball into $HOME/kexec
1 parent efe280b commit 5748958

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/nixos-anywhere.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ runKexec() {
726726
local logContent=""
727727
if logContent=$(
728728
set +x
729+
# shellcheck disable=SC2016 # We want $HOME to expand on the remote server
729730
runSsh 'cat "$HOME/kexec/nixos-anywhere.log" 2>/dev/null' 2>/dev/null
730731
); then
731732
echo "Remote output log:" >&2
@@ -741,8 +742,6 @@ runKexec() {
741742
# Run kexec commands with sudo if needed
742743
{
743744
set -eu ${enableDebug}
744-
${maybeSudo} rm -rf \"\$HOME/kexec\"
745-
mkdir -p \"\$HOME/kexec\"
746745
cd \"\$HOME/kexec\"
747746
echo Downloading kexec tarball, this may take a moment...
748747
# Execute tar command
@@ -790,19 +789,24 @@ fi
790789
# Use remote command for download
791790
tarCommand="$(printf '%q ' "${remoteUploadCommand[@]}") | tar -xv ${tarDecomp}"
792791
else
793-
# Upload the kexec tarball first
794-
"${localUploadCommand[@]}" | runSsh 'cat > "$HOME/kexec-tarball.tar.gz"'
795792
# Use local file for extraction
796-
tarCommand="cat \"\$HOME/kexec-tarball.tar.gz\" | tar -xv ${tarDecomp}"
793+
tarCommand="cat \"\$HOME/kexec/kexec-tarball.tar.gz\" | tar -xv ${tarDecomp}"
797794
fi
798795
799796
local remoteCommands
800797
remoteCommands=${remoteCommandTemplate//'%TAR_COMMAND%'/$tarCommand}
801798
802799
# Create and execute the script on the remote system
800+
# shellcheck disable=SC2016 # We want $HOME to expand on the remote server
803801
runSsh 'mkdir -p "$HOME/kexec" && cat > "$HOME/kexec/nixos-anywhere-kexec.sh"' <<EOF
804802
$remoteCommands
805803
EOF
804+
if [[ ${#localUploadCommand[@]} -gt 0 ]]; then
805+
# Upload the kexec tarball first
806+
# shellcheck disable=SC2016 # We want $HOME to expand on the remote server
807+
"${localUploadCommand[@]}" | runSsh 'cat > "$HOME/kexec/kexec-tarball.tar.gz"'
808+
fi
809+
# shellcheck disable=SC2016 # We want $HOME to expand on the remote server
806810
runSsh 'bash "$HOME/kexec/nixos-anywhere-kexec.sh"' || handleKexecFailure "Kexec"
807811
808812
# use the default SSH port to connect at this point

0 commit comments

Comments
 (0)