Skills von blackbook: network/headscale-vpn

This commit is contained in:
2026-11-05 22:16:07 +01:00
parent 8ec5cb6b6c
commit e069d995d7
3 changed files with 107 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
# headscale-probe.sh - Verification script for headscale server status and socket existence
set -e
CONFIG_FILE="${1:-/tmp/headscale_config.yaml}"
HEADSCALE_BIN="/tmp/headscale"
echo "=== Headscale Server Probe ==="
echo "Config file: $CONFIG_FILE"
echo "Binary: $HEADSCALE_BIN"
# Check if config exists
if [ ! -f "$CONFIG_FILE" ]; then
echo "ERROR: Config file not found: $CONFIG_FILE"
exit 1
fi
# Check if headscale binary exists
if [ ! -x "$HEADSCALE_BIN" ]; then
echo "ERROR: Headscale binary not found or not executable: $HEADSCALE_BIN"
exit 1
fi
# Check server process
echo "\n--- Server Process Check ---"
if pgrep -f "headscale serve" > /dev/null 2>&1; then
echo "Headscale server process is running"
else
echo "Headscale server process is NOT running"
fi
# Check socket existence
SOCKET_PATH="/var/run/headscale/headscale.sock"
echo "\n--- Socket Check ---"
if [ -S "$SOCKET_PATH" ]; then
echo "Socket exists at $SOCKET_PATH"
else
echo "Socket NOT found at $SOCKET_PATH"
fi
# Check config file readability
echo "\n--- Config File Check ---"
if headscale configtest -c "$CONFIG_FILE" 2>/dev/null; then
echo "Config test passed"
else
echo "Config test FAILED"
fi
# List users if server is running
echo "\n--- User List ---"
if pgrep -f "headscale serve" > /dev/null 2>&1; then
$HEADSCALE_BIN -c "$CONFIG_FILE" users list --output json 2>/dev/null || echo "Could not list users (server may not be responding)"
else
echo "Server not running - cannot list users"
fi
echo "\n=== Probe Complete ==="