fix: run-builder.sh uses BUILDER_USER from .env, not hardcoded

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-03-08 18:48:33 +03:00
parent fa553c3f20
commit 68b5e02a74
2 changed files with 23 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# run-builder.sh — trigger debug ISO build on remote Alpine builder VM
# run-builder.sh — trigger ISO build on remote Debian 12 builder VM
#
# Usage:
# sh scripts/run-builder.sh
@@ -18,10 +18,15 @@ if [ -f "$ENV_FILE" ]; then
fi
BUILDER_HOST="${BUILDER_HOST:-}"
BUILDER_USER="${BUILDER_USER:-}"
if [ -z "$BUILDER_HOST" ]; then
echo "ERROR: BUILDER_HOST not set. Copy .env.example to .env and set the address."
exit 1
fi
if [ -z "$BUILDER_USER" ]; then
echo "ERROR: BUILDER_USER not set. Set it in .env."
exit 1
fi
EXTRA_ARGS=""
while [ $# -gt 0 ]; do
@@ -32,7 +37,7 @@ while [ $# -gt 0 ]; do
done
echo "=== bee builder ==="
echo "Builder: ${BUILDER_HOST}"
echo "Builder: ${BUILDER_USER}@${BUILDER_HOST}"
echo ""
# --- check local repo is in sync with remote ---
@@ -53,10 +58,10 @@ fi
echo "repo: in sync with remote ($LOCAL)"
echo ""
ssh -o StrictHostKeyChecking=no root@"${BUILDER_HOST}" /bin/sh <<ENDSSH
ssh -o StrictHostKeyChecking=no "${BUILDER_USER}@${BUILDER_HOST}" /bin/sh <<ENDSSH
set -e
REPO=/root/bee
LOG=/var/log/bee-build.log
REPO="/home/${BUILDER_USER}/bee"
LOG=/tmp/bee-build.log
if [ ! -d "\$REPO/.git" ]; then
echo "--- cloning bee repo ---"
@@ -67,24 +72,25 @@ cd "\$REPO"
echo "--- pulling latest ---"
git checkout -- .
git pull --ff-only
chmod +x iso/overlay/etc/init.d/* iso/overlay/usr/local/bin/* 2>/dev/null || true
chmod +x iso/overlay/usr/local/bin/* 2>/dev/null || true
# Kill any previous build session
screen -S bee-build -X quit 2>/dev/null || true
echo "--- starting build in screen session (survives SSH disconnect) ---"
echo "--- log: \$LOG ---"
screen -dmS bee-build sh -c "sh iso/builder/build.sh ${EXTRA_ARGS} > \$LOG 2>&1; echo \$? > /tmp/bee-build-exit"
screen -dmS bee-build sh -c "sudo sh iso/builder/build.sh ${EXTRA_ARGS} > \$LOG 2>&1; echo \$? > /tmp/bee-build-exit"
# Stream log until build finishes
echo "--- streaming build log (Ctrl+C safe — build continues on VM) ---"
while screen -list | grep -q bee-build; do
tail -n +1 -f "\$LOG" 2>/dev/null & TAIL_PID=\$!
sleep 1
while screen -list | grep -q bee-build; do sleep 2; done
kill \$TAIL_PID 2>/dev/null || true
break
tail -n +1 -f "\$LOG" 2>/dev/null &
TAIL_PID=\$!
while screen -list 2>/dev/null | grep -q bee-build; do
sleep 2
done
sleep 1
kill \$TAIL_PID 2>/dev/null || true
tail -n 20 "\$LOG" 2>/dev/null || true
EXIT_CODE=\$(cat /tmp/bee-build-exit 2>/dev/null || echo 1)
@@ -95,14 +101,14 @@ echo ""
echo "=== downloading ISO ==="
LOCAL_ISO_DIR="${REPO_ROOT}/iso/out"
mkdir -p "${LOCAL_ISO_DIR}"
if command -v rsync >/dev/null 2>&1 && ssh -o StrictHostKeyChecking=no root@"${BUILDER_HOST}" command -v rsync >/dev/null 2>&1; then
if command -v rsync >/dev/null 2>&1 && ssh -o StrictHostKeyChecking=no "${BUILDER_USER}@${BUILDER_HOST}" command -v rsync >/dev/null 2>&1; then
rsync -az --progress \
-e "ssh -o StrictHostKeyChecking=no" \
"root@${BUILDER_HOST}:/root/bee/dist/*.iso" \
"${BUILDER_USER}@${BUILDER_HOST}:/home/${BUILDER_USER}/bee/dist/*.iso" \
"${LOCAL_ISO_DIR}/"
else
scp -o StrictHostKeyChecking=no \
"root@${BUILDER_HOST}:/root/bee/dist/*.iso" \
"${BUILDER_USER}@${BUILDER_HOST}:/home/${BUILDER_USER}/bee/dist/*.iso" \
"${LOCAL_ISO_DIR}/"
fi
echo ""