32 lines
1.0 KiB
Bash
32 lines
1.0 KiB
Bash
#!/bin/bash
|
|
# Install Blair fleet monitor on pve. Run as root.
|
|
set -euo pipefail
|
|
|
|
BASE_URL="${BLAIR_MONITOR_BASE_URL:-https://git.easygoingaming.com/Davoguha/blair-pve-sync-temp/raw/main}"
|
|
TARGET='/usr/local/sbin/monitor-blair-fleet.sh'
|
|
SHARE_COPY='/tank/blair-share/tools/golden/host/monitor-blair-fleet.sh'
|
|
CRON='/etc/cron.d/blair-fleet-monitor'
|
|
LOG='/var/log/blair-fleet-monitor.jsonl'
|
|
|
|
echo "=== Download monitor script ==="
|
|
curl -fsSL "$BASE_URL/monitor-blair-fleet.sh" -o "$TARGET"
|
|
chmod +x "$TARGET"
|
|
sed -i 's/\r$//' "$TARGET" 2>/dev/null || true
|
|
|
|
mkdir -p "$(dirname "$SHARE_COPY")" /tank/blair-share/fleet/monitor
|
|
cp -f "$TARGET" "$SHARE_COPY"
|
|
chmod +x "$SHARE_COPY"
|
|
|
|
echo "=== cron (every 5 min) ==="
|
|
printf '%s\n' "*/5 * * * * root $TARGET >> /var/log/blair-fleet-monitor-cron.log 2>&1" > "$CRON"
|
|
chmod 644 "$CRON"
|
|
cat "$CRON"
|
|
|
|
echo "=== test run ==="
|
|
"$TARGET"
|
|
echo "=== latest snapshot ==="
|
|
head -c 2000 /tank/blair-share/fleet/monitor/latest.json; echo
|
|
echo "=== log tail ==="
|
|
tail -3 "$LOG" 2>/dev/null || true
|
|
echo "=== done ==="
|