#!/bin/sh # Pulse agent installer. Usage: curl -fsSL https://visionstack.space/install.sh | sudo sh -s -- # Installs a read-only agent that runs once a minute via a systemd timer. # Remove with: sudo sh -c 'systemctl disable --now pulse-agent.timer; rm -rf /etc/pulse /var/lib/pulse /usr/local/bin/pulse-agent /etc/systemd/system/pulse-agent.*' set -eu TOKEN="${1:-}" URL="${PULSE_URL:-https://visionstack.space}" [ -n "$TOKEN" ] || { echo "Usage: curl -fsSL $URL/install.sh | sudo sh -s -- " >&2; exit 1; } [ "$(id -u)" = 0 ] || { echo "Please run as root (sudo)." >&2; exit 1; } command -v python3 >/dev/null || { echo "python3 is required." >&2; exit 1; } command -v systemctl >/dev/null || { echo "systemd is required." >&2; exit 1; } echo "Installing Pulse agent..." curl -fsSL "$URL/agent/pulse-agent.py" -o /usr/local/bin/pulse-agent chmod 755 /usr/local/bin/pulse-agent mkdir -p /etc/pulse /var/lib/pulse umask 077 printf 'PULSE_URL=%s\nPULSE_TOKEN=%s\n' "$URL" "$TOKEN" > /etc/pulse/config # Certificate checks: start from the hostnames nginx serves, if any. Edit freely. if [ ! -f /etc/pulse/domains ]; then { echo "# One hostname per line; Pulse checks TLS certificate expiry hourly." grep -RhoE '^\s*server_name\s+[^;]+' /etc/nginx 2>/dev/null \ | sed -E 's/^\s*server_name\s+//' | tr ' ' '\n' \ | grep -E '^[A-Za-z0-9.-]+\.[A-Za-z]{2,}$' | grep -v '^www\.' | sort -u | head -40 } > /etc/pulse/domains || true fi cat > /etc/systemd/system/pulse-agent.service <<'EOF' [Unit] Description=Pulse health snapshot (read-only) After=network-online.target [Service] Type=oneshot ExecStart=/usr/bin/python3 /usr/local/bin/pulse-agent Nice=10 IOSchedulingClass=idle TimeoutStartSec=120 EOF cat > /etc/systemd/system/pulse-agent.timer <<'EOF' [Unit] Description=Run the Pulse agent every minute [Timer] OnBootSec=30s OnUnitActiveSec=60s AccuracySec=5s [Install] WantedBy=timers.target EOF systemctl daemon-reload systemctl enable --now pulse-agent.timer >/dev/null systemctl start pulse-agent.service || true echo "Done. Your server should appear in the Pulse dashboard within a minute."