From 84ca12d507e21cfd99ea8b7e08699b24a2be141a Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Fri, 22 Nov 2024 14:42:22 +0800 Subject: [PATCH] uninstall improve --- install/uninstall.sh | 77 +++++++++++++++++++++----------------------- version.json | 1 + 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/install/uninstall.sh b/install/uninstall.sh index cc486d2e..5892c8dd 100644 --- a/install/uninstall.sh +++ b/install/uninstall.sh @@ -4,24 +4,6 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin # Export PATH export PATH - -# Command-line options -# ============================================================================== -# -# --cockpit -# Use the --cockpit option to remove cockpit: -# -# $ sudo sh install.sh --cockpit -# -# --files -# Use the --files option remove files have installed: -# -# $ sudo sh install.sh --files -# -# -# ============================================================================== - - install_path="/data/websoft9/source" systemd_path="/opt/websoft9/systemd" cockpit_plugin_path="/usr/share/cockpit" @@ -35,14 +17,44 @@ sudo systemctl disable websoft9 sudo systemctl stop websoft9 rm -rf /lib/systemd/system/websoft9.service - - remove_cockpit() { + echo -e "\n---Remove Cockpit---" sudo systemctl stop cockpit.socket cockpit - for package in $cockpit_packages; do - sudo pkcon remove $package -y || true - done + sudo systemctl disable cockpit.socket cockpit + + dnf --version >/dev/null 2>&1 + dnf_status=$? + + yum --version >/dev/null 2>&1 + yum_status=$? + + apt --version >/dev/null 2>&1 + apt_status=$? + + if [ $dnf_status -eq 0 ]; then + for pkg in $cockpit_packages + do + echo "Uninstalling $pkg" + sudo dnf remove -y "$pkg" > /dev/null || echo "$pkg failed to uninstall" + done + elif [ $yum_status -eq 0 ]; then + for pkg in $cockpit_packages + do + echo "Uninstalling $pkg" + sudo yum remove -y "$pkg" > /dev/null || echo "$pkg failed to uninstall" + done + elif [ $apt_status -eq 0 ]; then + export DEBIAN_FRONTEND=noninteractive + for pkg in $cockpit_packages + do + echo "Uninstalling $pkg" + sudo apt-get remove -y "$pkg" > /dev/null || echo "$pkg failed to uninstall" + done + else + echo "Neither apt,dnf nor yum found. Please install one of them and try again." + end + sudo rm -rf /etc/cockpit/* } @@ -51,22 +63,7 @@ remove_files() { sudo rm -rf $install_path/* $systemd_path/* $cockpit_plugin_path/* } -for arg in "$@" -do - case $arg in - --cockpit) - remove_cockpit - shift - ;; - --files) - remove_files - shift - ;; - *) - echo "Unknown argument: $arg" - exit 1 - ;; - esac -done +remove_cockpit +remove_files echo -e "\nCongratulations, Websoft9 uninstall is complete!" \ No newline at end of file diff --git a/version.json b/version.json index 847447ca..7880b22c 100644 --- a/version.json +++ b/version.json @@ -24,6 +24,7 @@ "7" ], "Oracle Linux": [ + "9", "8", "7" ],