#!/bin/sh # Stages dist/ and serves it as https://watch.socialweb.computer/ from the socialweb.computer gateway's Caddy # (/etc/caddy/sites/.caddy, which its Caddyfile imports; *.socialweb.computer points there). scp's the files # and scripts/remote-install.sh, checks the host's name first; the live dir is backed up on the host. set -eu cd "$(dirname "$0")/.." site=${SITE:-watch.socialweb.computer} port=${SSH_PORT:-1997} target=${SSH_TARGET:-root@socialweb.computer} want_host=${WANT_HOST:-social-web-computer-static-site} got=$(ssh -p "$port" -o BatchMode=yes "$target" hostname) [ "$got" = "$want_host" ] || { echo "$target is $got, not $want_host" >&2; exit 1; } scripts/stage.sh tar -C dist -czf /tmp/swc-watch-dist.tgz . scp -P "$port" -o BatchMode=yes -q /tmp/swc-watch-dist.tgz scripts/remote-install.sh "$target:/tmp/" ssh -p "$port" -o BatchMode=yes "$target" sh /tmp/remote-install.sh "$site" /tmp/swc-watch-dist.tgz ok= for i in 1 2 3 4 5 6 7 8 9 10; do curl -sf -o /dev/null "https://$site/model.js" && { echo "https://$site/"; ok=1; break; }; sleep 3; done [ -n "$ok" ] || { echo "https://$site/ does not answer yet (TLS issuance?)" >&2; exit 1; } # the same dist/ as a web tile (records/tiles/; commit it), as TILE_AS: its atlibs OAuth session, or with # ATPROTO_APP_PASSWORD set its app password. NO_TILE=1 skips it. [ -n "${NO_TILE-}" ] && exit as=${TILE_AS:-johnandersen777.bsky.social} if [ -n "${ATPROTO_APP_PASSWORD-}" ]; then auth="--app-password $as --password-env ATPROTO_APP_PASSWORD"; else auth="--as $as"; fi atlibs publish tile dist socialweb-computer-watch --out records/tiles $auth | grep '"uri"' git status --short records/tiles