@@ -726,6 +726,7 @@ runKexec() {
726
726
local logContent=" "
727
727
if logContent=$(
728
728
set +x
729
+ # shellcheck disable=SC2016 # We want $HOME to expand on the remote server
729
730
runSsh ' cat "$HOME/kexec/nixos-anywhere.log" 2>/dev/null' 2> /dev/null
730
731
) ; then
731
732
echo " Remote output log:" >&2
@@ -741,8 +742,6 @@ runKexec() {
741
742
# Run kexec commands with sudo if needed
742
743
{
743
744
set -eu ${enableDebug}
744
- ${maybeSudo} rm -rf \"\$ HOME/kexec\"
745
- mkdir -p \"\$ HOME/kexec\"
746
745
cd \"\$ HOME/kexec\"
747
746
echo Downloading kexec tarball, this may take a moment...
748
747
# Execute tar command
790
789
# Use remote command for download
791
790
tarCommand=" $( printf ' %q ' " ${remoteUploadCommand[@]} " ) | tar -xv ${tarDecomp} "
792
791
else
793
- # Upload the kexec tarball first
794
- " ${localUploadCommand[@]} " | runSsh ' cat > "$HOME/kexec-tarball.tar.gz"'
795
792
# 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} "
797
794
fi
798
795
799
796
local remoteCommands
800
797
remoteCommands=${remoteCommandTemplate// ' %TAR_COMMAND%' / $tarCommand }
801
798
802
799
# Create and execute the script on the remote system
800
+ # shellcheck disable=SC2016 # We want $HOME to expand on the remote server
803
801
runSsh ' mkdir -p "$HOME/kexec" && cat > "$HOME/kexec/nixos-anywhere-kexec.sh"' << EOF
804
802
$remoteCommands
805
803
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
806
810
runSsh ' bash "$HOME/kexec/nixos-anywhere-kexec.sh"' || handleKexecFailure " Kexec"
807
811
808
812
# use the default SSH port to connect at this point
0 commit comments