Files
Misc-Scripts/cc-reinstall.sh

129 lines
3.3 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/apache2
rm -Rf /etc/cmon.d
rm -Rf /etc/mysql
rm -Rf /etc/php
rm -Rf /etc/s9s.conf
rm -f /etc/ssl/certs/s9server*
rm -Rf /root/.s9s
rm -Rf /root/s9s_tmp
rm -Rf /var/lib/cmon
rm -Rf /var/lib/mysql
rm -Rf /var/lib/prometheus
rm -Rf /var/cache/cmon
rm -Rf /var/www
rm -Rf /var/www/clustercontrol
rm -f /var/log/cmon*
find /etc -iname "*cmon*" -exec rm {} \;
/root/install-cc --uninstall
apt install -y mailutils
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 -1
/opt/copycerts.sh
echo
echo
read -p "Enter a password to set for the Admin account in MySQL: " pwd
echo
echo "Enter the root MySQL password:"
mysql -u root -p -e "CREATE USER 'admin'@'%' IDENTIFIED BY '${pwd}';GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;"
read -n 1 -p "Login at https://mysql.scity.us and setup the admin user, verify it brings up the deploy prompt. Once complete then press ENTER" choice2
echo
echo
echo "Importing Previous Database Clusters"
/usr/bin/s9s cluster --register \
--cluster-type=galera \
--nodes="10.10.1.51;10.10.1.52;10.2.1.51" \
--vendor=mariadb \
--provider-version=10.4 \
--db-admin="root" \
--db-admin-passwd='Dc$@54115' \
--os-user=root \
--os-key-file=/root/.ssh/id_rsa \
--cluster-name="iDS-MySQL-Galera"
# /usr/bin/s9s cluster --register \
# --cluster-type=postgresql \
# --nodes="10.10.0.211;10.10.0.212" \
# --vendor=mariadb \
# --provider-version=13 \
# --db-admin="root" \
# --db-admin-passwd='Dc$@54115' \
# --os-user=root \
# --os-key-file=/root/.ssh/id_rsa \
# --cluster-name="Headscale-PostgreSQL"
/usr/bin/s9s cluster --register \
--cluster-type=galera \
# --nodes="10.10.10.10;10.10.10.11;10.2.1.5;10.2.1.6" \
--nodes="10.10.10.10;10.10.10.11;10.2.1.2" \
--vendor=mariadb \
--provider-version=10.6 \
--db-admin="root" \
--db-admin-passwd='Dc$@54115' \
--os-user=root \
--os-key-file=/root/.ssh/id_rsa \
--cluster-name="LAN-DNS-MySQL-Galera"
/usr/bin/s9s cluster --register \
--cluster-type=galera \
--nodes="100.100.20.1;100.100.20.2;100.100.20.3" \
--vendor=mariadb \
--provider-version=10.6 \
--db-admin="root" \
--db-admin-passwd='Dc$@54115' \
--os-user=root \
--os-key-file=/root/.ssh/id_rsa \
--cluster-name="WAN-DNS-MySQL-Galera"
# bash <(curl -sL https://git.schroedercity.com/voltron/Misc-Scripts/raw/master/install-postfix.sh)
echo
echo "Install Completed"
;; esac
exit 0