rename vendor files to put extension after version string
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.
This commit is contained in:
+53
-24
@@ -1,54 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
# Download and vendor libraries into vendor/.
|
||||
# Run from the project root after updating the VERSION variables below.
|
||||
# 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"
|
||||
|
||||
VENDOR="vendor"
|
||||
|
||||
# ---- Helpers ----
|
||||
download() {
|
||||
local name="$1" url="$2" dest="$3"
|
||||
if [[ -n "${SKIP_DOWNLOAD:-}" ]]; then
|
||||
echo "[skip] $name (SKIP_DOWNLOAD is set)"
|
||||
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" \
|
||||
"${VENDOR}/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://raw.githubusercontent.com/developit/htm/${HTM_VERSION}/mini/index.module.js" \
|
||||
"${VENDOR}/htm.js"
|
||||
"https://cdn.jsdelivr.net/npm/htm@${HTM_VERSION}/mini/index.module.js" \
|
||||
"$HTM_VERSIONED"
|
||||
ensure_symlink "$HTM_SYMLINK" "htm-${HTM_VERSION}.js"
|
||||
|
||||
chmod +x "${VENDOR}/acme.sh"
|
||||
# ---- 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
|
||||
|
||||
# --- Symlinks for webui ---
|
||||
WEBUI_VENDOR="webui/static/vendor"
|
||||
# ---- Webui symlinks (point to versioned files) ----
|
||||
mkdir -p "$WEBUI_VENDOR"
|
||||
|
||||
WEBUI_LINKS=(
|
||||
"htm.js:../../../vendor/htm.js"
|
||||
"htm.js:../../../vendor/htm-${HTM_VERSION}.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
|
||||
IFS=':' read -r name target <<< "$entry"
|
||||
ensure_symlink "${WEBUI_VENDOR}/${name}" "$target"
|
||||
done
|
||||
|
||||
echo "[done] All libraries vendored."
|
||||
|
||||
Reference in New Issue
Block a user