#!/bin/bash # Copies PiDisplay/ from this Mac to the Pi 5, and rebuilds the FT8/FT4 # native library over there so a C source change takes effect. # # This used to also offer to restart radio_ui.py and then close its own # Terminal window - split out (2026-10-13) into Restart_PiRadio.command, # a separate, simpler script, after the combined version kept failing on # the restart step specifically (see that script's header for why). Run # this one to push a change, then run Restart_PiRadio.command (or just # restart it by hand on the Pi) to pick it up. # # One-time setup: fill in PI_HOST and PI_USER below to match your Pi # (the same .local and from INTEGRATION_PROCEDURE.md # Section 6). Then just double-click this file (or run it) after editing # any PiDisplay file. # # Uses rsync, not a flat scp -r, so only changed files are sent - a normal # re-sync after a small edit takes a couple seconds instead of recopying # everything (photos, .stl files, PDFs, etc.) every time. PI_HOST="mustang.local" # <-- set to your Pi's hostname (or IP address) PI_USER="bob" # <-- set to your Pi's username PI_DEST="/home/$PI_USER/PiDisplay" cd "$(dirname "$0")" # Single shared SSH connection for sync + build (2026-10-13, so you only # enter the Pi's password once instead of once per rsync/ssh call below). # ControlPersist keeps it open briefly after this script exits so a # follow-up run of Restart_PiRadio.command right after can reuse it too. CONTROL_PATH="/tmp/sync_pidisplay_ssh_%r@%h:%p" SSH_OPTS=(-o ConnectTimeout=10 -o ControlMaster=auto -o ControlPath="$CONTROL_PATH" -o ControlPersist=5m) close_shared_connection() { ssh "${SSH_OPTS[@]}" -O exit "$PI_USER@$PI_HOST" >/dev/null 2>&1 } trap close_shared_connection EXIT echo "== Connecting to $PI_USER@$PI_HOST (password needed once here, reused" echo " for the rest of this script)..." if ! ssh "${SSH_OPTS[@]}" "$PI_USER@$PI_HOST" true; then echo "Could not connect to $PI_USER@$PI_HOST - check PI_HOST/PI_USER above, and" echo "that the Pi is on the network and SSH is enabled." read -p "Press Return to close... " exit 1 fi echo "== Syncing PiDisplay/ -> $PI_USER@$PI_HOST:$PI_DEST" # --checksum (2026-10-18): rsync's default "quick check" only compares # size + mtime, not actual content. Found to silently skip real changes - # e.g. a one-character version bump (V1.0.73 -> V1.0.74) doesn't change # file size at all, and files edited and pushed to this Mac through the # Claude device bridge don't reliably come out with a newer mtime than # whatever the Pi already has. Result: rsync reported success ("Sync # done") while actually transferring nothing for that file, and the Pi # kept running old code through repeated syncs+restarts with no error # anywhere to catch it. --checksum compares actual file content instead, # so a real change is never silently skipped again - it costs a bit more # time (the Pi has to read and hash its existing copy of every file), not # a problem for how small/infrequent these syncs are. rsync -avzc --delete \ --exclude '__pycache__/' \ --exclude '.DS_Store' \ --exclude '_doc_backups_*/' \ --exclude '*.FCBak' \ -e "ssh ${SSH_OPTS[*]}" \ PiDisplay/ "$PI_USER@$PI_HOST:$PI_DEST/" STATUS=$? if [ $STATUS -ne 0 ]; then echo "rsync failed (exit $STATUS) - check PI_HOST/PI_USER above, and that" echo "the Pi is on the network and SSH is enabled." read -p "Press Return to close... " exit $STATUS fi echo "== Sync done." # Rebuild the FT8/FT4 native library on the Pi (2026-10-13, so a C source # change under PiDisplay/ft8/ doesn't need a separate manual SSH step) - # this has to run on the Pi itself (gcc, built for its own ARM CPU), not # here on the Mac. Same command build_ft8.sh's own header comment has # always told you to run by hand: bash ~/PiDisplay/ft8/build_ft8.sh # # Reuses the shared connection above, so this shouldn't ask for a password # at all - gcc itself prints nothing until it's done (a few seconds to # around a minute on a Pi, depending on what changed), so it can look like # nothing's happening for a bit; that's normal. echo "== Building libmustang_ftx.so on the Pi (quiet until it's done)..." ssh "${SSH_OPTS[@]}" "$PI_USER@$PI_HOST" "bash $PI_DEST/ft8/build_ft8.sh" BUILD_STATUS=$? if [ $BUILD_STATUS -ne 0 ]; then echo "build_ft8.sh failed (exit $BUILD_STATUS) on the Pi - see the gcc" echo "output above. The sync above still went through; fix the build" echo "error and re-run this script, or build it by hand on the Pi." else echo "== Build done." fi echo "" echo "== Sync + build complete. Run Restart_PiRadio.command (in this same" echo " folder) to restart radio_ui.py on the Pi and pick up the change." read -p "Press Return to close... " # Close this script's own Terminal window (2026-10-13, at the user's # request: "it closes the radio window but not the terminal window behind # it, need to close that also") - matched by this process's own tty, so it # closes the right window without touching any other Terminal windows you # have open. Runs in the foreground (not backgrounded) so it's guaranteed # to finish before the script exits. osascript -e "tell application \"Terminal\" to close (every window whose tty is \"$(tty)\")" exit 0