#!/bin/bash # Configura las rutas SYSTEMD_SERVICE="monitor_nfs.service" LOGROTATE_CONF="monitor_nfs" INITD_SERVICE="monitor_nfs" SYSTEMD_PATH="/etc/systemd/system" LOGROTATE_PATH="/etc/logrotate.d" INITD_PATH="/etc/init.d" SCRIPT_DEST="/usr/local/bin/monitor_nfs.sh" # Comprueba que se ejecuta como root if [[ $EUID -ne 0 ]]; then echo "Este script debe ejecutarse como root." exit 1 fi # Desinstala el servicio systemd si está presente if [ -f "$SYSTEMD_PATH/$SYSTEMD_SERVICE" ]; then echo "Deteniendo y desinstalando el servicio systemd..." systemctl stop "$SYSTEMD_SERVICE" systemctl disable "$SYSTEMD_SERVICE" rm -f "$SYSTEMD_PATH/$SYSTEMD_SERVICE" systemctl daemon-reload echo "Servicio systemd desinstalado." fi # Desinstala el servicio init.d si está presente if [ -f "$INITD_PATH/$INITD_SERVICE" ]; then echo "Deteniendo y desinstalando el servicio init.d..." service "$INITD_SERVICE" stop update-rc.d -f "$INITD_SERVICE" remove rm -f "$INITD_PATH/$INITD_SERVICE" echo "Servicio init.d desinstalado." fi # Desinstala el script de monitoreo if [ -f "$SCRIPT_DEST" ]; then echo "Desinstalando el script de monitoreo..." rm -f "$SCRIPT_DEST" echo "Script de monitoreo desinstalado." fi # Desinstala la configuración de logrotate if [ -f "$LOGROTATE_PATH/$LOGROTATE_CONF" ]; then echo "Desinstalando la configuración de logrotate..." rm -f "$LOGROTATE_PATH/$LOGROTATE_CONF" echo "Configuración de logrotate desinstalada." fi echo "Desinstalación completada con éxito."