#!/bin/sh # Deploy ac-ms-url-shortener (replaces monolith submodule path on lab nodes). set -eu ROOT="$(cd "$(dirname "$0")/.." && pwd)" # shellcheck source=/dev/null . "$ROOT/scripts/lib/common.sh" load_cluster_env URL_ROOT="${URL_SHORTENER_ROOT:-/var/www/url-shortener}" ORIGIN="${URL_SHORTENER_ORIGIN:-git://f0xx.org/ac/ac-ms-url-shortener}" BRANCH="${AC_GIT_BRANCH:-next}" mkdir -p "$(dirname "$URL_ROOT")" git config --global --add safe.directory "$URL_ROOT" 2>/dev/null || true if [ -d "${URL_ROOT}/.git" ]; then log "url-shortener pull ${BRANCH}" git -C "$URL_ROOT" fetch origin git -C "$URL_ROOT" checkout "$BRANCH" git -C "$URL_ROOT" pull --ff-only origin "$BRANCH" || git -C "$URL_ROOT" reset --hard "origin/${BRANCH}" else log "url-shortener clone ${ORIGIN}" rm -rf "$URL_ROOT" git clone --branch "$BRANCH" --depth 1 "$ORIGIN" "$URL_ROOT" fi chown -R nginx:nginx "$URL_ROOT" 2>/dev/null || true log "deploy-ac-url-shortener_ok $(host_short) $(git -C "$URL_ROOT" rev-parse --short HEAD)"