Add 4 and update 2 files
This commit is contained in:
43
tailscale/install_monitor.sh
Executable file
43
tailscale/install_monitor.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# Install monitoring script for Tailscale
|
||||
# This sets up a cron job to check and recover Tailscale connection
|
||||
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
|
||||
echo "Setting up Tailscale monitoring..."
|
||||
|
||||
# Copy healthcheck script to a safe location
|
||||
MONITOR_SCRIPT="/opt/tailscale-monitor.sh"
|
||||
sudo cp "${CONFIG_PATH}/healthcheck.sh" "$MONITOR_SCRIPT"
|
||||
sudo chmod +x "$MONITOR_SCRIPT"
|
||||
|
||||
# Create systemd service for monitoring (more reliable than cron)
|
||||
cat << 'EOF' | sudo tee /etc/systemd/system/tailscale-monitor.service
|
||||
[Unit]
|
||||
Description=Tailscale Connection Monitor
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/bin/bash /opt/tailscale-monitor.sh
|
||||
Restart=always
|
||||
RestartSec=300
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Enable and start the monitor service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable tailscale-monitor.service
|
||||
sudo systemctl start tailscale-monitor.service
|
||||
|
||||
echo "Tailscale monitoring service installed and started"
|
||||
|
||||
# Also add a cron job as backup
|
||||
(crontab -l 2>/dev/null | grep -v tailscale-monitor; echo "*/5 * * * * /opt/tailscale-monitor.sh >> /var/log/tailscale-monitor.log 2>&1") | crontab -
|
||||
|
||||
echo "Backup cron job added (runs every 5 minutes)"
|
Reference in New Issue
Block a user