fuzzyworld

fuzzyworld-tools / files / server / install.sh

install.sh

3.3 KB · history · blame

1#!/bin/bash
2# Install or update the DreamHost side of fuzzyworld-tools. Run from the laptop:
3# server/install.sh copy tools, site files and hooks to `dh`
4# server/install.sh --publish ...then republish every public repo
5set -euo pipefail
6cd "$(dirname "$0")/.."
7HOST=${FW_HOST:-dh}
8
9ssh "$HOST" 'mkdir -p ~/fw/tools'
10rsync -az --delete --exclude '__pycache__' server/ "$HOST:fw/tools/server/"
11ssh "$HOST" bash -s <<'EOF'
12set -euo pipefail
13chmod +x ~/fw/tools/server/fw ~/fw/tools/server/hooks/*
14# DreamHost's process watchdog kills git-upload-pack when pack-objects uses its defaults
15# (2 threads, unbounded delta window) on large repos, so clones/fetches over ssh of e.g.
16# when-am-i (284 MB) die with "git-pack-objects died". These limits keep it under the radar.
17git config --global pack.threads 1
18git config --global pack.windowMemory 64m
19git config --global pack.deltaCacheSize 16m
20git config --global core.bigFileThreshold 16m
21mkdir -p ~/bin ~/fw/state ~/fw/logs ~/fw/queue/pending ~/fw/queue/running ~/fw/ci ~/fw/issues
22chmod +x ~/fw/tools/server/runner-api ~/fw/tools/server/mirror-only
23# Pygments colors source code on the file pages (gen.py works without it, uncolored).
24# Python-Markdown renders the README pages and the landing page text (`gen.py landing` needs it).
25[ -d ~/fw/pylib/markdown ] || python3 -m pip install --quiet --target ~/fw/pylib "Markdown==3.7"
26[ -d ~/fw/pylib/pygments ] || python3 -m pip install --quiet --target ~/fw/pylib "Pygments==2.21.0"
27ln -sfn ~/fw/tools/server/fw ~/bin/fw
28site=~/code.fuzzyworld.net
29cp ~/fw/tools/server/site/htaccess "$site/.htaccess"
30cp ~/fw/tools/server/site/_shared.css ~/fw/tools/server/site/_icons.css ~/fw/tools/server/site/style.css ~/fw/tools/server/site/robots.txt ~/fw/tools/server/site/favicon.ico "$site/"
31chmod 644 "$site"/_shared.css "$site"/_icons.css "$site"/style.css "$site"/robots.txt "$site"/favicon.ico
32apps=~/apps.fuzzyworld.net
33cp ~/fw/tools/server/site-apps/htaccess "$apps/.htaccess"
34cp ~/fw/tools/server/site/_shared.css ~/fw/tools/server/site/_icons.css ~/fw/tools/server/site/style.css ~/fw/tools/server/site/favicon.ico "$apps/"
35chmod 644 "$apps"/_shared.css "$apps"/_icons.css "$apps"/style.css "$apps"/favicon.ico
36# Main fuzzyworld.net site
37main_site=~/fuzzyworld.net
38python3 ~/fw/tools/server/gen.py landing ~/fw/tools/server/site/index.html "$main_site/index.html" # nav and footer built in gen.py
39cp ~/fw/tools/server/site/main.css "$main_site/"
40mkdir -p "$main_site/projects"
41cp ~/fw/tools/server/site/projects-redirect.html "$main_site/projects/index.html" # the old projects page, now /projects/ on code.
42chmod 644 "$main_site/projects/index.html"
43cp ~/fw/tools/server/site/_shared.css ~/fw/tools/server/site/_icons.css "$main_site/"
44cp ~/fw/tools/server/site/favicon.ico "$main_site/"
45chmod 644 "$main_site"/index.html "$main_site"/main.css "$main_site"/_shared.css "$main_site"/_icons.css "$main_site"/favicon.ico
46~/bin/fw install-hooks
47~/bin/fw apps-index
48~/bin/fw content
49# Scheduled jobs: replace only our own block in the crontab, keeping anything else.
50chmod +x ~/fw/tools/server/jobs/*.sh
51{ { crontab -l 2>/dev/null || true; } | sed '/^# fw:begin/,/^# fw:end/d'; cat ~/fw/tools/server/jobs/crontab; } | crontab -
52EOF
53if [ "${1:-}" = --publish ]; then ssh "$HOST" '~/bin/fw publish-all'; fi
54echo "installed on $HOST"