#!/bin/bash REPO_URL="http://gitea:3000/baphemot/proxmox-node-config.git" CLONE_DIR="/opt/proxmox-node-config" MARKER_FILE="$CLONE_DIR/.apply-done" if [ ! -d "$CLONE_DIR/.git" ]; then echo "==> Clonando repo desde $REPO_URL..." git clone "$REPO_URL" "$CLONE_DIR" else echo "==> Actualizando repo..." git -C "$CLONE_DIR" pull fi cd "$CLONE_DIR" || exit 1 if [ ! -f "$MARKER_FILE" ]; then echo "==> Ejecutando apply.sh por primera vez..." bash "$CLONE_DIR/apply.sh" touch "$MARKER_FILE" else echo "==> apply.sh ya fue ejecutado previamente, se omite." fi install_unit() { local service_name=$1 local timer_name=$2 if ! systemctl list-timers | grep -q "$timer_name"; then echo "==> Instalando $timer_name..." cp "$CLONE_DIR/systemd/$service_name" /etc/systemd/system/ cp "$CLONE_DIR/systemd/$timer_name" /etc/systemd/system/ systemctl daemon-reexec systemctl daemon-reload systemctl enable --now "$timer_name" else echo "==> $timer_name ya está instalado." fi } install_unit apply.service apply.timer install_unit arp-monitor.service arp-monitor.timer echo "==> Instalación y configuración completa."