From 272502473bbaf77b6140576a910e2bb8331f1700 Mon Sep 17 00:00:00 2001 From: b068931cc450442b63f5b3d276ea4297 <77171083+b068931cc450442b63f5b3d276ea4297@users.noreply.github.com> Date: Mon, 15 Jan 2024 23:25:04 +0100 Subject: [PATCH] fix autoremove for uninstall.sh --- install.sh | 12 ++++----- uninstall.sh | 6 ++--- uninstall.sh.save | 65 +++++++++++++++++++++++++++++++++++++++++++++++ update.sh | 2 +- 4 files changed, 74 insertions(+), 11 deletions(-) create mode 100755 uninstall.sh.save diff --git a/install.sh b/install.sh index 3683ebd..8b525eb 100644 --- a/install.sh +++ b/install.sh @@ -7,11 +7,11 @@ LOCALES=(en fr es ru pt de it) welcome_screen() { cat << "EOF" - __ _ __ _ _ - (_ |_) \_/ /__ | | /\ |_) | \ - __) | | \_| |_| /--\ | \ |_/ - -SpyGuard is a fork of TinyCheck, developped by Kaspersky. + __ _ __ _ _ + (_ |_) \_/ /__ | | /\ |_) | \ + __) | | \_| |_| /--\ | \ |_/ + +SpyGuard is a fork of TinyCheck, developped by Kaspersky. ----- EOF @@ -251,5 +251,3 @@ else feeding_iocs cleaning fi - - diff --git a/uninstall.sh b/uninstall.sh index 4c8bf63..1b93c54 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -26,17 +26,17 @@ delete_packages(){ "dnsutils" "suricata" "sqlite3") - + echo -n "[?] Do you want to remove the installed packages? (Yes/no) " read answer if [[ "$answer" =~ ^([yY][eE][sS]|[yY])$ ]] then for pkg in "${pkgs[@]}" - do + do apt -y remove $pkg && apt -y purge $pkg done fi - apt autoremove &> /dev/null + apt autoremove &> /dev/null -y } update_hostname(){ diff --git a/uninstall.sh.save b/uninstall.sh.save new file mode 100755 index 0000000..cd24983 --- /dev/null +++ b/uninstall.sh.save @@ -0,0 +1,65 @@ + +delete_folder(){ + echo "[+] Deleting SpyGuard folders" + rm -rf /usr/share/spyguard/ +} + +delete_services(){ + echo "[+] Deleting SpyGuard services" + + systemctl disable spyguard-frontend &> /dev/null + systemctl disable spyguard-backend &> /dev/null + systemctl disable spyguard-watchers &> /dev/null + + rm /lib/systemd/system/spyguard-frontend.service + rm /lib/systemd/system/spyguard-backend.service + rm /lib/systemd/system/spyguard-watchers.service +} + +deleting_icon(){ + echo "[+] Deleting desktop icon" + rm "/home/${SUDO_USER}/Desktop/spyguard.desktop" +} + +delete_packages(){ + pkgs=("tshark" + "dnsutils" + "suricata" + "sqlite3") + + echo -n "[?] Do you want to remove the installed packages? (Yes/no) " + read answer + if [[ "$answer" =~ ^([yY][eE][sS]|[yY])$ ]] + then + for pkg in "${pkgs[@]}" + do apt -y remove $pkg && apt -y purge $pkg + done + apt autoremove &> /dev/null + fi +} + +update_hostname(){ + echo -n "[?] Please provide a new hostname: " + read hostname + echo "$hostname" > /etc/hostname + sed -i "s/spyguard/$hostname/g" /etc/hosts +} + +reboot_box() { + echo -e "\e[92m[+] SpyGuard uninstalled, let's reboot.\e[39m" + sleep 5 + reboot +} + +# Checking rights. +if [[ $EUID -ne 0 ]]; then + echo "The update must be run as root. Type in 'sudo bash $0' to run it as root." + exit 1 +else + delete_folder + delete_services + deleting_icon + update_hostname + delete_packages + reboot_box +fi diff --git a/update.sh b/update.sh index 06ada8c..cb68452 100755 --- a/update.sh +++ b/update.sh @@ -6,7 +6,7 @@ fi if [ $PWD = "/usr/share/spyguard" ]; then echo "[+] Cloning the current repository to /tmp/" - rm -rf /tmp/spyguard/ &> /dev/null + rm -rf /tmp/spyguard/ &> /dev/null cd /tmp/ && git clone https://github.com/SpyGuard/spyguard cd /tmp/spyguard && bash update.sh elif [ $PWD = "/tmp/spyguard" ]; then