Add uninstall script

This commit is contained in:
VirtuBox
2019-07-29 11:23:23 +02:00
parent 9c0eda3877
commit 5c90b7952b
3 changed files with 127 additions and 109 deletions

View File

@@ -54,3 +54,4 @@ script:
- sudo wo update --travis - sudo wo update --travis
- sudo wo stack status - sudo wo stack status
- echo "yes" | sudo wo stack purge --all - echo "yes" | sudo wo stack purge --all
- sudo bash install --purge

234
install
View File

@@ -7,7 +7,7 @@
# Copyright (c) 2019 - WordOps # Copyright (c) 2019 - WordOps
# This script is licensed under M.I.T # This script is licensed under M.I.T
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Version 3.9.6.3 - 2019-07-25 # Version 3.9.6.3 - 2019-07-29
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
readonly wo_version_old="2.2.3" readonly wo_version_old="2.2.3"
readonly wo_version_new="3.9.6.3" readonly wo_version_new="3.9.6.3"
@@ -73,6 +73,9 @@ while [ "$#" -gt 0 ]; do
-s | --silent) -s | --silent)
wo_force_install="y" wo_force_install="y"
;; ;;
--purge | --uninstall)
wo_purge="y"
;;
*) # positional args *) # positional args
;; ;;
esac esac
@@ -620,15 +623,15 @@ wo_git_init() {
} }
wo_backup_ee() { wo_backup_ee() {
/bin/tar -I pigz -cf "$EE_BACKUP_FILE" /etc/nginx /usr/local/bin/ee /usr/lib/ee/templates /usr/local/lib/python3.6/dist-packages/ee-*.egg /etc/ee /var/lib/ee /etc/letsencrypt >> /var/log/wo/install.log 2>&1 /bin/tar -I pigz -cf "$EE_BACKUP_FILE" /etc/nginx /usr/local/bin/ee /usr/lib/ee/templates /usr/local/lib/python3.*/dist-packages/ee-*.egg /etc/ee /var/lib/ee /etc/letsencrypt >> /var/log/wo/install.log 2>&1
} }
wo_backup_wo() { wo_backup_wo() {
/bin/tar -I pigz -cf "$WO_BACKUP_FILE" /etc/nginx /usr/local/lib/python3.6/dist-packages/wo-*.egg /etc/wo /var/lib/wo /etc/letsencrypt >> /var/log/wo/install.log 2>&1 /bin/tar -I pigz -cf "$WO_BACKUP_FILE" /etc/nginx /usr/local/lib/python3.*/dist-packages/wo-*.egg /etc/wo /var/lib/wo /etc/letsencrypt >> /var/log/wo/install.log 2>&1
} }
wo_clean_ee() { wo_clean_ee() {
rm -f /usr/local/bin/ee /etc/bash_completion.d/ee_auto.rc /usr/lib/ee/templates /usr/local/lib/python3.6/dist-packages/ee-*.egg /etc/ee /var/lib/ee >> /var/log/wo/install.log 2>&1 rm -f /usr/local/bin/ee /etc/bash_completion.d/ee_auto.rc /usr/lib/ee/templates /usr/local/lib/python3.*/dist-packages/ee-*.egg /etc/ee /var/lib/ee >> /var/log/wo/install.log 2>&1
} }
wo_remove_ee_cron() { wo_remove_ee_cron() {
@@ -653,14 +656,14 @@ wo_tweak_kernel() {
# apply sysctl tweaks # apply sysctl tweaks
sysctl -eq -p /etc/sysctl.d/60-wo-tweaks.conf sysctl -eq -p /etc/sysctl.d/60-wo-tweaks.conf
if [ ! -x /opt/wo-kernel.sh ]; then if [ ! -x /opt/wo-kernel.sh ]; then
{ {
# download and setup wo-kernel systemd service to apply kernel tweaks for netdata and redis on server startup # download and setup wo-kernel systemd service to apply kernel tweaks for netdata and redis on server startup
wget -qO /opt/wo-kernel.sh https://raw.githubusercontent.com/WordOps/WordOps/updating-configuration/wo/cli/templates/wo-kernel-script.mustache wget -qO /opt/wo-kernel.sh https://raw.githubusercontent.com/WordOps/WordOps/updating-configuration/wo/cli/templates/wo-kernel-script.mustache
chmod +x /opt/wo-kernel.sh chmod +x /opt/wo-kernel.sh
wget -qO /lib/systemd/system/wo-kernel.service https://raw.githubusercontent.com/WordOps/WordOps/updating-configuration/wo/cli/templates/wo-kernel-service.mustache wget -qO /lib/systemd/system/wo-kernel.service https://raw.githubusercontent.com/WordOps/WordOps/updating-configuration/wo/cli/templates/wo-kernel-service.mustache
systemctl enable wo-kernel.service systemctl enable wo-kernel.service
systemctl start wo-kernel.service systemctl start wo-kernel.service
} >> /var/log/wo/install.log 2>&1 } >> /var/log/wo/install.log 2>&1
fi fi
fi fi
@@ -672,128 +675,141 @@ wo_tweak_kernel() {
} }
wo_uninstall() {
rm -rf /usr/local/lib/python3.*/dist-packages/{pystache-*,cement-2.*,wo-*} /usr/local/bin/wo /etc/bash_completion.d/wo_auto.rc /var/lib/wo /etc/wo /usr/lib/wo/templates >> /var/log/wo/install.log 2>&1
}
### ###
# 4 - WO MAIN SETUP # 4 - WO MAIN SETUP
### ###
# 1 - WO already installed if [ $wo_purge = "y" ]; then
if [ -x /usr/local/bin/wo ]; then wo_lib_echo "Backing-up WO install" | tee -ai $wo_install_log
if ! { wo_backup_wo | tee -ai $wo_install_log
wo -v 2>&1 | grep $wo_version_new wo_lib_echo "Uninstalling WordOps" | tee -ai $wo_install_log
} || [ "$wo_force_install" = "y" ]; then wo_uninstall | tee -ai $wo_install_log
if [ -z "$wo_force_install" ]; then wo_lib_echo "The WordOps backup files can be found in $WO_BACKUP_FILE"
echo -e "Update WordOps to $wo_version_new (y/n): " && read -r WO_ANSWER else
else # 1 - WO already installed
WO_ANSWER="y" if [ -x /usr/local/bin/wo ]; then
fi if ! {
if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then wo -v 2>&1 | grep $wo_version_new
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log } || [ "$wo_force_install" = "y" ]; then
wo_install_dep | tee -ai $wo_install_log if [ -z "$wo_force_install" ]; then
wo_lib_echo "Backing-up WO install" | tee -ai $wo_install_log echo -e "Update WordOps to $wo_version_new (y/n): " && read -r WO_ANSWER
wo_backup_wo | tee -ai $wo_install_log
wo_lib_echo "Syncing WO database" | tee -ai $wo_install_log
secure_wo_db | tee -ai $wo_install_log
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
if [ -f "$HOME/.gitconfig" ]; then
wo_install >> $wo_install_log 2>&1
else else
wo_install | tee -ai $wo_install_log WO_ANSWER="y"
fi fi
if [ -z "$wo_preserve_config" ]; then if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then
if [ -n "$(command -v nginx)" ]; then wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
if [ ! -f /etc/nginx/common/release ] || ! grep -q "v3.9.6" /etc/nginx/common/release; then wo_install_dep | tee -ai $wo_install_log
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log wo_lib_echo "Backing-up WO install" | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log wo_backup_wo | tee -ai $wo_install_log
wo_lib_echo "Syncing WO database" | tee -ai $wo_install_log
secure_wo_db | tee -ai $wo_install_log
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
if [ -f "$HOME/.gitconfig" ]; then
wo_install >> $wo_install_log 2>&1
else
wo_install | tee -ai $wo_install_log
fi
if [ -z "$wo_preserve_config" ]; then
if [ -n "$(command -v nginx)" ]; then
if [ ! -f /etc/nginx/common/release ] || ! grep -q "v3.9.6" /etc/nginx/common/release; then
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log
fi
fi fi
fi fi
wo_update_latest | tee -ai $wo_install_log
wo_lib_echo "Updating acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log
else
wo_lib_error "Not updating WordOps to $wo_version_new, exit status = " 1
fi fi
wo_update_latest | tee -ai $wo_install_log
wo_lib_echo "Updating acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log
else else
wo_lib_error "Not updating WordOps to $wo_version_new, exit status = " 1 wo_lib_error "You already have WordOps $wo_version_new, exit status = " 1
fi fi
else else
wo_lib_error "You already have WordOps $wo_version_new, exit status = " 1 # 2 - Migration from EEv3
fi if [ -x /usr/local/bin/ee ]; then
else if [ -z "$wo_force_install" ]; then
# 2 - Migration from EEv3 echo -e "Migrate from EasyEngine to WordOps (y/n): " && read -r WO_ANSWER
if [ -x /usr/local/bin/ee ]; then else
if [ -z "$wo_force_install" ]; then WO_ANSWER="y"
echo -e "Migrate from EasyEngine to WordOps (y/n): " && read -r WO_ANSWER fi
if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | tee -ai $wo_install_log
wo_lib_echo "Backing-up EE install" | tee -ai $wo_install_log
wo_backup_ee | tee -ai $wo_install_log
wo_lib_echo "Removing EasyEngine cronjob" | tee -ai $wo_install_log
wo_remove_ee_cron | tee -ai $wo_install_log
wo_lib_echo "Syncing WO database" | tee -ai $wo_install_log
wo_sync_db | tee -ai $wo_install_log
secure_wo_db | tee -ai $wo_install_log
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
if [ -f "$HOME/.gitconfig" ]; then
wo_install >> $wo_install_log 2>&1
else
wo_install | tee -ai $wo_install_log
fi
if [ -n "$(command -v nginx)" ]; then
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log
fi
wo_update_latest | tee -ai $wo_install_log
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log
wo_lib_echo "Cleaning-up EE previous install" | tee -ai $wo_install_log
wo_clean_ee | tee -ai $wo_install_log
else
wo_lib_error "Not installing WordOps, exit status = " 1
fi
else else
WO_ANSWER="y" # 3 - Fresh WO setup
fi
if [ "$WO_ANSWER" = "y" ] || [ "$WO_ANSWER" = "Y" ]; then
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | tee -ai $wo_install_log wo_install_dep | tee -ai $wo_install_log
wo_lib_echo "Backing-up EE install" | tee -ai $wo_install_log
wo_backup_ee | tee -ai $wo_install_log
wo_lib_echo "Removing EasyEngine cronjob" | tee -ai $wo_install_log
wo_remove_ee_cron | tee -ai $wo_install_log
wo_lib_echo "Syncing WO database" | tee -ai $wo_install_log
wo_sync_db | tee -ai $wo_install_log
secure_wo_db | tee -ai $wo_install_log
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
if [ -f "$HOME/.gitconfig" ]; then wo_install | tee -ai $wo_install_log
wo_install >> $wo_install_log 2>&1
else
wo_install | tee -ai $wo_install_log
fi
if [ -n "$(command -v nginx)" ]; then
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log
fi
wo_update_latest | tee -ai $wo_install_log
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
secure_wo_db | tee -ai $wo_install_log
wo_git_init | tee -ai $wo_install_log wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log wo_update_wp_cli | tee -ai $wo_install_log
wo_lib_echo "Cleaning-up EE previous install" | tee -ai $wo_install_log
wo_clean_ee | tee -ai $wo_install_log
else
wo_lib_error "Not installing WordOps, exit status = " 1
fi fi
else
# 3 - Fresh WO setup
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
wo_install_dep | tee -ai $wo_install_log
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
wo_install | tee -ai $wo_install_log
wo_lib_echo "Applying Kernel tweaks" | tee -ai $wo_install_log
wo_tweak_kernel | tee -ai $wo_install_log
wo_lib_echo "Installing acme.sh" | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
secure_wo_db | tee -ai $wo_install_log
wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log
fi fi
fi
wo sync | tee -ai $wo_install_log wo sync | tee -ai $wo_install_log
if [ "$ee_migration" = "1" ]; then if [ "$ee_migration" = "1" ]; then
echo
wo_lib_echo "The migration from EasyEngine to WordOps was succesfull!"
wo_lib_echo "The EasyEngine backup files can be found in /var/lib/wo-backup/ee-backup.tgz"
echo
elif [ "$wo_upgrade" = "1" ]; then
wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!"
else
wo_lib_echo "WordOps (wo) installed successfully"
fi
echo echo
wo_lib_echo "The migration from EasyEngine to WordOps was succesfull!" wo_lib_echo_info "For autocompletion, run the following command:"
wo_lib_echo "The EasyEngine backup files can be found in /var/lib/wo-backup/ee-backup.tgz" wo_lib_echo_info "source /etc/bash_completion.d/wo_auto.rc"
echo echo
elif [ "$wo_upgrade" = "1" ]; then wo_lib_echo "WordOps Documentation : https://docs.wordops.net"
wo_lib_echo "WordOps (wo) upgrade to $wo_version_new was succesfull!" wo_lib_echo "WordOps Community Forum : https://community.wordops.net"
else echo
wo_lib_echo "WordOps (wo) installed successfully"
fi fi
echo
wo_lib_echo_info "For autocompletion, run the following command:"
wo_lib_echo_info "source /etc/bash_completion.d/wo_auto.rc"
echo
wo_lib_echo "WordOps Documentation : https://docs.wordops.net"
wo_lib_echo "WordOps Community Forum : https://community.wordops.net"
echo

View File

@@ -1486,6 +1486,7 @@ class WOStackController(CementBaseController):
"/master/mysqltuner.pl", "/master/mysqltuner.pl",
"/usr/bin/mysqltuner", "/usr/bin/mysqltuner",
"MySQLTuner"]] "MySQLTuner"]]
else: else:
Log.debug(self, "MySQL connection is already alive") Log.debug(self, "MySQL connection is already alive")
Log.info(self, "MySQL connection is already alive") Log.info(self, "MySQL connection is already alive")