#!/bin/bash # LXS - Uptime Kuma Installation Script # Description: Install and manage Uptime Kuma monitoring tool # Author: LXS # Date: 2025 # Load LXS common library (colors, separator, run_spinner, loggers, helpers) LXS_RAW_BASE="${LXS_RAW_BASE:-https://git.hyko.cx/hykocx/lxs/raw/branch/main}" _lib=$(curl -fsSL "${LXS_RAW_BASE}/lib/common.sh") || { echo "Failed to fetch lib/common.sh" >&2; exit 1; } eval "$_lib" unset _lib export LXS_LOG_FILE="/tmp/lxs_uptime_kuma.log" require_root "$0" "$@" # ═══════════════════════════════════════════════════════════════════════════ # Configuration # ═══════════════════════════════════════════════════════════════════════════ INSTALL_DIR="/opt/uptime-kuma" SERVICE_NAME="uptime-kuma" PORT=3001 # ═══════════════════════════════════════════════════════════════════════════ # Helper Functions # ═══════════════════════════════════════════════════════════════════════════ is_installed() { [ -d "$INSTALL_DIR" ] && systemctl list-unit-files | grep -q "$SERVICE_NAME.service" } # ═══════════════════════════════════════════════════════════════════════════ # Installation Functions # ═══════════════════════════════════════════════════════════════════════════ install_dependencies() { apt_noninteractive run_spinner "Updating system..." "apt update -qq && apt upgrade -y -qq -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'" run_spinner "Installing dependencies..." "apt install -y -qq curl git wget -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'" run_spinner "Adding Node.js repository..." "curl -fsSL https://deb.nodesource.com/setup_20.x | bash -" run_spinner "Installing Node.js..." "apt install -y -qq nodejs -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'" } configure_domain_ssl() { local domain=$1 local email=$2 run_spinner "Installing Nginx..." "apt install -y -qq nginx -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'" run_spinner "Installing Certbot..." "apt install -y -qq certbot python3-certbot-nginx -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'" cat > /etc/nginx/sites-available/$domain </dev/null } # ═══════════════════════════════════════════════════════════════════════════ # Main Installation # ═══════════════════════════════════════════════════════════════════════════ install_uptime_kuma() { local start_time=$(date +%s) # Configure non-interactive mode globally export DEBIAN_FRONTEND=noninteractive export NEEDRESTART_MODE=a export NEEDRESTART_SUSPEND=1 echo -e "${WHITE}${BOLD}UPTIME KUMA INSTALLATION${NC}\n" if is_installed; then echo -e "${YELLOW}Uptime Kuma is already installed!${NC}" return 0 fi require_disk_space 1024 || return 1 echo "[1/4] Installing dependencies..." install_dependencies echo "" echo "[2/4] Cloning repository..." run_spinner "Downloading from GitHub..." "git clone https://github.com/louislam/uptime-kuma.git '$INSTALL_DIR'" echo "" echo "[3/4] Installing Uptime Kuma..." cd "$INSTALL_DIR" run_spinner "Running npm setup..." "npm run setup" echo "" echo "[4/4] Creating service..." cat > /etc/systemd/system/$SERVICE_NAME.service <