host-metrics/scripts/start.sh
2026-09-17 22:31:35 +02:00

28 lines
878 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
[[ -f .env ]] || cp .env.example .env
python3 - <<'PY'
from pathlib import Path
import secrets
p = Path('.env')
if not any(line.startswith('DATASOURCE_MASTER_KEY=') and line.split('=', 1)[1].strip() for line in p.read_text().splitlines()):
with p.open('a') as f:
f.write('\nDATASOURCE_MASTER_KEY=' + secrets.token_hex(16) + '\n')
p.chmod(0o600)
PY
docker compose config --quiet
docker compose pull
docker compose up -d
echo 'Waiting for Dashboards...'
for ((i=0; i<120; i++)); do
if curl -fsS http://127.0.0.1:5601/api/status >/dev/null; then
echo 'Stack ready. Install the native agent, then import dashboards/host-metrics.ndjson.'
exit 0
fi
sleep 5
done
docker compose ps -a
echo 'Startup did not finish in 10 minutes. Run docker compose logs --tail=100.' >&2
exit 1