From 932c43738103ea50e277af63bb2d8b2afef7aa27 Mon Sep 17 00:00:00 2001 From: Mitesh Shah Date: Mon, 23 Jun 2014 14:58:51 +0530 Subject: [PATCH] ee site command finished --- .travis.yml | 9 ++++- bin/easyengine | 55 +++++++++++++++++++++++++++- bin/ee | 18 ++++----- src/modules/site/ee_mod_site_edit.sh | 2 +- 4 files changed, 71 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index c7f2dd3a..5aa6ac7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,8 +41,13 @@ script: - sudo bash ee site create wpsubdirwpfc.com --wpsubdirectory --wpfc - sudo bash ee site create wpsubdomainwpfc.com --wpfc --wpsubdom -- sudo cat /var/log/easyengine/* - - sudo mysql -e "show databases"; +- sudo bash ee site delete wwpsubdomainwpsc.com --files --no-prompt +- sudo bash ee site delete wpwpfc.com --db --no-prompt +- sudo bash ee site delete wpsubdirwpfc.com --all --no-prompt +- sudo bash ee site delete wpsubdomainwpfc.com --no-prompt +- sudo mysql -e "show databases"; + +- sudo cat /var/log/easyengine/* - sudo wp --allow-root --info diff --git a/bin/easyengine b/bin/easyengine index ba36cd41..203a364f 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -235,7 +235,22 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_service nginx reload # Git commit - ee_lib_git /etc/nginx/ "Enable website: $EE_DOMAIN" + ee_lib_git /etc/nginx/ "Disable website: $EE_DOMAIN" + elif [ "$EE_SECOND" = "edit" ]; then + # Check the website name is empty or not + EE_DOMAIN_CHECK=$EE_THIRD + ee_lib_check_domain + + # Edit the NGINX configuration for $EE_DOMAIN + ee_mod_site_edit "$EE_THIRD" + + if [ $(cd /etc/nginx; git status -s /etc/nginx/sites-available/$EE_DOMAIN | wc -l) -ne 0 ]; then + # Git commit + ee_lib_git /etc/nginx/ "Edit website: $EE_DOMAIN" + + # Execute: service nginx reload + ee_lib_service nginx reload + fi elif [ "$EE_SECOND" = "create" ]; then # Configure variables EE_DOMAIN_CHECK=$EE_THIRD @@ -383,6 +398,44 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "Successfully created new website: http://$EE_WWW_DOMAIN" fi fi + elif [ "$EE_SECOND" = "delete" ]; then + # Check the website name is empty or not + EE_DELETE_ARGS=$EE_FOURTH + EE_DOMAIN_CHECK=$EE_THIRD + ee_lib_check_domain + + # Use default whenever possible + # ee site delete example.com + # ee site delete example.com --no-prompt + if [ "$EE_DELETE_ARGS" = "" ]; then + EE_DELETE_ARGS="--all" + elif [ "$EE_DELETE_ARGS" = "--no-prompt" ]; then + EE_DELETE_ARGS="--all" + EE_FIFTH="--no-prompt" + fi + + if [ "$EE_DELETE_ARGS" = "--db" ]; then + # Delete MySQL database + ee_mod_delete_database $EE_FIFTH + elif [ "$EE_DELETE_ARGS" = "--files" ]; then + # Delete webroot + ee_mod_delete_webroot $EE_FIFTH + elif [ "$EE_DELETE_ARGS" = "--all" ]; then + # Delete MySQL database + ee_mod_delete_database $EE_FIFTH + + # Delete webroot + ee_mod_delete_webroot $EE_FIFTH + + # Delete NGINX configuration file + ee_mod_delete_nginxconf $EE_FIFTH + + # Git commit + ee_lib_git /etc/nginx/ "Delete website: $EE_DOMAIN" + + # Execute: service nginx reload + ee_lib_service nginx reload + fi fi fi diff --git a/bin/ee b/bin/ee index 8e47890f..0ce9dd16 100644 --- a/bin/ee +++ b/bin/ee @@ -1617,28 +1617,28 @@ then # Check SITENAME Is Empty Or Not EE_DOMAIN_CHECK=$EE_THIRD - SITEDELETEARG=$4 + EE_DELETE_ARGS=$4 ee_lib_check_domain # USE DEFAULT WHEN POSSIBLES - if [ "$SITEDELETEARG" = "" ] + if [ "$EE_DELETE_ARGS" = "" ] then - SITEDELETEARG=--all + EE_DELETE_ARGS=--all fi - if [ "$SITEDELETEARG" = "--db" ] + if [ "$EE_DELETE_ARGS" = "--db" ] then # Remove Database ee_mod_delete_database - elif [ "$SITEDELETEARG" = "--files" ] + elif [ "$EE_DELETE_ARGS" = "--files" ] then # Remove Webroot ee_mod_delete_webroot - elif [ "$SITEDELETEARG" = "--all" ] + elif [ "$EE_DELETE_ARGS" = "--all" ] then # Remove All Database And Webroot @@ -1653,10 +1653,10 @@ then # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx - EE_GIT_MESSAGE="Delete Website With $SITEDELETEARG Option: $EE_DOMAIN" + EE_GIT_MESSAGE="Delete Website With $EE_DELETE_ARGS Option: $EE_DOMAIN" ee_lib_git_commit - elif [ "$SITEDELETEARG" = "--all---no-prompt" ] + elif [ "$EE_DELETE_ARGS" = "--all---no-prompt" ] then # Remove All Database And Webroot @@ -1671,7 +1671,7 @@ then # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx - EE_GIT_MESSAGE="Delete Website With $SITEDELETEARG Option: $EE_DOMAIN" + EE_GIT_MESSAGE="Delete Website With $EE_DELETE_ARGS Option: $EE_DOMAIN" ee_lib_git_commit fi diff --git a/src/modules/site/ee_mod_site_edit.sh b/src/modules/site/ee_mod_site_edit.sh index 5a773226..a9670216 100644 --- a/src/modules/site/ee_mod_site_edit.sh +++ b/src/modules/site/ee_mod_site_edit.sh @@ -2,5 +2,5 @@ function ee_mod_site_edit() { - sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $EE_VIM 2> /dev/null + sensible-editor /etc/nginx/sites-available/$EE_DOMAIN $1 2> /dev/null }