fix: Linux install.sh erstellt (systemd, Debian/Proxmox), Makefile nutzt plattformspezifische install.sh

This commit is contained in:
cynfo3000 2026-03-06 22:20:20 +01:00
parent 9cb504fea1
commit ae1a8617f5
2 changed files with 135 additions and 36 deletions

View File

@ -43,11 +43,12 @@ release: agent agent-linux updater-freebsd updater-linux
@echo "==> Creating release bundles v$(VERSION)..." @echo "==> Creating release bundles v$(VERSION)..."
@mkdir -p build/release @mkdir -p build/release
@# FreeBSD Bundle (Agent + Updater + install.sh) @# FreeBSD Bundle (Agent + Updater + install.sh)
@cp opnsense-plugin/install.sh build/install.sh @cp opnsense-plugin/install.sh build/install-freebsd.sh
@cd build && zip -j release/rmm-freebsd-$(VERSION).zip rmm-agent rmm-updater-freebsd install.sh @cd build && zip -j release/rmm-freebsd-$(VERSION).zip rmm-agent rmm-updater-freebsd install-freebsd.sh
@echo "==> build/release/rmm-freebsd-$(VERSION).zip erstellt" @echo "==> build/release/rmm-freebsd-$(VERSION).zip erstellt"
@# Linux Bundle (Agent + Updater + install.sh) @# Linux Bundle (Agent + Updater + install.sh)
@cd build && zip -j release/rmm-linux-$(VERSION).zip rmm-agent-linux rmm-updater-linux install.sh @cp agent-linux/install.sh build/install-linux.sh
@cd build && zip -j release/rmm-linux-$(VERSION).zip rmm-agent-linux rmm-updater-linux install-linux.sh
@echo "==> build/release/rmm-linux-$(VERSION).zip erstellt" @echo "==> build/release/rmm-linux-$(VERSION).zip erstellt"
@echo "" @echo ""
@echo "Release v$(VERSION) fertig:" @echo "Release v$(VERSION) fertig:"

View File

