Initial commit: stats-gateway gRPC service + dashboard + CLI
This commit is contained in:
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# Renders stats-site (Hugo project) without requiring Hugo, deploys atomically
|
||||
# to /var/www/stats-site/. The Hugo project uses only two template variables;
|
||||
# we substitute them with sed.
|
||||
#
|
||||
# Usage: build.sh [--src DIR] [--dest DIR]
|
||||
# --src default /opt/stats-site
|
||||
# --dest default /var/www/stats-site
|
||||
set -euo pipefail
|
||||
|
||||
SRC="${SRC:-/opt/stats-site}"
|
||||
DEST="${DEST:-/var/www/stats-site}"
|
||||
|
||||
# Hugo variables (mirror config.toml).
|
||||
SITE_TITLE='PSP Speedtest Stats'
|
||||
SITE_DESC='Метрики латентности и времени отклика двух geo-распределённых OpenSpeedTest нод. Snapshot обновляется каждые 10 минут.'
|
||||
|
||||
[ -d "$SRC" ] || { echo "src $SRC not found" >&2; exit 1; }
|
||||
|
||||
TMP=$(mktemp -d)
|
||||
trap "rm -rf $TMP" EXIT
|
||||
|
||||
# 1. Copy static/ verbatim
|
||||
cp -r "$SRC/static/." "$TMP/"
|
||||
|
||||
# 2. Render layouts/index.html with sed-substitution
|
||||
sed \
|
||||
-e "s|{{ \.Site\.Title }}|${SITE_TITLE}|g" \
|
||||
-e "s|{{ \.Site\.Params\.description }}|${SITE_DESC}|g" \
|
||||
"$SRC/layouts/index.html" > "$TMP/index.html"
|
||||
|
||||
# 3. Atomic rsync, preserving runtime data (snapshot.json) and ownership.
|
||||
# --delete removes files in DEST that aren't in TMP (cleans old assets),
|
||||
# --exclude protects data/ (snapshot generator owns that).
|
||||
rsync -a --delete \
|
||||
--exclude='data/snapshot.json' \
|
||||
--exclude='data/snapshot.json.tmp' \
|
||||
--chown=deploy:www-data \
|
||||
"$TMP/" "$DEST/"
|
||||
|
||||
echo "site built: $(find $DEST -type f | wc -l) files in $DEST"
|
||||
Reference in New Issue
Block a user