Files
Misc-Scripts/cc-cleaner.sh
2023-05-06 10:11:04 -05:00

74 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
if [ -d /opt/idssys/defaults ]; then
source /opt/idssys/defaults/colors.inc
source /opt/idssys/defaults/default.inc
else
source /dev/stdin <<< "$(curl -sL http://go.scity.us/colorsinc)"
source /dev/stdin <<< "$(curl -sL http://go.scity.us/defaultinc)"
fi
echo ""
echo -e "${idsCL[LightGreen]}Cluster Control Removal Script${idsCL[Default]}"
echo ""
cd ~
rm -f ./install-cc
wget https://severalnines.com/downloads/cmon/install-cc
chmod +x ./install-cc
sed -i 's/\/var\/lib\/mysql\/mysql.sock/\/var\/run\/mysqld\/mysqld.sock/g' ./install-cc
read -n 1 -p "Are you sure you wish to remove Cluster Control and all data (Y/n)?" choice
case "$choice" in
[Nn]) echo '';;
* )
echo ''
apt remove --purge -y clustercontrol*
apt remove --purge -y mysql-server*
apt remove --purge -y "mysql*" "*s9s*" apache2 "php*"
apt --purge -y autoremove
apt clean
rm -Rf /etc/cmon.d
rm -Rf /var/www/clustercontrol
rm -Rf /var/lib/cmon
rm -Rf /var/lib/prometheus
rm -Rf /etc/apache2
rm -Rf /var/www
rm -Rf /etc/php
rm -Rf /root/.s9s
rm -Rf /etc/s9s.conf
rm -f /etc/ssl/certs/s9server*
rm -Rf /root/s9s_tmp
find /etc -iname "*cmon*" -exec rm {} \;
/root/install-cc --uninstall
echo '';;
esac
read -n 1 -p "Would you like to now re-install Cluster Control (Y/n)?" choice
case "$choice" in
[Nn]) echo ''; exit 0;;
* )
./install-cc
#read -n 1 -p "Login at https://10.10.10.50 and setup the admin user, once complete then press ENTER" choice
/opt/copycerts.sh
apt install -y mailutils xtrabackup
echo
echo
read -p "Enter the admin password for MySQL: " pwd
echo "Enter the root password for adding back in the admin user for MySQL:"
mysql -u root -p -e "CREATE USER 'admin'@'%' IDENTIFIED BY '${pwd}';GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;"
;;
esac
exit 0