#!/bin/bash # Deploy bubble-relay to jai (see ~/Documents/shared-resources/jai.html#run). # jai is production: this only ever touches ~/Documents/bubble-server and its # own screen session, and installs nothing. # # scripts/deploy-jai.sh copy the code and (re)start the service # scripts/deploy-jai.sh --stop stop it # scripts/deploy-jai.sh --token print the bearer token, for Settings → Rabbit relay on the desktop # # What runs is server/run.sh, also started by jai's ~/startup.sh (re-run by its # watchdog every 5 minutes), so it comes back after a crash or a reboot. set -euo pipefail HOST=${JAI_HOST:-jai-ext} DIR=/home/jai/Documents/bubble-server NAME=bubble-relay cd "$(dirname "$0")/.." case "${1:-}" in --token) ssh "$HOST" "cat $DIR/data/token"; echo; exit 0 ;; --stop) ssh "$HOST" "screen -S $NAME -X quit || true"; echo "stopped"; exit 0 ;; esac ssh "$HOST" "mkdir -p $DIR/app $DIR/data ~/service-logs && chmod 700 $DIR $DIR/data" rsync -a server/bubble_relay.py server/run.sh "$HOST:$DIR/app/" ssh "$HOST" bash -s </dev/null || true sleep 1 screen -dmS $NAME bash -c 'bash $DIR/app/run.sh 2>&1 | tee ~/service-logs/$NAME.log' sleep 2 for pid in \$(pgrep -f bubble_relay.py); do echo 1000 > /proc/\$pid/oom_score_adj; done curl -s -m 5 http://100.69.139.40:8080/health; echo REMOTE