diff --git a/scripts/build-linux-docker.sh b/scripts/build-linux-docker.sh index dab5d83..bcf828a 100755 --- a/scripts/build-linux-docker.sh +++ b/scripts/build-linux-docker.sh @@ -10,6 +10,7 @@ set -euo pipefail # ./scripts/build-linux-docker.sh --pull Git pull before building # ./scripts/build-linux-docker.sh --clean Clean Rust target cache # ./scripts/build-linux-docker.sh --install Download binaries locally after build +# ./scripts/build-linux-docker.sh --deploy Download + deploy wzp-relay to relay servers REMOTE_HOST="SepehrHomeserverdk" BASE_DIR="/mnt/storage/manBuilder" @@ -21,17 +22,26 @@ SSH_OPTS="-o ConnectTimeout=15 -o ServerAliveInterval=15 -o ServerAliveCountMax= # (opus-DRED-v2 as of 2026-04-11). Override with `WZP_BRANCH= ./build-linux-docker.sh` # if you need a different one — e.g. to rebuild the relay from a feature # branch for A/B testing. -WZP_BRANCH="${WZP_BRANCH:-opus-DRED-v2}" +WZP_BRANCH="${WZP_BRANCH:-$(git -C "$(dirname "$0")/.." branch --show-current 2>/dev/null || echo "experimental-ui")}" + +# Relay servers to deploy to when --deploy is passed. +# Format: "user@host:binary_dir:tmux_session" +RELAY_SERVERS=( + "manwe@manwehs:/home/manwe/wzp:5" + "manwe@pangolin.manko.yoga:/home/manwe/wzp-linux:0" +) DO_PULL=1 DO_CLEAN=0 DO_INSTALL=0 +DO_DEPLOY=0 for arg in "$@"; do case "$arg" in - --pull) DO_PULL=1 ;; + --pull) DO_PULL=1 ;; --no-pull) DO_PULL=0 ;; - --clean) DO_CLEAN=1 ;; + --clean) DO_CLEAN=1 ;; --install) DO_INSTALL=1 ;; + --deploy) DO_DEPLOY=1; DO_INSTALL=1 ;; esac done @@ -149,6 +159,41 @@ echo " Monitor: ssh $REMOTE_HOST 'tail -f /tmp/wzp-linux-build.log'" echo " Status: ssh $REMOTE_HOST 'tail -5 /tmp/wzp-linux-build.log'" echo "" +# Deploy wzp-relay to a single relay server. +# $1 = "user@host" $2 = binary_dir $3 = tmux_session +deploy_relay() { + local TARGET="$1" + local BINARY_DIR="$2" + local TMUX_SESSION="$3" + local DEPLOY_OPTS="-o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new -o LogLevel=ERROR" + + log "Deploying wzp-relay to $TARGET ($BINARY_DIR) ..." + + # Copy new binary atomically + scp $DEPLOY_OPTS "$LOCAL_OUTPUT/wzp-relay" "$TARGET:$BINARY_DIR/wzp-relay.new" + ssh $DEPLOY_OPTS "$TARGET" "chmod +x $BINARY_DIR/wzp-relay.new && mv $BINARY_DIR/wzp-relay.new $BINARY_DIR/wzp-relay" + + # Capture current args, stop, restart in same tmux session + ssh $DEPLOY_OPTS "$TARGET" bash </dev/null || kill -TERM \$RELAY_PID 2>/dev/null || true +sleep 2 +echo "Starting new relay..." +tmux send-keys -t $TMUX_SESSION "cd $BINARY_DIR && ./wzp-relay \$RELAY_ARGS" Enter 2>/dev/null || true +echo "Deploy done on $TARGET" +DEPLOY + + log "Deployed to $TARGET" +} + # Optionally wait and download if [ "$DO_INSTALL" = "1" ]; then log "Waiting for build..." @@ -170,5 +215,19 @@ if [ "$DO_INSTALL" = "1" ]; then log "Done! Binaries in $LOCAL_OUTPUT/" else err "Build failed" + exit 1 fi fi + +# Deploy to relay servers +if [ "$DO_DEPLOY" = "1" ]; then + if [ ! -f "$LOCAL_OUTPUT/wzp-relay" ]; then + err "wzp-relay binary not found in $LOCAL_OUTPUT — install step may have failed" + exit 1 + fi + for SERVER in "${RELAY_SERVERS[@]}"; do + IFS=: read -r TARGET BINARY_DIR TMUX_SESSION <<< "$SERVER" + deploy_relay "$TARGET" "$BINARY_DIR" "$TMUX_SESSION" + done + log "All relay servers updated!" +fi