diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/bugs | 3 | ||||
| -rwxr-xr-x | scripts/deploy | 44 | ||||
| -rwxr-xr-x | scripts/logs | 2 | ||||
| -rwxr-xr-x | scripts/resolve-bug | 4 |
4 files changed, 48 insertions, 5 deletions
diff --git a/scripts/bugs b/scripts/bugs index 4f3c064..824e67a 100755 --- a/scripts/bugs +++ b/scripts/bugs @@ -1,4 +1,3 @@ #!/bin/bash # List all bugs from the production database - -ssh titanium "sqlite3 -column -header /site/doot.terst.org/data/dashboard.db 'SELECT id, description, created_at FROM bugs ORDER BY id'" +sqlite3 -column -header /site/doot.terst.org/data/dashboard.db 'SELECT id, description, created_at FROM bugs ORDER BY id' diff --git a/scripts/deploy b/scripts/deploy new file mode 100755 index 0000000..e6746d8 --- /dev/null +++ b/scripts/deploy @@ -0,0 +1,44 @@ +#!/bin/bash +set -e + +# Configuration +FQDN="doot.terst.org" +SITE_DIR="/site/${FQDN}" +SERVICE="task-dashboard@${FQDN}" + +echo "==> Building CSS..." +npm run css:build + +echo "==> Building binary..." +BUILD_COMMIT=$(git rev-parse --short HEAD) +BUILD_TIME=$(date -u '+%Y-%m-%dT%H:%M:%SZ') +LDFLAGS="-X main.buildCommit=${BUILD_COMMIT} -X main.buildTime=${BUILD_TIME}" +go build -ldflags "$LDFLAGS" -o app cmd/dashboard/main.go + +echo "==> Stopping service..." +systemctl stop ${SERVICE} || true + +echo "==> Syncing assets and migrations to ${SITE_DIR}..." +# Sync static files +rsync -av --delete web/static/ ${SITE_DIR}/public/ +# Sync templates +rsync -av --delete web/templates/ ${SITE_DIR}/templates/ +# Sync migrations +rsync -av --delete migrations/ ${SITE_DIR}/migrations/ + +echo "==> Swapping binary..." +mv app ${SITE_DIR}/app + +echo "==> Setting permissions..." +chown -R www-data:www-data ${SITE_DIR} +find ${SITE_DIR} -type d -exec chmod 755 {} \; +find ${SITE_DIR} -type f -exec chmod 644 {} \; +chmod +x ${SITE_DIR}/app +chmod 600 ${SITE_DIR}/.env 2>/dev/null || true + +echo "==> Starting service..." +systemctl start ${SERVICE} +sleep 1 +systemctl status ${SERVICE} --no-pager -l + +echo "==> Deploy complete!" diff --git a/scripts/logs b/scripts/logs index 7cec0c6..0259939 100755 --- a/scripts/logs +++ b/scripts/logs @@ -8,4 +8,4 @@ # scripts/logs --since "1 hour ago" # scripts/logs --grep "error" -ssh titanium journalctl -u task-dashboard@doot.terst.org --no-pager "$@" +journalctl -u task-dashboard@doot.terst.org --no-pager "$@" diff --git a/scripts/resolve-bug b/scripts/resolve-bug index a3f0979..1fcf5df 100755 --- a/scripts/resolve-bug +++ b/scripts/resolve-bug @@ -10,10 +10,10 @@ BUG_ID="$1" # Show the bug being resolved echo "Resolving bug #$BUG_ID:" -ssh titanium "sqlite3 -column /site/doot.terst.org/data/dashboard.db \"SELECT description FROM bugs WHERE id = $BUG_ID\"" +sqlite3 -column /site/doot.terst.org/data/dashboard.db "SELECT description FROM bugs WHERE id = $BUG_ID" # Delete the bug -ssh titanium "sqlite3 /site/doot.terst.org/data/dashboard.db \"DELETE FROM bugs WHERE id = $BUG_ID\"" +sqlite3 /site/doot.terst.org/data/dashboard.db "DELETE FROM bugs WHERE id = $BUG_ID" if [ $? -eq 0 ]; then echo "Bug #$BUG_ID resolved." |
