#!/usr/bin/env bash # Download and vendor libraries into vendor/. # Run from the project root after updating the VERSION variables below. set -euo pipefail # ---- Library versions ---- ACME_VERSION="3.1.3" HTM_VERSION="3.1.1" VENDOR="vendor" download() { local name="$1" url="$2" dest="$3" if [[ -n "${SKIP_DOWNLOAD:-}" ]]; then echo "[skip] $name (SKIP_DOWNLOAD is set)" return fi echo "[download] $name → $dest" curl -sfL -o "$dest" "$url" } download "acme.sh@${ACME_VERSION}" \ "https://raw.githubusercontent.com/acmesh-official/acme.sh/${ACME_VERSION}/acme.sh" \ "${VENDOR}/acme.sh" download "htm@${HTM_VERSION}" \ "https://raw.githubusercontent.com/developit/htm/${HTM_VERSION}/mini/index.module.js" \ "${VENDOR}/htm.js" chmod +x "${VENDOR}/acme.sh" # --- Symlinks for webui --- WEBUI_VENDOR="webui/static/vendor" mkdir -p "$WEBUI_VENDOR" WEBUI_LINKS=( "htm.js:../../../vendor/htm.js" ) for entry in "${WEBUI_LINKS[@]}"; do IFS=':' read -r name target <<< "$entry" if [[ -L "${WEBUI_VENDOR}/${name}" ]]; then cur=$(readlink "${WEBUI_VENDOR}/${name}") if [[ "$cur" != "$target" ]]; then echo "[symlink] ${WEBUI_VENDOR}/${name} → ${target} (updated)" ln -sf "$target" "${WEBUI_VENDOR}/${name}" fi else echo "[symlink] ${WEBUI_VENDOR}/${name} → ${target}" ln -sf "$target" "${WEBUI_VENDOR}/${name}" fi done echo "[done] All libraries vendored."