#!/usr/bin/env bash # crosscode: installs, updates and moves church installs on this server (ROADMAP-v3 §8, # docs/EVENTS-2.2-PLAN.md §4). `crosscode help` lists the commands. # # On a server this is a checkout of crosscode-platform's main in /opt/crosscode/tools, linked as # /usr/local/bin/crosscode. Every run first updates that checkout (git pull --ff-only), then runs # from a copy, so a checkout never changes the script while it runs. # # Environment: CROSSCODE_SITES (default /var/www/sites), CROSSCODE_REPO (the monorepo's git URL), # CROSSCODE_TOOLS_DIR (default /opt/crosscode/tools), CROSSCODE_NO_UPDATE=1 (skip the update). set -Eeuo pipefail CROSSCODE_TOOLS_DIR="${CROSSCODE_TOOLS_DIR:-/opt/crosscode/tools}" if [ -z "${CROSSCODE_HOME:-}" ]; then src="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)" root="$(cd "$src/.." && pwd)" if [ "${CROSSCODE_NO_UPDATE:-}" != 1 ] && [ "$root" = "$CROSSCODE_TOOLS_DIR" ] && [ -d "$root/.git" ]; then git -C "$root" pull --ff-only --quiet || printf '!!> Couldn'"'"'t update %s; running the version that is there.\n' "$root" >&2 fi copy="$(mktemp -d /tmp/crosscode.XXXXXX)" cp -R "$src/." "$copy/" CROSSCODE_HOME="$copy" CROSSCODE_FROM="$root" exec bash "$copy/crosscode" "$@" fi # Running from the copy: remove it afterwards (only ever a mktemp folder, never a checkout). if [[ "$CROSSCODE_HOME" == /tmp/crosscode.* ]]; then trap 'rm -rf "$CROSSCODE_HOME"' EXIT fi # shellcheck source=lib/common.sh source "$CROSSCODE_HOME/lib/common.sh" # shellcheck source=lib/deploy.sh source "$CROSSCODE_HOME/lib/deploy.sh" # shellcheck source=lib/status.sh source "$CROSSCODE_HOME/lib/status.sh" # shellcheck source=lib/install.sh source "$CROSSCODE_HOME/lib/install.sh" # shellcheck source=lib/adopt.sh source "$CROSSCODE_HOME/lib/adopt.sh" usage() { cat </dev/null || echo 'unknown version')) crosscode deploy [events] [website] [app] update Accounts and the products named crosscode deploy --every-church [events] … the same, for every church here crosscode deploy … --check only the checks; changes nothing crosscode status [] versions, latest releases, health crosscode install --products events --domain
a new church crosscode adopt --events-dir move an existing Cross Events install here crosscode adopt --undo go back to the old folder (within 14 days) crosscode help [] this, or a command's options Churches live in $CROSSCODE_SITES// (church.env, one checkout per product). EOF } command="${1:-help}" [ $# -gt 0 ] && shift case "$command" in deploy) cmd_deploy "$@" ;; status) cmd_status "$@" ;; install) cmd_install "$@" ;; adopt) cmd_adopt "$@" ;; add) die "\`crosscode add\` comes with the second product (phase 3)." ;; help|-h|--help) case "${1:-}" in deploy) deploy_usage ;; status) status_usage ;; install) install_usage ;; adopt) adopt_usage ;; *) usage ;; esac ;; *) usage; die "Unknown command \"$command\"." ;; esac