@ -1,46 +1,144 @@
#!/bin/bash #!/bin/bash
# RMM Agent Linux Installation Script #
# RMM Agent Linux Installer
# Unterstuetzt: Debian, Ubuntu, Proxmox VE
#
# Verwendung nach ZIP-Download:
# unzip rmm-linux-*.zip
# bash install.sh
#
set -e set -e
echo "==> Installing RMM Agent Linux" BASEDIR="$(cd "$(dirname "$0")" && pwd)"
AGENT_BIN="${BASEDIR}/rmm-agent-linux"
UPDATER_BIN="${BASEDIR}/rmm-updater-linux"
INSTALL_DIR="/usr/local/bin"
CONFIG_DIR="/etc/rmm"
CONFIG_FILE="${CONFIG_DIR}/config.yaml"
AGENT_ID_FILE="${CONFIG_DIR}/agent_id"
# Check if running as root echo "========================================"
if [[ $EUID -ne 0 ]]; then echo " RMM Agent Linux Installer"
echo "This script must be run as root" echo "========================================"
# Root-Check
if [ "$(id -u)" -ne 0 ]; then
echo "FEHLER: Bitte als root ausfuehren (sudo bash install.sh)"
exit 1 exit 1
fi fi
# Create directories # Binaries pruefen
mkdir -p /etc/rmm if [ ! -f "${AGENT_BIN}" ]; then
mkdir -p /usr/local/bin echo "FEHLER: ${AGENT_BIN} nicht gefunden"
echo "ZIP-Inhalt muss 'rmm-agent-linux' enthalten"
# Copy binary
if [ ! -f "rmm-agent-linux" ]; then
echo "Error: rmm-agent-linux binary not found in current directory"
exit 1 exit 1
fi fi
cp rmm-agent-linux /usr/local/bin/rmm-agent-linux # Alte Dienste stoppen
chmod +x /usr/local/bin/rmm-agent-linux echo "[1/5] Alte Dienste stoppen..."
systemctl stop rmm-agent 2>/dev/null || true
systemctl stop rmm-updater 2>/dev/null || true
# Copy service file # Binaries installieren
cp rmm-agent-linux.service /etc/systemd/system/ echo "[2/5] Binaries installieren..."
cp "${AGENT_BIN}" "${INSTALL_DIR}/rmm-agent"
chmod +x "${INSTALL_DIR}/rmm-agent"
echo " rmm-agent -> ${INSTALL_DIR}/rmm-agent"
# Create example config if it doesn't exist if [ -f "${UPDATER_BIN}" ]; then
if [ ! -f "/etc/rmm/config.yaml" ]; then cp "${UPDATER_BIN}" "${INSTALL_DIR}/rmm-updater"
cp config.yaml.example /etc/rmm/config.yaml chmod +x "${INSTALL_DIR}/rmm-updater"
echo "==> Created /etc/rmm/config.yaml - please edit with your backend URL and API key" echo " rmm-updater -> ${INSTALL_DIR}/rmm-updater"
fi
# Config anlegen (wenn noch nicht vorhanden)
echo "[3/5] Konfiguration anlegen..."
mkdir -p "${CONFIG_DIR}"
if [ ! -f "${CONFIG_FILE}" ]; then
cat > "${CONFIG_FILE}" << 'CFGEOF'
backend_url: "https://BACKEND_IP:8443"
api_key: "DEIN_API_KEY"
interval_seconds: 60
agent_name: ""
insecure: true
CFGEOF
echo " Config erstellt: ${CONFIG_FILE}"
echo " WICHTIG: Bitte Backend-URL und API-Key eintragen!"
else
echo " Config bereits vorhanden — unveraendert"
fi
# Systemd Services
echo "[4/5] Systemd Services installieren..."
cat > /etc/systemd/system/rmm-agent.service << 'SVCEOF'
[Unit]
Description=RMM Agent
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/rmm-agent -config /etc/rmm/config.yaml
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=rmm-agent
[Install]
WantedBy=multi-user.target
SVCEOF
if [ -f "${INSTALL_DIR}/rmm-updater" ]; then
cat > /etc/systemd/system/rmm-updater.service << 'SVCEOF'
[Unit]
Description=RMM Agent Updater
After=network-online.target rmm-agent.service
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/rmm-updater
Restart=always
RestartSec=30
StandardOutput=journal
StandardError=journal
SyslogIdentifier=rmm-updater
[Install]
WantedBy=multi-user.target
SVCEOF
fi fi
# Reload systemd and enable service
systemctl daemon-reload systemctl daemon-reload
systemctl enable rmm-agent-linux systemctl enable rmm-agent
[ -f "${INSTALL_DIR}/rmm-updater" ] && systemctl enable rmm-updater || true
echo "==> Installation complete!" echo " Systemd Services registriert"
# Start (nur wenn Config bereits ausgefuellt)
echo "[5/5] Dienste starten..."
if grep -q "BACKEND_IP\|DEIN_API_KEY" "${CONFIG_FILE}" 2>/dev/null; then
echo "" echo ""
echo "Next steps:" echo " Config noch nicht angepasst — Agent wird NICHT gestartet."
echo "1. Edit /etc/rmm/config.yaml with your backend URL and API key" echo ""
echo "2. Start the service: systemctl start rmm-agent-linux" echo " Bitte Config bearbeiten und dann starten:"
echo "3. Check status: systemctl status rmm-agent-linux" echo " nano ${CONFIG_FILE}"
echo "4. View logs: journalctl -u rmm-agent-linux -f" echo " systemctl start rmm-agent"
[ -f "${INSTALL_DIR}/rmm-updater" ] && echo " systemctl start rmm-updater" || true
else
systemctl start rmm-agent
[ -f "${INSTALL_DIR}/rmm-updater" ] && systemctl start rmm-updater || true
echo " Dienste gestartet"
fi
echo ""
echo "========================================"
echo " RMM Agent Linux installiert!"
echo ""
echo " Config: ${CONFIG_FILE}"
echo " Logs: journalctl -u rmm-agent -f"
echo " Status: systemctl status rmm-agent"
echo "========================================"