Fix darkforge-test heredoc indentation in cloud-init

The cat heredoc inside cloud-init runcmd was indented, causing the
shebang line to become "    #!/bin/bash" (with leading spaces) which
makes the script fail to execute as a proper interpreter.

Fixed by removing indentation from the heredoc body. Also improved
the error message to explain that the clone likely failed during
provisioning and show the manual clone command.

Added tmux kill-session before starting new session to avoid
"duplicate session" errors on re-run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 16:10:03 +01:00
parent fe6ee25d1c
commit 83760025b6
2 changed files with 21 additions and 12 deletions

BIN
rescue-objects.tar Normal file

Binary file not shown.

View File

@@ -179,20 +179,29 @@ runcmd:
' '
# --- INSTALL CONVENIENCE COMMAND ------------------------------------------- # --- INSTALL CONVENIENCE COMMAND -------------------------------------------
# NOTE: heredoc inside cloud-init runcmd must NOT be indented or the
# shebang gets leading spaces and the script won't execute properly.
- | - |
cat > /usr/local/bin/darkforge-test << 'DTEOF' cat > /usr/local/bin/darkforge-test << 'DTEOF'
#!/bin/bash #!/bin/bash
SCRIPT="/home/darkforge/darkforge/tests/proxmox/run-in-vm.sh" SCRIPT="/home/darkforge/darkforge/tests/proxmox/run-in-vm.sh"
if [ ! -f "$SCRIPT" ]; then if [ ! -f "$SCRIPT" ]; then
echo "ERROR: Test script not found. Is the repo cloned?" echo "ERROR: Test script not found at: $SCRIPT"
echo " git clone --recurse-submodules https://git.dannyhaslund.dk/danny8632/darkforge.git ~/darkforge" echo ""
exit 1 echo "The git clone probably failed during provisioning."
fi echo "Clone manually:"
ARGS="$*" echo " git clone --recurse-submodules https://git.dannyhaslund.dk/danny8632/darkforge.git ~/darkforge"
exec tmux new-session -d -s darkforge \ echo ""
"bash ${SCRIPT} --tmux ${ARGS}; echo ''; echo 'Tests finished. Press Enter to close.'; read" \; \ echo "Then run: darkforge-test"
attach-session -t darkforge exit 1
DTEOF fi
ARGS="$*"
# Kill any existing tmux session first
tmux kill-session -t darkforge 2>/dev/null || true
exec tmux new-session -d -s darkforge \
"bash ${SCRIPT} --tmux ${ARGS}; echo ''; echo 'Tests finished. Press Enter to close.'; read" \; \
attach-session -t darkforge
DTEOF
chmod +x /usr/local/bin/darkforge-test chmod +x /usr/local/bin/darkforge-test
# --- SIGNAL DONE ----------------------------------------------------------- # --- SIGNAL DONE -----------------------------------------------------------