From 0e785416369f51ad6eaa0740c09de0887b7edae9 Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 18 Apr 2026 17:59:24 +0100 Subject: [PATCH] Added first version of the script --- UptimeKuma-Monitor-Setup.sh | 98 +++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 UptimeKuma-Monitor-Setup.sh diff --git a/UptimeKuma-Monitor-Setup.sh b/UptimeKuma-Monitor-Setup.sh new file mode 100755 index 0000000..66b1f10 --- /dev/null +++ b/UptimeKuma-Monitor-Setup.sh @@ -0,0 +1,98 @@ +#!/bin/bash + +# Monitor Check-in Setup Script +# This script sets up automated URL check-ins with systemd + +set -e # Exit on error + +# Check if running as root +if [[ $EUID -ne 0 ]]; then + echo "Error: This script must be run as root" + echo "Please run with: sudo $0" + exit 1 +fi + +echo "==========================================" +echo "Monitor Check-in Setup Script" +echo "==========================================" +echo "" + +# Prompt for endpoint URL +read -p "Enter the endpoint URL (e.g., https://example.com/your-endpoint): " endpoint_url + +# Validate URL format +if [[ ! "$endpoint_url" =~ ^https?:// ]]; then + echo "Error: URL must start with http:// or https://" + exit 1 +fi + +# Create the monitor script +echo "Creating monitor script at /opt/monitor_checkin.sh..." +tee /opt/monitor_checkin.sh > /dev/null < /dev/null 2>&1; do + echo "Network not ready, waiting..." + sleep 5 +done + +echo "Network is ready. Script started. Calling URL every 55 seconds..." + +while true; do + curl -s "\$url" > /dev/null + echo "Called \$url at \$(date '+%Y-%m-%d %H:%M:%S')" >> /var/log/call-url.log + sleep \$interval +done +EOF + +# Make the script executable +echo "Making script executable..." +chmod +x /opt/monitor_checkin.sh + +# Create the systemd service +echo "Creating systemd service..." +tee /etc/systemd/system/monitor_checkin.service > /dev/null <