20266e4a2f
Flask's send_file uses mimetypes.guess_type() which needs the file extension at the end of the path. Previously files were named acme.sh-3.1.3 and htm.js-3.1.1 — now acme-3.1.3.sh and htm-3.1.1.js. Also: update-vendor.sh now owns ACME_HOME installation, removing duplicate logic from install.sh.
84 lines
2.4 KiB
Bash
Executable File
84 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Download and vendor libraries into vendor/.
|
|
# Files are named {pkg}-{ver}.{ext}, with {pkg}.{ext} symlinks for stable references.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
VENDOR="$PROJECT_DIR/vendor"
|
|
WEBUI_VENDOR="$PROJECT_DIR/webui/static/vendor"
|
|
|
|
# ---- Library versions ----
|
|
ACME_VERSION="3.1.3"
|
|
HTM_VERSION="3.1.1"
|
|
|
|
# ---- Helpers ----
|
|
download() {
|
|
local name="$1" url="$2" dest="$3"
|
|
if [[ -n "${SKIP_DOWNLOAD:-}" ]]; then
|
|
echo "[skip] $name"
|
|
return
|
|
fi
|
|
if [[ -f "$dest" ]]; then
|
|
echo "[skip] $name (already present)"
|
|
return
|
|
fi
|
|
echo "[download] $name → $dest"
|
|
curl -sfL -o "$dest" "$url"
|
|
}
|
|
|
|
ensure_symlink() {
|
|
local link="$1" target="$2"
|
|
if [[ -L "$link" ]]; then
|
|
cur=$(readlink "$link")
|
|
if [[ "$cur" != "$target" ]]; then
|
|
echo "[symlink] $link → $target (updated)"
|
|
ln -sf "$target" "$link"
|
|
fi
|
|
elif [[ -e "$link" ]]; then
|
|
echo "[symlink] $link (replacing existing file)"
|
|
mv -f "$link" "${link}.bak" && ln -sf "$target" "$link"
|
|
else
|
|
echo "[symlink] $link → $target"
|
|
ln -sf "$target" "$link"
|
|
fi
|
|
}
|
|
|
|
# ---- acme.sh ----
|
|
ACME_VERSIONED="$VENDOR/acme-${ACME_VERSION}.sh"
|
|
ACME_SYMLINK="$VENDOR/acme.sh"
|
|
download "acme.sh@${ACME_VERSION}" \
|
|
"https://raw.githubusercontent.com/acmesh-official/acme.sh/${ACME_VERSION}/acme.sh" \
|
|
"$ACME_VERSIONED"
|
|
chmod +x "$ACME_VERSIONED"
|
|
ensure_symlink "$ACME_SYMLINK" "acme-${ACME_VERSION}.sh"
|
|
|
|
# ---- htm ----
|
|
HTM_VERSIONED="$VENDOR/htm-${HTM_VERSION}.js"
|
|
HTM_SYMLINK="$VENDOR/htm.js"
|
|
download "htm@${HTM_VERSION}" \
|
|
"https://cdn.jsdelivr.net/npm/htm@${HTM_VERSION}/mini/index.module.js" \
|
|
"$HTM_VERSIONED"
|
|
ensure_symlink "$HTM_SYMLINK" "htm-${HTM_VERSION}.js"
|
|
|
|
# ---- ACME_HOME (acme.sh runtime home) ----
|
|
ACME_HOME="${ACME_HOME:-$PROJECT_DIR/data/acme}"
|
|
mkdir -p "$ACME_HOME"
|
|
if [[ ! -x "$ACME_HOME/acme.sh" ]]; then
|
|
cp "$ACME_SYMLINK" "$ACME_HOME/acme.sh"
|
|
chmod +x "$ACME_HOME/acme.sh"
|
|
fi
|
|
|
|
# ---- Webui symlinks (point to versioned files) ----
|
|
mkdir -p "$WEBUI_VENDOR"
|
|
WEBUI_LINKS=(
|
|
"htm.js:../../../vendor/htm-${HTM_VERSION}.js"
|
|
)
|
|
for entry in "${WEBUI_LINKS[@]}"; do
|
|
IFS=':' read -r name target <<< "$entry"
|
|
ensure_symlink "${WEBUI_VENDOR}/${name}" "$target"
|
|
done
|
|
|
|
echo "[done] All libraries vendored."
|