From a7d63a72df540765e8d99c14668b995c4c8a4b25 Mon Sep 17 00:00:00 2001 From: admManuel Date: Sat, 28 Jun 2025 06:06:56 +0000 Subject: [PATCH] Add roles/install_ngs-pulsar/templates/uninstall.sh.j2 --- .../templates/uninstall.sh.j2 | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 roles/install_ngs-pulsar/templates/uninstall.sh.j2 diff --git a/roles/install_ngs-pulsar/templates/uninstall.sh.j2 b/roles/install_ngs-pulsar/templates/uninstall.sh.j2 new file mode 100644 index 0000000..5639f23 --- /dev/null +++ b/roles/install_ngs-pulsar/templates/uninstall.sh.j2 @@ -0,0 +1,71 @@ +# roles/install_ngs-pulsar/templates/uninstall.sh.j2 +#!/bin/bash + +# Enginsight Pulsar Deinstallations-Skript + +echo "Stoppe Enginsight Pulsar Service..." + +# Init-System erkennen und Service stoppen +if command -v systemctl >/dev/null 2>&1; then + # SystemD + echo "SystemD erkannt - stoppe und deaktiviere Service..." + + # Erst clear-shield ausführen, solange die Binary noch existiert + if [ -x "{{ pulsar_install_path }}/{{ pulsar_binary_name }}" ]; then + echo "Führe clear-shield aus..." + {{ pulsar_install_path }}/{{ pulsar_binary_name }} -clear-shield 2>/dev/null || true + fi + + systemctl stop enginsight-pulsar 2>/dev/null || true + systemctl disable enginsight-pulsar 2>/dev/null || true + rm -f /etc/systemd/system/enginsight-pulsar.service + systemctl daemon-reload + systemctl reset-failed enginsight-pulsar 2>/dev/null || true + +elif command -v rc-service >/dev/null 2>&1; then + # OpenRC + echo "OpenRC erkannt - stoppe und deaktiviere Service..." + + # Erst clear-shield ausführen, solange die Binary noch existiert + if [ -x "{{ pulsar_install_path }}/{{ pulsar_binary_name }}" ]; then + echo "Führe clear-shield aus..." + {{ pulsar_install_path }}/{{ pulsar_binary_name }} -clear-shield 2>/dev/null || true + fi + + rc-service enginsight-pulsar stop 2>/dev/null || true + rc-update del enginsight-pulsar 2>/dev/null || true + rm -f /etc/init.d/enginsight-pulsar + +elif command -v service >/dev/null 2>&1; then + # SysV Init oder andere + echo "Legacy Init-System erkannt - stoppe Service..." + + # Erst clear-shield ausführen, solange die Binary noch existiert + if [ -x "{{ pulsar_install_path }}/{{ pulsar_binary_name }}" ]; then + echo "Führe clear-shield aus..." + {{ pulsar_install_path }}/{{ pulsar_binary_name }} -clear-shield 2>/dev/null || true + fi + + service enginsight-pulsar stop 2>/dev/null || true + update-rc.d -f enginsight-pulsar remove 2>/dev/null || true + chkconfig enginsight-pulsar off 2>/dev/null || true + rm -f /etc/init.d/enginsight-pulsar +else + echo "Warnung: Konnte Init-System nicht erkennen. Manuelles Stoppen des Services erforderlich." + # Trotzdem clear-shield versuchen + if [ -x "{{ pulsar_install_path }}/{{ pulsar_binary_name }}" ]; then + echo "Führe clear-shield aus..." + {{ pulsar_install_path }}/{{ pulsar_binary_name }} -clear-shield 2>/dev/null || true + fi +fi + +echo "Lösche Installationsverzeichnis..." +rm -rf "{{ pulsar_install_path }}" + +echo "Lösche übergeordnetes Enginsight-Verzeichnis falls leer..." +rmdir /opt/enginsight 2>/dev/null || true + +echo "Lösche Log-Verzeichnis..." +rm -rf /var/log/enginsight + +echo "Enginsight Pulsar wurde erfolgreich deinstalliert." \ No newline at end of file