fix: Linux install.sh erstellt (systemd, Debian/Proxmox), Makefile nutzt plattformspezifische install.sh
This commit is contained in:
parent
9cb504fea1
commit
ae1a8617f5
7
Makefile
7
Makefile
@ -43,11 +43,12 @@ release: agent agent-linux updater-freebsd updater-linux
|
||||
@echo "==> Creating release bundles v$(VERSION)..."
|
||||
@mkdir -p build/release
|
||||
@# FreeBSD Bundle (Agent + Updater + install.sh)
|
||||
@cp opnsense-plugin/install.sh build/install.sh
|
||||
@cd build && zip -j release/rmm-freebsd-$(VERSION).zip rmm-agent rmm-updater-freebsd 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-freebsd.sh
|
||||
@echo "==> build/release/rmm-freebsd-$(VERSION).zip erstellt"
|
||||
@# 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 ""
|
||||
@echo "Release v$(VERSION) fertig:"
|
||||
|
||||
@ -1,46 +1,144 @@
|
||||
#!/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
|
||||
|
||||
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
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root"
|
||||
echo "========================================"
|
||||
echo " RMM Agent Linux Installer"
|
||||
echo "========================================"
|
||||
|
||||
# Root-Check
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "FEHLER: Bitte als root ausfuehren (sudo bash install.sh)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create directories
|
||||
mkdir -p /etc/rmm
|
||||
mkdir -p /usr/local/bin
|
||||
|
||||
# Copy binary
|
||||
if [ ! -f "rmm-agent-linux" ]; then
|
||||
echo "Error: rmm-agent-linux binary not found in current directory"
|
||||
# Binaries pruefen
|
||||
if [ ! -f "${AGENT_BIN}" ]; then
|
||||
echo "FEHLER: ${AGENT_BIN} nicht gefunden"
|
||||
echo "ZIP-Inhalt muss 'rmm-agent-linux' enthalten"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp rmm-agent-linux /usr/local/bin/rmm-agent-linux
|
||||
chmod +x /usr/local/bin/rmm-agent-linux
|
||||
# Alte Dienste stoppen
|
||||
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
|
||||
cp rmm-agent-linux.service /etc/systemd/system/
|
||||
# Binaries installieren
|
||||
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 "/etc/rmm/config.yaml" ]; then
|
||||
cp config.yaml.example /etc/rmm/config.yaml
|
||||
echo "==> Created /etc/rmm/config.yaml - please edit with your backend URL and API key"
|
||||
if [ -f "${UPDATER_BIN}" ]; then
|
||||
cp "${UPDATER_BIN}" "${INSTALL_DIR}/rmm-updater"
|
||||
chmod +x "${INSTALL_DIR}/rmm-updater"
|
||||
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
|
||||
|
||||
# Reload systemd and enable service
|
||||
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 "Next steps:"
|
||||
echo "1. Edit /etc/rmm/config.yaml with your backend URL and API key"
|
||||
echo "2. Start the service: systemctl start rmm-agent-linux"
|
||||
echo "3. Check status: systemctl status rmm-agent-linux"
|
||||
echo "4. View logs: journalctl -u rmm-agent-linux -f"
|
||||
echo " Config noch nicht angepasst — Agent wird NICHT gestartet."
|
||||
echo ""
|
||||
echo " Bitte Config bearbeiten und dann starten:"
|
||||
echo " nano ${CONFIG_FILE}"
|
||||
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 "========================================"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user