Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
95 lines (84 loc) · 3.54 KB
/
Copy pathinstall.sh
File metadata and controls
95 lines (84 loc) · 3.54 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
# Install the topology dashboard server as a systemd service on THIS Linux host.
# Idempotent — re-run (or ./update.sh, which fetches the latest first) to update.
# Remove with ./uninstall.sh.
#
# ./install.sh
# TOPO_TOKEN=secret ./install.sh # require a shared token from agents
set -euo pipefail
DIR="$(cd "$(dirname "$0")" && pwd)" # repo root (this script lives here)
RUN_USER="$(id -un)"
SUDO=""
if [ "$(id -u)" -ne 0 ]; then
command -v sudo >/dev/null 2>&1 && SUDO=sudo || { echo "not root and no sudo — cannot install"; exit 1; }
fi
# Unraid runs the dashboard as a container now (Community Applications), so this
# script no longer installs the flash-launcher + 'go' script setup it used to.
# ./uninstall.sh still removes that older install — see it for the migration.
if [ -f /etc/unraid-version ]; then
cat <<'EOT'
Unraid detected — run the dashboard as a container instead of installing it here.
Community Applications: search "topographer" and hit Install
or by hand: docker run -d --name topographer --network host \
-v /mnt/user/appdata/topographer:/app/out \
ghcr.io/fugginold/topographer:latest
Appdata is the same directory the old native install used, so saved topologies
and widgets carry over untouched.
Already have the older native install? ./uninstall.sh removes it (flash launcher
+ the boot 'go' hook) and leaves your data in place.
EOT
exit 1
fi
command -v systemctl >/dev/null 2>&1 || {
echo "no systemd here — run the dashboard directly:"
echo " python3 $DIR/renderers/html/topo_server.py"; exit 1; }
# deps: only what's missing (the server is stdlib; PyYAML is the one Python dep)
have() { command -v "$1" >/dev/null 2>&1; }
need=""
have python3 || need="$need python3"
python3 -c "import yaml" >/dev/null 2>&1 || need="$need python3-yaml"
if [ -n "$need" ]; then
if have apt-get; then
echo "installing:$need"
$SUDO apt-get update -qq && $SUDO apt-get install -y -qq $need || echo "warn: could not install:$need"
else
echo "warn: missing (install manually):$need"
fi
fi
UNIT=/etc/systemd/system/topo-server.service
echo "installing service -> $UNIT"
$SUDO tee "$UNIT" >/dev/null <<EOF
[Unit]
Description=Topographer dashboard server (fleet dashboard + ingest/telemetry API)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=$RUN_USER
WorkingDirectory=$DIR
ExecStart=/usr/bin/python3 $DIR/renderers/html/topo_server.py
Restart=always
RestartSec=10
${TOPO_TOKEN:+Environment=TOPO_TOKEN=$TOPO_TOKEN}
[Install]
WantedBy=multi-user.target
EOF
$SUDO systemctl daemon-reload
$SUDO systemctl enable topo-server >/dev/null 2>&1 || true
$SUDO systemctl restart topo-server
# open the port where a firewall is present (best effort)
if have ufw; then
$SUDO ufw allow 8770/tcp >/dev/null 2>&1 || true
elif have firewall-cmd; then
$SUDO firewall-cmd --permanent --add-port=8770/tcp >/dev/null 2>&1 && $SUDO firewall-cmd --reload >/dev/null 2>&1 || true
fi
# this host's own LAN IP — the address to open the dashboard and point agents at
IP="$(ip route get 1.1.1.1 2>/dev/null | sed -n 's/.* src \([0-9.][0-9.]*\).*/\1/p' | head -1)"
[ -z "$IP" ] && IP="$(hostname -I 2>/dev/null | awk '{print $1}')"
echo
echo "✓ topo-server running (starts on boot)."
echo " dashboard: http://${IP:-localhost}:8770"
echo " point agents: TOPO_SERVER=http://${IP:-<this-host-ip>}:8770"
echo " logs: journalctl -u topo-server -f"
echo " update: ./update.sh"
echo " remove: ./uninstall.sh"