#!/usr/bin/env bash # Build locally, push to the droplet, restart. Usage: deploy/deploy.sh set -euo pipefail HOST="${1:?usage: deploy.sh }" npm run build --workspace=@wizwar/web rsync -az --delete \ --exclude node_modules --exclude data/ --exclude .git --exclude research \ ./ "root@$HOST:/opt/wizwar/" ssh "root@$HOST" ' cd /opt/wizwar && npm install --no-audit --no-fund chown -R wizwar:wizwar /opt/wizwar cp /opt/wizwar/deploy/wizwar.service /etc/systemd/system/wizwar.service # The backup script is cron-run from /usr/local/bin — install it every # deploy, or the repo copy and the live copy drift apart (they did: # the Sentry check-ins shipped in the repo and never reached the box). install -m 755 /opt/wizwar/deploy/wizwar-backup.sh /usr/local/bin/wizwar-backup.sh # The nightly rollup and its cron entry ride along the same way; its # Sentry check-in URL is the backup monitor'"'"'s with its own slug. install -m 755 /opt/wizwar/deploy/wizwar-rollup.sh /usr/local/bin/wizwar-rollup.sh install -m 644 /opt/wizwar/deploy/wizwar-rollup.cron /etc/cron.d/wizwar-rollup if [ -f /root/.wizwar-sentry-cron ] && [ ! -f /root/.wizwar-sentry-cron-rollup ]; then sed "s#/cron/new-monitor/#/cron/wizwar-rollup/#" /root/.wizwar-sentry-cron > /root/.wizwar-sentry-cron-rollup chmod 600 /root/.wizwar-sentry-cron-rollup fi systemctl daemon-reload systemctl enable --now wizwar systemctl restart wizwar systemctl --no-pager -l status wizwar | head -5 ' echo "deployed."