# 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."