diff --git a/Makefile b/Makefile index fe661c4..375945d 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,8 @@ install-utils: uninstall: rm -f $(DESTDIR)$(BINDIR)/nvfd rm -f $(DESTDIR)$(UNITDIR)/nvfd.service + rm -f $(DESTDIR)$(BINDIR)/nvfd-fan-control.sh + rm -f $(DESTDIR)$(UNITDIR)/nvfd-fan-control.service @echo "Config files preserved in $(CONFDIR). Remove manually if desired." uninstall-utils: diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 50f422b..4f72b84 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -2,19 +2,12 @@ set -e # Parse arguments -WITH_UTILS=false while [[ $# -gt 0 ]]; do case "$1" in - --with-utils) - WITH_UTILS=true - shift - ;; --help) - echo "Usage: sudo $(basename "$0") [OPTIONS]" + echo "Usage: sudo $(basename "$0")" echo - echo "Options:" - echo " --with-utils Also remove utility scripts (nvfd-fan-control.sh and service)" - echo " --help Show this help message" + echo "Uninstalls NVFD and any installed utilities." echo exit 0 ;; @@ -65,10 +58,10 @@ if grep -q 'alias igfc=' /etc/bash.bashrc 2>/dev/null; then sed -i '/alias igfc=/d' /etc/bash.bashrc fi -# Remove optional utilities if requested -if [ "$WITH_UTILS" = true ]; then - echo "Removing utility scripts..." - +# Auto-detect and remove utilities if installed +if [ -f /usr/local/bin/nvfd-fan-control.sh ] || [ -f /etc/systemd/system/nvfd-fan-control.service ]; then + echo "Detected installed utility scripts, removing..." + # Stop and disable fan-control service if running if systemctl is-active --quiet nvfd-fan-control.service 2>/dev/null; then systemctl stop nvfd-fan-control.service @@ -76,11 +69,11 @@ if [ "$WITH_UTILS" = true ]; then if systemctl is-enabled --quiet nvfd-fan-control.service 2>/dev/null; then systemctl disable nvfd-fan-control.service fi - + # Remove utility files rm -f /usr/local/bin/nvfd-fan-control.sh rm -f /etc/systemd/system/nvfd-fan-control.service - + systemctl daemon-reload fi