From 674c8239e21e049ead57f8f00a16823a60516de6 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 9 Jun 2014 15:47:03 +0530 Subject: [PATCH] ee stack remove && ee stack purge --- .travis.yml | 2 + bin/easyengine | 51 +++++++++++++++++++ src/lib/ee_lib_autoremove.sh | 7 +++ .../system/remove/ee_mod_remove_mysql.sh | 6 +-- .../system/remove/ee_mod_remove_nginx.sh | 6 +-- .../system/remove/ee_mod_remove_php.sh | 6 +-- .../system/remove/ee_mod_remove_postfix.sh | 4 +- 7 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 src/lib/ee_lib_autoremove.sh diff --git a/.travis.yml b/.travis.yml index 2dc8ff20..da4c69cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,8 @@ script: - sudo bash -x bin/install.sh $TRAVIS_BRANCH - sudo ee stack install +- sudo ee stack remove +- sudo ee stack purge - sudo ee system install nginx - sudo ee system install php - sudo ee system install mysql diff --git a/bin/easyengine b/bin/easyengine index fe890a69..17ce16cf 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -108,6 +108,57 @@ then ee_ven_install_phpmyadmin ee_ven_install_wpcli ee_ven_install_utils + + # Display success message + ee_lib_echo "Successfully installed all packages" + fi + fi + + # EasyEngine remove/purge + if [ "$EE_SECOND" = "remove" ] || [ "$EE_SECOND" = "purge" ]; then + if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then + + # Remove/Purge nginx/php/mysql/postfix package + if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then + ee_mod_remove_$EE_THIRD + fi + + # Remove/Purge adminer/phpmyadmin/wpcli/utils + if [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ];then + ee_ven_remove_$EE_THIRD + fi + + # Execute: apt-get autoremove + ee_lib_autoremove + + # Display success message + if [ "$EE_SECOND" = "remove" ];then + ee_lib_echo "$EE_THIRD successfully removed" + elif [ "$EE_SECOND" = "purge" ];then + ee_lib_echo "$EE_THIRD successfully purged" + fi + elif [ "$EE_THIRD" = "" ]; then + # Remove/Purge nginx/php/mysql/postfix package + ee_mod_remove_nginx + ee_mod_remove_php + ee_mod_remove_mysql + ee_mod_remove_postfix + + # Install adminer/phpmyadmin/wpcli/utils + ee_ven_remove_adminer + ee_ven_remove_phpmyadmin + ee_ven_remove_wpcli + ee_ven_remove_utils + + # Execute: apt-get autoremove + ee_lib_autoremove + + # Display success message + if [ "$EE_SECOND" = "remove" ];then + ee_lib_echo "Successfully removed all packages" + elif [ "$EE_SECOND" = "purge" ];then + ee_lib_echo "Successfully purged all packages" + fi fi fi fi diff --git a/src/lib/ee_lib_autoremove.sh b/src/lib/ee_lib_autoremove.sh new file mode 100644 index 00000000..ab10a207 --- /dev/null +++ b/src/lib/ee_lib_autoremove.sh @@ -0,0 +1,7 @@ +# Execute: apt-get autoremove + +function ee_lib_autoremove() +{ + ee_lib_echo "Removing unwanted packages, please wait..." + $EE_APT_GET autoremove | tee -ai $EE_COMMAND_LOG +} \ No newline at end of file diff --git a/src/modules/system/remove/ee_mod_remove_mysql.sh b/src/modules/system/remove/ee_mod_remove_mysql.sh index 025a0d24..173da3a5 100644 --- a/src/modules/system/remove/ee_mod_remove_mysql.sh +++ b/src/modules/system/remove/ee_mod_remove_mysql.sh @@ -2,9 +2,9 @@ function ee_mod_remove_mysql() { - ee_lib_echo "Removing MySQL, please wait..." - $EE_APT_GET remove mysql-server mysqltuner percona-toolkit \ - || ee_lib_error "Unable to remove MySQL, exit status = " $? + ee_lib_echo "$EE_SECOND MySQL, please wait..." + $EE_APT_GET $EE_SECOND mysql-server mysqltuner percona-toolkit \ + || ee_lib_error "Unable to $EE_SECOND MySQL, exit status = " $? # Remove tuning-primer.sh rm -f /usr/local/bin/tuning-primer.sh diff --git a/src/modules/system/remove/ee_mod_remove_nginx.sh b/src/modules/system/remove/ee_mod_remove_nginx.sh index 1eca36e0..8763eefb 100644 --- a/src/modules/system/remove/ee_mod_remove_nginx.sh +++ b/src/modules/system/remove/ee_mod_remove_nginx.sh @@ -2,7 +2,7 @@ function ee_mod_remove_nginx() { - ee_lib_echo "Removing $EE_NGINX_PACKAGE, please wait..." - $EE_APT_GET remove $EE_NGINX_PACKAGE nginx-common \ - || ee_lib_error "Unable to remove $NGINX_PACKAGE, exit status = " $? + ee_lib_echo "$EE_SECOND $EE_NGINX_PACKAGE, please wait..." + $EE_APT_GET $EE_SECOND $EE_NGINX_PACKAGE nginx-common \ + || ee_lib_error "Unable to $EE_SECOND $NGINX_PACKAGE, exit status = " $? } diff --git a/src/modules/system/remove/ee_mod_remove_php.sh b/src/modules/system/remove/ee_mod_remove_php.sh index c8146490..39d2c1a8 100644 --- a/src/modules/system/remove/ee_mod_remove_php.sh +++ b/src/modules/system/remove/ee_mod_remove_php.sh @@ -2,8 +2,8 @@ function ee_mod_remove_php() { - ee_lib_echo "Removing php5, please wait..." - $EE_APT_GET remove php5-common php5-mysqlnd php5-xmlrpc \ + ee_lib_echo "$EE_SECOND php5, please wait..." + $EE_APT_GET $EE_SECOND php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached || ee_lib_error "Unable to remove php5, exit status = " $? + php5-memcache memcached || ee_lib_error "Unable to $EE_SECOND php5, exit status = " $? } diff --git a/src/modules/system/remove/ee_mod_remove_postfix.sh b/src/modules/system/remove/ee_mod_remove_postfix.sh index 2da20872..c4281aa3 100644 --- a/src/modules/system/remove/ee_mod_remove_postfix.sh +++ b/src/modules/system/remove/ee_mod_remove_postfix.sh @@ -2,6 +2,6 @@ function ee_mod_remove_postfix() { - ee_lib_echo "Removing Postfix, please wait..." - $EE_APT_GET remove postfix || ee_lib_error "Unable to remove Postfix, exit status = " $? + ee_lib_echo "$EE_SECOND Postfix, please wait..." + $EE_APT_GET $EE_SECOND postfix || ee_lib_error "Unable to $EE_SECOND Postfix, exit status = " $? }