fuzzyworld-tools / files / server / install.sh
install.sh
| 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 |
| 5 | set -euo pipefail |
| 6 | cd "$(dirname "$0")/.." |
| 7 | HOST=${FW_HOST:-dh} |
| 8 | |
| 9 | ssh "$HOST" 'mkdir -p ~/fw/tools' |
| 10 | rsync -az --delete --exclude '__pycache__' server/ "$HOST:fw/tools/server/" |
| 11 | ssh "$HOST" bash -s <<'EOF' |
| 12 | set -euo pipefail |
| 13 | chmod +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. |
| 17 | git config --global pack.threads 1 |
| 18 | git config --global pack.windowMemory 64m |
| 19 | git config --global pack.deltaCacheSize 16m |
| 20 | git config --global core.bigFileThreshold 16m |
| 21 | mkdir -p ~/bin ~/fw/state ~/fw/logs ~/fw/queue/pending ~/fw/queue/running ~/fw/ci ~/fw/issues |
| 22 | chmod +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" |
| 27 | ln -sfn ~/fw/tools/server/fw ~/bin/fw |
| 28 | site=~/code.fuzzyworld.net |
| 29 | cp ~/fw/tools/server/site/htaccess "$site/.htaccess" |
| 30 | cp ~/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/" |
| 31 | chmod 644 "$site"/_shared.css "$site"/_icons.css "$site"/style.css "$site"/robots.txt "$site"/favicon.ico |
| 32 | apps=~/apps.fuzzyworld.net |
| 33 | cp ~/fw/tools/server/site-apps/htaccess "$apps/.htaccess" |
| 34 | cp ~/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/" |
| 35 | chmod 644 "$apps"/_shared.css "$apps"/_icons.css "$apps"/style.css "$apps"/favicon.ico |
| 36 | # Main fuzzyworld.net site |
| 37 | main_site=~/fuzzyworld.net |
| 38 | python3 ~/fw/tools/server/gen.py landing ~/fw/tools/server/site/index.html "$main_site/index.html" # nav and footer built in gen.py |
| 39 | cp ~/fw/tools/server/site/main.css "$main_site/" |
| 40 | mkdir -p "$main_site/projects" |
| 41 | cp ~/fw/tools/server/site/projects-redirect.html "$main_site/projects/index.html" # the old projects page, now /projects/ on code. |
| 42 | chmod 644 "$main_site/projects/index.html" |
| 43 | cp ~/fw/tools/server/site/_shared.css ~/fw/tools/server/site/_icons.css "$main_site/" |
| 44 | cp ~/fw/tools/server/site/favicon.ico "$main_site/" |
| 45 | chmod 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. |
| 50 | chmod +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 - |
| 52 | EOF |
| 53 | if [ "${1:-}" = --publish ]; then ssh "$HOST" '~/bin/fw publish-all'; fi |
| 54 | echo "installed on $HOST" |