-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-in-ct.sh
More file actions
52 lines (42 loc) · 1.88 KB
/
Copy pathinstall-in-ct.sh
File metadata and controls
52 lines (42 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
# Run inside the LXC after files are staged at /opt/warzone-lobby-sentinel.
set -euo pipefail
INSTALL_ROOT="/opt/warzone-lobby-sentinel"
ENV_FILE="/etc/default/warzone-lobby-sentinel"
apt-get update -qq
apt-get install -y -qq ca-certificates curl >/dev/null
mkdir -p "$INSTALL_ROOT/bin" /etc/warzone-sentinel /var/lib/warzone-sentinel
chmod 700 /var/lib/warzone-sentinel
if [[ -x "$INSTALL_ROOT/bin/warzone-sentinel" ]]; then
echo "Using Rust binary at $INSTALL_ROOT/bin/warzone-sentinel"
chmod +x "$INSTALL_ROOT/bin/warzone-sentinel"
else
apt-get install -y -qq python3 python3-venv python3-pip >/dev/null
if [[ ! -d "$INSTALL_ROOT/.venv" ]]; then
python3 -m venv "$INSTALL_ROOT/.venv"
fi
"$INSTALL_ROOT/.venv/bin/pip" install -q -U pip
"$INSTALL_ROOT/.venv/bin/pip" install -q -r "$INSTALL_ROOT/requirements.txt"
fi
chmod +x "$INSTALL_ROOT/tools/run_automated.sh"
[[ -x "$INSTALL_ROOT/bin/warzone-sentinel" ]] && chmod +x "$INSTALL_ROOT/bin/warzone-sentinel"
mkdir -p /etc/warzone-sentinel /var/lib/warzone-sentinel
chmod 700 /var/lib/warzone-sentinel
if [[ ! -f "$ENV_FILE" ]]; then
install -m 0644 "$INSTALL_ROOT/warzone-lobby-sentinel.env.example" "$ENV_FILE"
fi
# Copy Firewalla API token from fleet secret if present (deploy host).
TOKEN_SRC="${WZ_TOKEN_SRC:-/root/.secrets/firewalla-api.env}"
if [[ -f "$TOKEN_SRC" ]]; then
grep -E '^FIREWALLA_API_TOKEN=' "$TOKEN_SRC" > /etc/warzone-sentinel/firewalla.token || true
chmod 600 /etc/warzone-sentinel/firewalla.token
fi
install -m 0644 "$INSTALL_ROOT/warzone-lobby-sentinel.service" \
/etc/systemd/system/warzone-lobby-sentinel.service
systemctl daemon-reload
systemctl enable --now warzone-lobby-sentinel.service
systemctl restart warzone-lobby-sentinel.service
sleep 2
systemctl is-active warzone-lobby-sentinel.service
curl -sf "http://127.0.0.1:${WZ_INGEST_PORT:-8098}/health" 2>/dev/null || true
echo ""