diff --git a/.travis.yml b/.travis.yml index fb41793c..ad15332d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,16 +8,13 @@ notifications: language: bash - - before_install: - +- rm -rf ~/.gnupg before_script: - sudo apt-get -qq purge mysql* graphviz* - sudo apt-get -qq autoremove - script: - sudo echo -e "[user]\n\tname = Mitesh Shah\n\temail = root@localhost.com" > ~/.gitconfig - sudo echo "Travis Banch = $TRAVIS_BRANCH" @@ -40,7 +37,7 @@ script: - sudo bash ee site create site2.com --wpsc - sudo bash ee site create site2.net --wp --wpsc -- sudo bash ee site create site2.org --wpsc --wp +- sudo bash ee site create site2.org --wpsc --wp - sudo bash ee site create site3.com --w3tc - sudo bash ee site create site3.net --wp --w3tc @@ -48,7 +45,7 @@ script: - sudo bash ee site create site4.com --wpfc - sudo bash ee site create site4.net --wp --wpfc -- sudo bash ee site create site4.org --wpfc --wp +- sudo bash ee site create site4.org --wpfc --wp - sudo bash ee site create site5.com --wpsubdir - sudo bash ee site create site5.net --wpsubdir --basic @@ -100,9 +97,9 @@ script: - sudo bash ee debug --nginx site1.com - sudo bash ee debug --nginx site1.com --stop -- sudo bash ee debug -rewrite +- sudo bash ee debug -rewrite - sudo bash ee debug -rewrite --stop -- sudo bash ee debug -rewrite site1.com +- sudo bash ee debug -rewrite site1.com - sudo bash ee debug -rewrite site1.com --stop - sudo bash ee debug --php @@ -133,21 +130,6 @@ script: - sudo bash ee site update 1.com --wp - sudo bash ee site update 2.com --wpsubdir -- sudo bash ee site update 3.com --wpsubdomain - - -- sudo bash ee site update site1.com --wp --wpfc -- sudo bash ee site update site1.com --wp --w3tc -- sudo bash ee site update site1.com --wp --wpsc - -- sudo bash ee site update site5.com --wpsubdir --wpfc -- sudo bash ee site update site5.com --wpsubdir --w3tc -- sudo bash ee site update site5.com --wpsubdir --wpsc - -- sudo bash ee site update site9.com --wpsubdom --wpfc -- sudo bash ee site update site9.com --wpsubdom --w3tc -- sudo bash ee site update site9.com --wpsubdom --wpsc - - sudo ee site delete site12.com --no-prompt - sudo ee site delete site12.net --no-prompt @@ -163,4 +145,3 @@ script: - sudo wp --allow-root --info - diff --git a/bin/easyengine b/bin/easyengine index dbe38938..97d157c9 100644 --- a/bin/easyengine +++ b/bin/easyengine @@ -425,7 +425,7 @@ elif [ "$EE_FIRST" = "site" ]; then ee_mod_setup_database # Add Database Information On ee-config.php - echo -e "" \ + echo -e "" \ &>> /var/www/$EE_DOMAIN/ee-config.php fi @@ -444,9 +444,6 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - # Cross check WP-CLI installed or not - wp --allow-root --info &>> $EE_COMMAND_LOG \ - || ee_lib_error "WP-CLI not found, exit status = " $? # Configure variable EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf @@ -459,22 +456,6 @@ elif [ "$EE_FIRST" = "site" ]; then # Setup WordPress ee_mod_setup_wordpress - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - - # Install WordPress plugins - ee_mod_plugin_nginx_helper - - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_mod_plugin_w3tc - fi - # Adjust permission ee_lib_permissions @@ -496,38 +477,8 @@ elif [ "$EE_FIRST" = "site" ]; then ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo - # Configure WordPress plugin settings - if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" - else - ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=wpsupercache" - fi - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=nginx" - else - ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=nginx" - fi - fi - - if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" - else - ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/admin.php?page=w3tc_general" - fi - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - ee_lib_echo_escape "Page Cache:\t\tDisable" - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - ee_lib_echo_escape "Page Cache:\t\tDisk Enhanced" - fi - ee_lib_echo_escape "Database Cache:\t\tMemcached" - ee_lib_echo_escape "Object Cache:\t\tMemcached" - ee_lib_echo_escape "Browser Cache:\t\tDisable" - fi + # Display WordPress cache plugin settings + ee_mod_plugin_settings # Display Success Message ee_lib_echo_info "Successfully created new website: http://$EE_WWW_DOMAIN" @@ -585,140 +536,148 @@ elif [ "$EE_FIRST" = "site" ]; then # Check the website name is empty or not ee_lib_check_domain - # Check the website exist - ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ - || ee_lib_error "The $EE_DOMAIN is not found in /etc/nginx/sites-available, exit status = " $? - - # Update WordPress user password - if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then - ee_mod_site_update_password - else - # Auto switch site options - ee_mod_site_option - - EE_SITE_CURRENT_OPTION=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) - if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then - EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf - elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf - fi - fi - - # Install required packages - ee_mod_site_packages - - # Lets update HTML|PHP|MySQL website - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - - - # Update NGINX configuration for $EE_DOMAIN - if [[ "$EE_SITE_CREATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \ - || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - - # Setup WordPress - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - if [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then - # Sets EE_DB_NAME, EE_DB_USER, EE_DB_PASS variables, so that same database can be used while updating MYSQL site to any WordPress site - EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/htdocs/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) - fi - ee_mod_setup_wordpress - fi - - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi + # Auto switch site options + ee_mod_site_option - # Install WordPress plugins - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - ee_mod_plugin_nginx_helper - fi + # Let's use variable name as per action + # EE_SITE_CREATE_OPTION=$EE_SITE_CREATE_OPTION - # Update cache plugins - ee_mod_update_plugins + # Check the website exist or not + ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ + || ee_lib_error "The $EE_DOMAIN does not exist, exit status = " $? + + # Find out information about current NGINX configuration + EE_SITE_CURRENT_TYPE=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5) + + # Detect current website type and cache + if [ "$EE_SITE_CURRENT_TYPE" = "HTML" ]; then + EE_SITE_CURRENT_TYPE="--html" + elif [ "$EE_SITE_CURRENT_TYPE" = "PHP" ]; then + EE_SITE_CURRENT_TYPE="--php" + elif [ "$EE_SITE_CURRENT_TYPE" = "MYSQL" ]; then + EE_SITE_CURRENT_TYPE="--mysql" + # Single WordPress + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE BASIC" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--basic" + EE_SITE_CURRENT_TYPE="--wp --basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE WP SUPER CACHE" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--wpsc" + EE_SITE_CURRENT_TYPE="--wp --wpsc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--w3tc" + EE_SITE_CURRENT_TYPE="--wp --w3tc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSINGLE FASTCGI" ]; then + EE_SITE_CURRENT_WP="--wp" + EE_SITE_CURRENT_CACHE="--wpfc" + EE_SITE_CURRENT_TYPE="--wp --wpfc" + # WordPress subdirectory + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR BASIC" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--basic" + EE_SITE_CURRENT_TYPE="--wpsubdir --basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR WP SUPER CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--wpsc" + EE_SITE_CURRENT_TYPE="--wpsubdir --wpsc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--w3tc" + EE_SITE_CURRENT_TYPE="--wpsubdir --w3tc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDIR FASTCGI" ]; then + EE_SITE_CURRENT_WP="--wpsubdir" + EE_SITE_CURRENT_CACHE="--wpfc" + EE_SITE_CURRENT_TYPE="--wpsubdir --wpfc" + # WordPress subdomain + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN BASIC" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--basic" + EE_SITE_CURRENT_TYPE="--wpsubdomain --basic" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN WP SUPER CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--wpsc" + EE_SITE_CURRENT_TYPE="--wpsubdomain --wpsc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--w3tc" + EE_SITE_CURRENT_TYPE="--wpsubdomain --w3tc" + elif [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_TYPE" = "WPSUBDOMAIN FASTCGI" ]; then + EE_SITE_CURRENT_WP="--wpsubdomain" + EE_SITE_CURRENT_CACHE="--wpfc" + EE_SITE_CURRENT_TYPE="--wpsubdomain --wpfc" + fi - # Setup MySQL database - if [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then - ee_mod_setup_database + # Detect update website type and cache + # Single WordPress + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + EE_SITE_UPDATE_TYPE="--wp --basic" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + EE_SITE_UPDATE_TYPE="--wp --wpsc" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + EE_SITE_UPDATE_TYPE="--wp --w3tc" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + EE_SITE_UPDATE_TYPE="--wp --wpfc" + fi + # WordPress subdirectory + elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --basic" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --wpsc" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --w3tc" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdir --wpfc" + fi + # WordPress subdomain + elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --basic" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --wpsc" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --w3tc" + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + EE_SITE_UPDATE_TYPE="--wpsubdomain --wpfc" + fi + fi - # Add Database Information On ee-config.php - echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ - &>> /var/www/$EE_DOMAIN/ee-config.php - fi + # Let's log site current option + ee_lib_echo_escape "EE_SITE_CURRENT_WP = $EE_SITE_CURRENT_WP \nEE_SITE_CURRENT_CACHE = $EE_SITE_CURRENT_CACHE \nEE_SITE_CURRENT_TYPE = $EE_SITE_CURRENT_TYPE \n\nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG - if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - # Display WordPress credential - echo - ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" - ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" - echo - fi + # Update WordPress user password + if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then + ee_mod_site_update_password + # Lets update HTML|PHP website + elif [[ "$EE_SITE_CURRENT_TYPE" = "--html" && "$EE_SITE_CREATE_OPTION" != "--html" ]] || [[ "$EE_SITE_CURRENT_TYPE" = "--php" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" ]]; then + # Lets call update function + ee_mod_update_website + + elif [[ "$EE_SITE_CURRENT_TYPE" = "--mysql" && "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" ]]; then + # Lets call update function + ee_mod_update_website + + elif [[ "$EE_SITE_CURRENT_WP" = "--wp" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then + # Lets call update function + ee_mod_update_website + + elif [[ "$EE_SITE_CURRENT_WP" = "--wpsubdir" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then + # Lets call update function + ee_mod_update_website + + elif [[ "$EE_SITE_CURRENT_WP" = "--wpsubdomain" ]] \ + && [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CURRENT_TYPE" != "$EE_SITE_UPDATE_TYPE" ]]; then + # Lets call update function + ee_mod_update_website + fi - # Lets update WordPress Single sites - # WordPress Single sites can only be updated to multisites or with different cache options - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ - && [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then - - if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE BASIC" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ]] \ - || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - # Update NGINX configuration for $EE_DOMAIN - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - # Setup WordPress Network - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - ee_mod_setup_network - fi - # Update cache plugins - ee_mod_update_plugins - - # Lets update WprdPress multi sites with subdirectory - # WordPress multi sites with subdirectory can only update cache - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then - if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ]]; then - # Update NGINX configuration for $EE_DOMAIN - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - # Update cache plugins - ee_mod_update_plugins - - # Lets update WordPress multi sites with subdomain - # WordPress multi sites with subdomain can only update cache - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then - if [[ "$EE_SITE_CACHE_OPTION" = "--basic" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ]] \ - || [[ "$EE_SITE_CACHE_OPTION" = "--wpsc" && "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ]]; then - # Update NGINX configuration for $EE_DOMAIN - ee_mod_update_domain - else - ee_lib_error "$EE_DOMAIN already with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options, exit status" $? - fi - # Update cache plugins - ee_mod_update_plugins - else - ee_lib_error "Invalid update option, exit status =" $? - fi + if [ "$EE_UPDATE_WEBSITE" = "success" ]; then # Adjust permission ee_lib_permissions @@ -730,10 +689,15 @@ elif [ "$EE_FIRST" = "site" ]; then # Display Success Message ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN" + elif [[ "$EE_SECOND" = "update" && "$EE_SITE_CREATE_OPTION" = "--password" ]]; then + ee_lib_echo "This option is needed for updating WordPress website password" &> /dev/null + else + ee_lib_error "Invalid option, exit status = " $? fi + elif [ "$EE_SECOND" = "log" ]; then - # Display logs for websites - ee_mod_site_log ${@:3} + # Display logs for websites + ee_mod_site_log ${@:3} # EasyEngine cd elif [ "$EE_SECOND" = "cd" ]; then @@ -886,8 +850,8 @@ elif [ "$EE_FIRST" = "import-slow-log" ];then # EasyEngine update elif [ "$EE_FIRST" = "update" ]; then - ee_lib_echo "Checking EasyEngine(ee) update, please wait..." - wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup + ee_lib_echo "Run following command to update EasyEngine" + ee_lib_echo_info "wget --no-check-certificate -qO eeup http://rt.cx/eeup && sudo bash eeup" else ee_lib_echo "EasyEngine (ee) commands:" @@ -904,7 +868,7 @@ fi } -EasyEngine $@ | tee -ai $EE_COMMAND_LOG +EasyEngine $@ | tee -ai $EE_TEE_LOG # If any command fails its return non-zero exit code [EasyEngine $@] diff --git a/bin/install b/bin/install index 5238f341..38ff5d48 100644 --- a/bin/install +++ b/bin/install @@ -52,9 +52,9 @@ if [ "$EE_LINUX_DISTRO" != "Ubuntu" ] && [ "$EE_LINUX_DISTRO" != "Debian" ]; the fi # EasyEngine (ee) only support all Ubuntu/Debian distro except the distro reached EOL -lsb_release -d | egrep -e "12.04|14.04|squeeze|wheezy" &>> /dev/null +lsb_release -d | egrep -e "12.04|14.04|14.10|squeeze|wheezy" &>> /dev/null if [ "$?" -ne "0" ]; then - ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04 and Debian 6.x/7.x" + ee_lib_echo_fail "EasyEngine (ee) only support Ubuntu 12.04/14.04/14.10 and Debian 6.x/7.x" exit 100 fi @@ -124,7 +124,7 @@ if [ -z "$BRANCH" ]; then BRANCH=stable else # Cross check EasyEngine (ee) branch name - git ls-remote --heads https://github.com/rtCamp/easyengine | grep $BRANCH &>> $EE_INSTALL_LOG + git ls-remote --heads https://github.com/rtCamp/easyengine | grep ${BRANCH}$ &>> $EE_INSTALL_LOG if [ $? -ne 0 ]; then ee_lib_error "The $BRANCH branch does not exist, please provide the correct branch name, exit status = " $? fi diff --git a/config/bash_completion.d/ee b/config/bash_completion.d/ee index 7015fc94..d9244a3a 100644 --- a/config/bash_completion.d/ee +++ b/config/bash_completion.d/ee @@ -115,7 +115,7 @@ function EE_AUTO() if [ "$PREVIOUS2" = "create" ]; then COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "update" ]; then - COMPREPLY=( $( compgen -W "--php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) + COMPREPLY=( $( compgen -W "--password --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "delete" ]; then COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) fi diff --git a/config/nginx/common/wpcommon.conf b/config/nginx/common/wpcommon.conf index eb6c4918..91450a79 100644 --- a/config/nginx/common/wpcommon.conf +++ b/config/nginx/common/wpcommon.conf @@ -27,8 +27,10 @@ location /wp-content/uploads/ { location ~ ([^/]*)sitemap(.*)\.x(m|s)l$ { rewrite ^/sitemap\.xml$ /sitemap_index.xml permanent; rewrite ^/([a-z]+)?-?sitemap\.xsl$ /index.php?xsl=$1 last; - rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last; - rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; + + # Rules for yoast sitemap with wp|wpsubdir|wpsubdomain + rewrite ^.*/sitemap_index\.xml$ /index.php?sitemap=1 last; + rewrite ^.*/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; # Following lines are options. Needed for WordPress seo addons rewrite ^/news_sitemap\.xml$ /index.php?sitemap=wpseo_news last; diff --git a/config/nginx/common/wpsc.conf b/config/nginx/common/wpsc.conf index ccbb4216..26982e3d 100644 --- a/config/nginx/common/wpsc.conf +++ b/config/nginx/common/wpsc.conf @@ -24,7 +24,9 @@ if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_lo # Use cached or actual file if they exists, Otherwise pass request to WordPress location / { - try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php$args; + # If we add index.php?$args its break WooCommerce like plugins + # Ref: #330 + try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php; } location ~ \.php$ { diff --git a/src/lib/ee_lib_autoremove.sh b/src/lib/ee_lib_autoremove.sh index ab10a207..bdc9ae6a 100644 --- a/src/lib/ee_lib_autoremove.sh +++ b/src/lib/ee_lib_autoremove.sh @@ -3,5 +3,5 @@ function ee_lib_autoremove() { ee_lib_echo "Removing unwanted packages, please wait..." - $EE_APT_GET autoremove | tee -ai $EE_COMMAND_LOG + $EE_APT_GET autoremove } \ No newline at end of file diff --git a/src/lib/ee_lib_stack_packages.sh b/src/lib/ee_lib_stack_packages.sh index 332fd1f9..f17df84d 100644 --- a/src/lib/ee_lib_stack_packages.sh +++ b/src/lib/ee_lib_stack_packages.sh @@ -3,6 +3,11 @@ function ee_lib_stack_packages() { local ee_stack_package + # Log only single time + # ee site create example.com called ee stack install nginx + # So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null + # So in log file all logs written single time only + export EE_LOG=false for ee_stack_package in $@;do # Check NGINX installed & install if not @@ -11,6 +16,7 @@ function ee_lib_stack_packages() if [ "$EE_PACKAGE_NAME" != "" ]; then # Export EE_DISPLAY variable to Display ee http auth after site creation. export EE_DISPLAY=false + # The following command creates its own sub-shell # and our ee_lib_error function only exit from that sub-shell # so we need to exit from parent shell also diff --git a/src/lib/ee_lib_swap.sh b/src/lib/ee_lib_swap.sh index 5f9edba0..1cb20de7 100644 --- a/src/lib/ee_lib_swap.sh +++ b/src/lib/ee_lib_swap.sh @@ -17,6 +17,11 @@ function ee_lib_swap() mkswap /ee-swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to create swapfile, exit status = " $? + # Change Permission for swapfile + chown root:root /ee-swapfile && + chmod 0600 /ee-swapfile \ + || ee_lib_error "Unable to change Swapfile permission, exit status = " $? + # On the Swap swapon /ee-swapfile &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to on Swap, exit status = " $? diff --git a/src/lib/ee_lib_variables.sh b/src/lib/ee_lib_variables.sh index 1d6eaf83..45a7cb1e 100644 --- a/src/lib/ee_lib_variables.sh +++ b/src/lib/ee_lib_variables.sh @@ -18,6 +18,16 @@ readonly EE_VIMBADMIN_VERSION='3.0.10' # EasyEngine Date variable for backup readonly EE_DATE=$(date +%d%b%Y%H%M%S) +# Log only single time +# ee site create example.com called ee stack install nginx +# So when ee stack install nginx run in sub-shell the value of EE_TEE_LOG=/dev/null +# So in log file all logs written single time only +if [ -n "$EE_LOG" ]; then + EE_TEE_LOG=/dev/null +else + EE_TEE_LOG=/var/log/easyengine/ee.log +fi + EE_COMMAND_LOG=/var/log/easyengine/ee.log readonly EE_LOG_DIR=/var/log/easyengine readonly EE_ERROR_LOG=/var/log/easyengine/error.log diff --git a/src/modules/site/create/ee_mod_plugin_settings.sh b/src/modules/site/create/ee_mod_plugin_settings.sh new file mode 100644 index 00000000..e59347be --- /dev/null +++ b/src/modules/site/create/ee_mod_plugin_settings.sh @@ -0,0 +1,35 @@ +# Display WordPress cache plugin settings + +function ee_mod_plugin_settings() { + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" + else + ee_lib_echo_escape "Configure WPSC:\t\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=wpsupercache" + fi + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/network/settings.php?page=nginx" + else + ee_lib_echo_escape "Configure nginx-helper:\thttp://$EE_DOMAIN/wp-admin/options-general.php?page=nginx" + fi + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" + else + ee_lib_echo_escape "Configure W3TC:\t\thttp://$EE_DOMAIN/wp-admin/admin.php?page=w3tc_general" + fi + if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_lib_echo_escape "Page Cache:\t\tDisable" + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + ee_lib_echo_escape "Page Cache:\t\tDisk Enhanced" + fi + ee_lib_echo_escape "Database Cache:\t\tMemcached" + ee_lib_echo_escape "Object Cache:\t\tMemcached" + ee_lib_echo_escape "Browser Cache:\t\tDisable" + fi +} diff --git a/src/modules/site/create/ee_mod_setup_wordpress.sh b/src/modules/site/create/ee_mod_setup_wordpress.sh index 8f282095..e91d7a1d 100644 --- a/src/modules/site/create/ee_mod_setup_wordpress.sh +++ b/src/modules/site/create/ee_mod_setup_wordpress.sh @@ -15,6 +15,9 @@ function ee_mod_setup_wordpress() # else current mysql site is to be updated if [ "$EE_DB_NAME" = "" ] && [ "$EE_DB_USER" = "" ] && [ "$EE_DB_PASS" = "" ]; then ee_mod_setup_database + else + # Display when run ee site update mysql.com --wp + echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS \nEE_MYSQL_HOST = $EE_MYSQL_HOST \nEE_MYSQL_GRANT_HOST = $EE_MYSQL_GRANT_HOST" &>> $EE_COMMAND_LOG fi # Default WordPress prefix or custom prefix @@ -121,4 +124,21 @@ function ee_mod_setup_wordpress() ee_lib_echo "Updating WordPress permalink, please wait..." wp rewrite structure --allow-root /%year%/%monthnum%/%day%/%postname%/ &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to update WordPress permalink for $EE_DOMAIN, exit status = " $? + + # Setup WordPress Network + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi + + # Install WordPress plugins + ee_mod_plugin_nginx_helper + + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + ee_mod_plugin_wpsc + fi + + if [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_mod_plugin_w3tc + fi + } diff --git a/src/modules/site/ee_mod_site_backup.sh b/src/modules/site/ee_mod_site_backup.sh index f4268a34..13001912 100644 --- a/src/modules/site/ee_mod_site_backup.sh +++ b/src/modules/site/ee_mod_site_backup.sh @@ -5,33 +5,40 @@ function ee_mod_site_backup() # Backup directory setup local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/\/htdocs//') - if [ ! -d $ee_webroot/backup ] || [ ! -d $ee_webroot/backup/htdocs/$EE_DATE ] || [ ! -d $ee_webroot/backup/nginx/$EE_DATE ] || [ ! -d $ee_webroot/backup/db/$EE_DATE ]; then - mkdir -p $ee_webroot/backup/{htdocs/$EE_DATE,nginx/$EE_DATE,db/$EE_DATE} || ee_lib_error "Unable to create $ee_webroot/backup directory, exit status =" $? + if [ ! -d $ee_webroot/backup/$EE_DATE ]; then + mkdir -p $ee_webroot/backup/$EE_DATE || ee_lib_error "Fail to create backup directory, exit status =" $? fi + ee_lib_echo "Backup location: $ee_webroot/backup/$EE_DATE" + ee_lib_echo "Backup NGINX configuration, please wait..." + # Backup $EE_DOMAIN NGINX configuration + cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup NGINX configuration, exit status =" $? + # Move htdocs - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ]; then - ee_lib_echo "Backup webroot at $ee_webroot/backup/htdocs/$EE_DATE/, please wait..." - mv $ee_webroot/htdocs $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/htdocs to backup, exit status =" $? - mkdir -p $ee_webroot/htdocs + if [ "$EE_SITE_CURRENT_TYPE" = "--html" ] || [ "$EE_SITE_CURRENT_TYPE" = "--php" ] || [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ]; then + ee_lib_echo "Backup webroot, please wait..." + mv $ee_webroot/htdocs $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup webroot, exit status =" $? + ee_lib_echo "Setting up webroot, please wait..." + mkdir -p $ee_webroot/htdocs || ee_lib_error "Failed: Setting up webroot, exit status =" $? fi - ee_lib_echo "Backup NGINX configuration at $ee_webroot/backup/nginx/$EE_DATE/, please wait..." - # Backup $EE_DOMAIN NGINX configuration - cp /etc/nginx/sites-available/$EE_DOMAIN $ee_webroot/backup/nginx/$EE_DATE/ &>> $EE_COMMAND_LOG - # Database backup + # Check ee-config.php or wp-config.php present if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) - ee_lib_echo "Backup Database $ee_db_name at $ee_webroot/backup/db/$EE_DATE/, please wait..." - mysqldump $ee_db_name > $ee_webroot/backup/db/$EE_DATE/${ee_db_name}.sql \ - || ee_lib_error "Unable to dump ${ee_db_name}, exit status =" $? + ee_lib_echo "Backup Database, please wait..." + mysqldump $ee_db_name > $ee_webroot/backup/$EE_DATE/${ee_db_name}.sql \ + || ee_lib_error "Failed: Backup Database, exit status =" $? # Move ee-config.php and copy wp-config.php to backup if [ -f $ee_webroot/ee-config.php ]; then - mv $ee_webroot/ee-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/ee-config.php to backup, exit status =" $? + mv $ee_webroot/ee-config.php $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup ee-config.php, exit status =" $? else - cp $ee_webroot/wp-config.php $ee_webroot/backup/htdocs/$EE_DATE/ || ee_lib_error "Unable to move $ee_webroot/wp-config.php to backup, exit status =" $? + cp $ee_webroot/wp-config.php $ee_webroot/backup/$EE_DATE/ \ + || ee_lib_error "Failed: Backup wp-config.php, exit status =" $? fi fi } diff --git a/src/modules/site/ee_mod_site_info.sh b/src/modules/site/ee_mod_site_info.sh index fdbff096..805c8d51 100644 --- a/src/modules/site/ee_mod_site_info.sh +++ b/src/modules/site/ee_mod_site_info.sh @@ -7,7 +7,7 @@ function ee_mod_site_info() local ee_access_log=$(grep access_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) local ee_error_log=$(grep error_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) local ee_webroot=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | grep htdocs | awk '{print($2)}' | cut -d ';' -f1) - + ee_lib_echo "Information about $EE_DOMAIN:" ee_lib_echo_escape "\nNginx configuration\t \033[37m$ee_site_info ($ee_site_status)" ee_lib_echo_escape "access_log\t\t \033[37m$ee_access_log" @@ -16,17 +16,19 @@ function ee_mod_site_info() if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/') ]; then local ee_db_name=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + local ee_db_host=$(grep DB_HOST $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) local ee_db_user=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) local ee_db_pass=$(grep DB_PASS $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/*-config.php/' 2> /dev/null) | cut -d"'" -f4) + ee_lib_echo_escape "DB_HOST\t\t\t \033[37m$ee_db_host" ee_lib_echo_escape "DB_NAME\t\t\t \033[37m$ee_db_name" ee_lib_echo_escape "DB_USER\t\t\t \033[37m$ee_db_user" ee_lib_echo_escape "DB_PASS\t\t\t \033[37m$ee_db_pass" - + if [ -f $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') ]; then local ee_table_prefix=$(grep table_prefix $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed 's/htdocs/wp-config.php/') | cut -d"'" -f2) ee_lib_echo_escape "table_prefix\t\t \033[37m$ee_table_prefix" - fi + fi fi } diff --git a/src/modules/site/ee_mod_site_option.sh b/src/modules/site/ee_mod_site_option.sh index 4c7f0e55..924858f1 100644 --- a/src/modules/site/ee_mod_site_option.sh +++ b/src/modules/site/ee_mod_site_option.sh @@ -34,4 +34,15 @@ function ee_mod_site_option() if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_CREATE_OPTION" != "--html" ] && [ "$EE_SITE_CREATE_OPTION" != "--php" ] && [ "$EE_SITE_CREATE_OPTION" != "--mysql" ]; then EE_SITE_CACHE_OPTION=--basic fi + + # Kick out for invalid cache option + if [[ "$EE_SECOND" = "update" && "$EE_SITE_CREATE_OPTION" = "--password" ]]; then + ee_lib_echo "This option is needed for updating WordPress website password" &> /dev/null + elif [[ "$EE_SITE_CREATE_OPTION" != "--html" && "$EE_SITE_CREATE_OPTION" != "--php" && "$EE_SITE_CREATE_OPTION" != "--mysql" && "$EE_SITE_CREATE_OPTION" != "--wp" && "$EE_SITE_CREATE_OPTION" != "--wpsubdir" && "$EE_SITE_CREATE_OPTION" != "--wpsubdomain" ]]; then + ee_lib_error "Invalid website type $EE_SITE_CREATE_OPTION, exit status = " $? + elif [[ "$EE_SITE_CREATE_OPTION" = "--html" || "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]] && [ -n "$EE_SITE_CACHE_OPTION" ]; then + ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION for $EE_SITE_CREATE_OPTION website, exit status = " $? + elif [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--basic" && "$EE_SITE_CACHE_OPTION" != "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then + ee_lib_error "Invalid cache option $EE_SITE_CACHE_OPTION, exit status = " $? + fi } diff --git a/src/modules/site/ee_mod_site_packages.sh b/src/modules/site/ee_mod_site_packages.sh index 9cf69368..66a19a42 100644 --- a/src/modules/site/ee_mod_site_packages.sh +++ b/src/modules/site/ee_mod_site_packages.sh @@ -17,10 +17,11 @@ function ee_mod_site_packages() ee_lib_stack_packages mysql fi + # Check & Install Postfix Packages + ee_lib_stack_packages postfix + if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then # Install WP-CLI ee_ven_install_wpcli fi - # Check & Install Postfix Packages - ee_lib_stack_packages postfix } diff --git a/src/modules/site/update/ee_mod_site_update_password.sh b/src/modules/site/update/ee_mod_site_update_password.sh index f8055b57..5335ad9d 100644 --- a/src/modules/site/update/ee_mod_site_update_password.sh +++ b/src/modules/site/update/ee_mod_site_update_password.sh @@ -12,7 +12,15 @@ ee_mod_site_update_password() if [ $? -eq 0 ]; then read -p "Provide WordPress user name [admin]: " ee_wp_user - if [[ $ee_wp_user = "" ]]; then + + # If user enter ? mark then show list of WordPress users + if [ "$ee_wp_user" = "?" ]; then + ee_lib_echo "Fetching WordPress user list, please wait..." + wp --allow-root user list --fields=user_login | grep -v user_login + read -p "Provide WordPress user name [admin]: " ee_wp_user + fi + + if [ "$ee_wp_user" = "" ]; then ee_wp_user=admin fi @@ -22,12 +30,13 @@ ee_mod_site_update_password() read -sp "Provide password for $ee_wp_user user: " ee_wp_pass echo if [[ ${#ee_wp_pass} -ge 8 ]]; then - wp --allow-root user update "${ee_wp_user}" --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG + wp --allow-root user update "${ee_wp_user}" --user_pass=$ee_wp_pass &>> $EE_COMMAND_LOG && \ + ee_lib_echo "Password updated successfully" else ee_lib_error "Password Unchanged. Hint : Your password must be 8 characters long, exit status = " $? fi else - ee_lib_error "Invalid WordPress user $ee_wp_user for $EE_DOMAIN, exit status = " $? + ee_lib_error "Invalid WordPress user $ee_wp_user for $EE_DOMAIN, exit status = " $? fi fi } diff --git a/src/modules/site/update/ee_mod_update_domain.sh b/src/modules/site/update/ee_mod_update_domain.sh deleted file mode 100644 index 00d4224c..00000000 --- a/src/modules/site/update/ee_mod_update_domain.sh +++ /dev/null @@ -1,93 +0,0 @@ -# Update NGINX configuration for $EE_DOMAIN - -function ee_mod_update_domain() -{ - # Git commit - ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_OPTION" - # Backup NGINX configuration & Database & Webroot - ee_mod_site_backup - - # Creating $EE_DOMAIN - ee_lib_echo "Updating $EE_DOMAIN, please wait..." - if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then - EE_SITE_CURRENT_CONF=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") - EE_SITE_UPDATE_CONF=$(head -n1 /usr/share/easyengine/nginx/$EE_NGINX_CONF | grep "NGINX CONFIGURATION") - EE_SITE_NGINX_CONF="/etc/nginx/sites-available/$EE_DOMAIN" - - # Update Head Line of NGINX conf - sed -i "s'$EE_SITE_CURRENT_CONF'$EE_SITE_UPDATE_CONF'" $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - - # Update Head Line of NGINX conf file - if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN BASIC" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR BASIC" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ];then - sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_NGINX_CONF && \ - sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_NGINX_CONF && \ - sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_NGINX_CONF && \ - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf for HTML site - if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ]; then - sed -i 's/access\.log/access.log rt_cache/' $EE_SITE_NGINX_CONF && \ - sed -i '/index index.html index.htm;$/d' $EE_SITE_NGINX_CONF && \ - sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_CREATE_OPTION" = "--php" || "$EE_SITE_CREATE_OPTION" = "--mysql" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from BASIC CACHE to WPFC|W3TC|WPSC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE BASIC" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR BASIC" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN BASIC" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/php.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/php.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/php.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from W3TC CACHE to BASIC|WPSC|WPFC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/w3tc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from WPFC CACHE to BASIC|W3TC|WPSC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpfc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - # Update NGINX conf from WPSC CACHE to BASIC|W3TC|WPFC CACHE - elif [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ]; then - if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - sed -i 's/include common\/wpsc.conf/include common\/php.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then - sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then - sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - fi - - # Update NGINX conf from HTML|PHP|MYSQL to wp|wpsubdir|wpsubdomain - if [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]] \ - && [[ "$EE_SITE_CURRENT_OPTION" = "HTML" || "$EE_SITE_CURRENT_OPTION" = "PHP" || "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]]; then - sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_NGINX_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? - fi - else - ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? - fi -} diff --git a/src/modules/site/update/ee_mod_update_nginx.sh b/src/modules/site/update/ee_mod_update_nginx.sh new file mode 100644 index 00000000..aa5156fe --- /dev/null +++ b/src/modules/site/update/ee_mod_update_nginx.sh @@ -0,0 +1,129 @@ +# Update NGINX configuration for $EE_DOMAIN + +function ee_mod_update_nginx() +{ + # Git commit + ee_lib_git /etc/nginx/ "Before ee site update: $EE_DOMAIN running on $EE_SITE_CURRENT_TYPE" + + # Update NGINX configuration + ee_lib_echo "Updating $EE_DOMAIN, please wait..." + + if [ -f /etc/nginx/sites-available/$EE_DOMAIN ]; then + # Find out current NGINX configuration header + ee_nginx_current_header=$(head -n1 /etc/nginx/sites-available/$EE_DOMAIN | grep "NGINX CONFIGURATION") + + # Update NGINX configuration header + if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + ee_nginx_conf=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf + elif [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + ee_nginx_conf=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf + fi + ee_nginx_update_header=$(head -n1 /usr/share/easyengine/nginx/$ee_nginx_conf | grep "NGINX CONFIGURATION") + + # Echo values + echo -e "EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK \nEE_SITE_CREATE_OPTION = $EE_SITE_CREATE_OPTION \nEE_SITE_CACHE_OPTION = $EE_SITE_CACHE_OPTION \nEE_NETWORK_ACTIVATE = $EE_NETWORK_ACTIVATE \nEE_WP_SUBDOMAIN = $EE_WP_SUBDOMAIN \nee_nginx_update_header = $ee_nginx_update_header" &>> $EE_COMMAND_LOG + + # Update Head Line of NGINX conf + sed -i "s'$ee_nginx_current_header'$ee_nginx_update_header'" /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + + # Update NGINX conf for HTML site + if [ "$EE_SITE_CURRENT_TYPE" = "--html" ]; then + sed -i 's/access\.log/access.log rt_cache/' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/index index.html index.htm;$/c \\tindex index.php index.htm index.html;' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/location \/ {/,/}/d ' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + + # Update HTML to PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) options + if [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + # Update HTML to --wpsc (--wp/--wpsubdir/--wpsubdomain) options + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + # Update HTML to --w3tc (--wp/--wpsubdir/--wpsubdomain) options + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + # Update HTML to --wpfc (--wp/--wpsubdir/--wpsubdomain) options + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + + # Update PHP MySQL --basic (--wp/--wpsubdir/--wpsubdomain) to --wpsc --w3tc --wpfc options + elif [ "$EE_SITE_CURRENT_TYPE" = "--php" ] || [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wp --basic" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --basic" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --basic" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/php.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/php.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/php.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + + # Update --wpsc (--wp/--wpsubdir/--wpsubdomain) to --basic --w3tc --wpfc options + elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --wpsc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpsc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpsc" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/wpsc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/wpsc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + + # Update --w3tc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --wpfc options + elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --w3tc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --w3tc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --w3tc" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/w3tc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ]; then + sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + + # Update --wpfc (--wp/--wpsubdir/--wpsubdomain) to --basic --wpsc --w3tc options + elif [ "$EE_SITE_CURRENT_TYPE" = "--wp --wpfc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdir --wpfc" ] || [ "$EE_SITE_CURRENT_TYPE" = "--wpsubdomain --wpfc" ]; then + if [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then + sed -i 's/include common\/wpfc.conf/include common\/php.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ]; then + sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf/' /etc/nginx/sites-available/$EE_DOMAIN \ + || ee_lib_error "Unable to update NGINX configuration to $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $? + fi + fi + + # Add WordPress common file wpcommon.conf for HTML PHP & MYSQL sites + if [[ "$EE_SITE_CURRENT_TYPE" = "--html" || "$EE_SITE_CURRENT_TYPE" = "--php" || "$EE_SITE_CURRENT_TYPE" = "--mysql" ]] && \ + [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]]; then + sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + + # Update server_name for HTML PHP MYSQL WP (single site) only + # Don't execute for WordPress Multisite + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] \ + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --basic" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --basic" ] \ + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpsc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpsc" ] \ + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --w3tc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --w3tc" ] \ + && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdir --wpfc" ] && [ "$EE_SITE_CURRENT_TYPE" != "--wpsubdomain --wpfc" ]; then + + sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' /etc/nginx/sites-available/$EE_DOMAIN && \ + sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' /etc/nginx/sites-available/$EE_DOMAIN || ee_lib_error "Unable to update nginx configuration to $EE_SITE_CREATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $? + fi + else + ee_lib_error "Unable to find $EE_DOMAIN NGINX configuration, exit status =" $? + fi +} diff --git a/src/modules/site/update/ee_mod_update_plugins.sh b/src/modules/site/update/ee_mod_update_plugins.sh deleted file mode 100644 index b50df163..00000000 --- a/src/modules/site/update/ee_mod_update_plugins.sh +++ /dev/null @@ -1,31 +0,0 @@ -# Update cache plugins - -function ee_mod_update_plugins() -{ - cd /var/www/$EE_DOMAIN/htdocs/ - - if [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN W3 TOTAL CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--basic" || "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then - ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." - wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG - fi - - if [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDOMAIN WP SUPER CACHE" ] || [ "$EE_SITE_CURRENT_OPTION" = "WPSINGLE WP SUPER CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" = "WPSUBDIR WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--basic" ]; then - ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." - - wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG - fi - - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE WP SUPER CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR WP SUPER CACHE" ] \ - && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN WP SUPER CACHE" ] && [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ]; then - ee_mod_plugin_wpsc - fi - - if [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR W3 TOTAL CACHE" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN W3 TOTAL CACHE" ] && [ "$EE_SITE_CURRENT_OPTION" != "WPSINGLE FAST CGI" ] || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDIR FAST CGI" ] \ - || [ "$EE_SITE_CURRENT_OPTION" != "WPSUBDOMAIN FAST CGI" ] && [[ "$EE_SITE_CACHE_OPTION" = "--wpfc" || "$EE_SITE_CACHE_OPTION" = "--w3tc" ]]; then - ee_mod_plugin_w3tc - fi -} diff --git a/src/modules/site/update/ee_mod_update_website.sh b/src/modules/site/update/ee_mod_update_website.sh new file mode 100644 index 00000000..17224714 --- /dev/null +++ b/src/modules/site/update/ee_mod_update_website.sh @@ -0,0 +1,90 @@ +# Update Websites + +function ee_mod_update_website() { + # Let's take backup first + ee_mod_site_backup + + # Install required packages + ee_mod_site_packages + + # Let's start update + ee_mod_update_nginx + + # Setup MySQL database for HTML|PHP websites + if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then + ee_mod_setup_database + + # Add Database Information On ee-config.php + echo -e "define('DB_NAME', '$EE_DB_NAME'); \ndefine('DB_USER', '$EE_DB_USER'); \ndefine('DB_PASSWORD', '$EE_DB_PASS'); \ndefine('DB_HOST', '$EE_MYSQL_HOST');" \ + &>> /var/www/$EE_DOMAIN/ee-config.php + fi + + # Use same database when update MySQL website updated to WordPress + if [ "$EE_SITE_CURRENT_TYPE" = "--mysql" ]; then + # Use same database for WordPress + EE_DB_NAME=$(grep DB_NAME $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_USER=$(grep DB_USER $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + EE_DB_PASS=$(grep DB_PASSWORD $(grep root /etc/nginx/sites-available/$EE_DOMAIN | awk '{ print $2 }' | sed 's/;//g' | sed "s'htdocs'backup/$EE_DATE/ee-config.php'" 2> /dev/null) | cut -d"'" -f4) + fi + + # Setup/Install WordPress for HTML|PHP|MySQL websites + if [[ "$EE_SITE_CURRENT_TYPE" = "--html" || "$EE_SITE_CURRENT_TYPE" = "--php" || "$EE_SITE_CURRENT_TYPE" = "--mysql" ]] && + [[ "$EE_SITE_CREATE_OPTION" = "--wp" || "$EE_SITE_CREATE_OPTION" = "--wpsubdir" || "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]]; then + # Setup WordPress + ee_mod_setup_wordpress + + # Display WordPress credential + echo + ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" + ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" + echo + + # Display WordPress cache plugin settings + ee_mod_plugin_settings + + # Update WordPress Websites + elif [[ "$EE_SITE_CURRENT_WP" = "--wp" || "$EE_SITE_CURRENT_WP" = "--wpsubdir" || "$EE_SITE_CURRENT_WP" = "--wpsubdomain" ]]; then + # Setup WordPress Network for --wp websites + if [[ "$EE_SITE_CURRENT_WP" = "--wp" ]]; then + if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then + ee_mod_setup_network + fi + fi + + # Uninstall unwanted plugins + # Current site type: --wp --wpsc + # Update site type: --wpsubdomain --wpsc + # Only delete plugin when current cache is --wpsc and update cache is not --wpsc + if [[ "$EE_SITE_CURRENT_CACHE" = "--wpsc" && "$EE_SITE_CACHE_OPTION" != "--wpsc" ]]; then + cd /var/www/$EE_DOMAIN/htdocs/ + ee_lib_echo "Unistalling WP Super Cache plugin, please wait..." + wp plugin --allow-root uninstall wp-super-cache &>> $EE_COMMAND_LOG + fi + + # Delete plugin when current cache is --w3tc|--wpfc and update cache is not --w3tc|--wpfc + if [[ "$EE_SITE_CURRENT_CACHE" = "--w3tc" || "$EE_SITE_CURRENT_CACHE" = "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" != "--w3tc" && "$EE_SITE_CACHE_OPTION" != "--wpfc" ]]; then + cd /var/www/$EE_DOMAIN/htdocs/ + ee_lib_echo "Uninstalling W3 Total Cache plugin, please wait..." + wp plugin --allow-root uninstall w3-total-cache &>> $EE_COMMAND_LOG + fi + + # Install WordPress plugins + # As nginx-helper is installed all type of WordPress + # We don't need to install it again + #ee_mod_plugin_nginx_helper + + if [[ "$EE_SITE_CURRENT_CACHE" != "--wpsc" && "$EE_SITE_CACHE_OPTION" = "--wpsc" ]]; then + ee_mod_plugin_wpsc + fi + + if [[ "$EE_SITE_CURRENT_CACHE" != "--w3tc" && "$EE_SITE_CURRENT_CACHE" != "--wpfc" ]] && [[ "$EE_SITE_CACHE_OPTION" = "--w3tc" || "$EE_SITE_CACHE_OPTION" = "--wpfc" ]]; then + ee_mod_plugin_w3tc + fi + + # Display WordPress cache plugin settings + ee_mod_plugin_settings + fi + + # Use this variable to detect and change ownership, reload nginx, + EE_UPDATE_WEBSITE="success" +} \ No newline at end of file diff --git a/src/modules/stack/install/ee_mod_install_php.sh b/src/modules/stack/install/ee_mod_install_php.sh index db30fadd..a3738ef7 100644 --- a/src/modules/stack/install/ee_mod_install_php.sh +++ b/src/modules/stack/install/ee_mod_install_php.sh @@ -5,5 +5,5 @@ function ee_mod_install_php() ee_lib_echo "Installing PHP, please wait..." $EE_APT_GET install php5-common php5-mysqlnd php5-xmlrpc \ php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt php5-xdebug \ - php5-memcache memcached php5-geoip || ee_lib_error "Unable to install PHP5, exit status = " $? + php5-memcache memcached php5-geoip 2>&1 || ee_lib_error "Unable to install PHP5, exit status = " $? } diff --git a/src/modules/stack/install/ee_mod_setup_mysql.sh b/src/modules/stack/install/ee_mod_setup_mysql.sh index b83ffd8a..a8ba0263 100644 --- a/src/modules/stack/install/ee_mod_setup_mysql.sh +++ b/src/modules/stack/install/ee_mod_setup_mysql.sh @@ -6,11 +6,11 @@ function ee_mod_setup_mysql() # Setting wait_timeout = 30 & interactive_timeout = 60 if [ ! -f /etc/mysql/my.cnf ]; then - echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60" > /etc/mysql/my.cnf + echo -e "[mysqld] \nwait_timeout = 30 \ninteractive_timeout = 60 \nperformance_schema = 0" > /etc/mysql/my.cnf else grep "_timeout" /etc/mysql/my.cnf &>> $EE_COMMAND_LOG if [ $? -ne 0 ]; then - sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60" /etc/mysql/my.cnf + sed -i "/#max_connections/a wait_timeout = 30 \ninteractive_timeout = 60 \nperformance_schema = 0" /etc/mysql/my.cnf fi fi } diff --git a/src/modules/stack/install/ee_mod_setup_nginx.sh b/src/modules/stack/install/ee_mod_setup_nginx.sh index b280d4dc..4257c6b7 100644 --- a/src/modules/stack/install/ee_mod_setup_nginx.sh +++ b/src/modules/stack/install/ee_mod_setup_nginx.sh @@ -21,7 +21,7 @@ function ee_mod_setup_nginx() # Disable nginx version # Set custom header # SSL Settings - sed -i "s/http {/http {\n\t##\n\t# EasyEngine Settings\n\t##\n\n\tserver_tokens off;\n\treset_timedout_connection on;\n\tadd_header X-Powered-By \"EasyEngine $EE_VERSION\";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n/" /etc/nginx/nginx.conf + sed -i "s/http {/http {\n\t##\n\t# EasyEngine Settings\n\t##\n\n\tserver_tokens off;\n\treset_timedout_connection on;\n\tadd_header X-Powered-By \"EasyEngine $EE_VERSION\";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\t# Fix POODLE attack\n\tssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n\n/" /etc/nginx/nginx.conf # Adjust nginx keepalive_timeout sed -i "s/keepalive_timeout.*/keepalive_timeout 30;/" /etc/nginx/nginx.conf diff --git a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh index 09225e4b..fafb37d8 100644 --- a/src/modules/stack/install/mail/ee_mod_install_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_install_dovecot.sh @@ -11,12 +11,13 @@ function ee_mod_install_dovecot() debconf-set-selections <<< "dovecot-core dovecot-core/create-ssl-cert boolean yes" debconf-set-selections <<< "dovecot-core dovecot-core/ssl-cert-name string $(hostname -f)" + # 2>&1 is needed as config file is written in STDEER # Debian 6 doesn't provide Dovecot 2.x if [ "$EE_DEBIAN_VERSION" == "squeeze" ]; then - $EE_APT_GET -t squeeze-backports install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ + $EE_APT_GET -t squeeze-backports install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved 2>&1 \ || ee_lib_error "Unable to install Dovecot, exit status = " $? else - $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved \ + $EE_APT_GET install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved 2>&1 \ || ee_lib_error "Unable to install Dovecot, exit status = " $? fi diff --git a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh index 2b1e62ad..76126c8e 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_dovecot.sh @@ -22,7 +22,7 @@ function ee_mod_setup_dovecot() # Configuring 10-mail.conf sed -i "s/mail_location = mbox:~\/mail:INBOX=\/var\/mail\/%u/mail_location = maildir:\/var\/vmail\/%d\/%n/" /etc/dovecot/conf.d/10-mail.conf \ || ee_lib_error "Unable to configure Dovecot mail_location, exit status = " $? - + # Configuring 10-auth.conf sed -i "s/#disable_plaintext_auth = yes/disable_plaintext_auth = no/" /etc/dovecot/conf.d/10-auth.conf && \ sed -i "s/auth_mechanisms = plain/auth_mechanisms = plain login/" /etc/dovecot/conf.d/10-auth.conf && \ @@ -30,6 +30,16 @@ function ee_mod_setup_dovecot() sed -i "s/#\!include auth-sql.conf.ext/\!include auth-sql.conf.ext/" /etc/dovecot/conf.d/10-auth.conf \ || ee_lib_error "Unable to setup 10-auth.conf file, exit status = " $? + # Configuring 10-ssl.conf, Disable SSLv2 and SSLv3, Fixes POODLE Bug + grep ssl_protocols /etc/dovecot/conf.d/10-ssl.conf &>> $EE_COMMAND_LOG + if [ $? -eq 0 ]; then + # For Ubuntu 14.04, Debian 6 and Debian 7 10-ssl.conf file contains commented #ssl_protocol variable + sed -i "s/#ssl_protocols =.*/ssl_protocols = \!SSLv2 \!SSLv3/" /etc/dovecot/conf.d/10-ssl.conf + else + # For Ubuntu 12.04 10-ssl.conf file does not contain commented #ssl-protocols variable + echo 'ssl_protocols = !SSLv2 !SSLv3' >> /etc/dovecot/conf.d/10-ssl.conf + fi + # Configuring dovecot-sql.conf.ext cp -v /usr/share/easyengine/mail/dovecot-sql.conf.ext /etc/dovecot/dovecot-sql.conf.ext &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable to copy dovecot-sql.conf.ext, exit status = " $? diff --git a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh index 6ffbf518..8beab678 100644 --- a/src/modules/stack/install/mail/ee_mod_setup_postfix.sh +++ b/src/modules/stack/install/mail/ee_mod_setup_postfix.sh @@ -33,6 +33,12 @@ function ee_mod_setup_postfix() postconf -e "smtpd_relay_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination" + # Disable SSL for POODLE + postconf -e "smtpd_tls_mandatory_protocols=!SSLv2,!SSLv3" + postconf -e "smtp_tls_mandatory_protocols=!SSLv2,!SSLv3" + postconf -e "smtpd_tls_protocols=!SSLv2,!SSLv3" + postconf -e "smtp_tls_protocols=!SSLv2,!SSLv3" + # other destination domains should be handled using virtual domains postconf -e "mydestination = localhost" @@ -44,6 +50,7 @@ function ee_mod_setup_postfix() postconf -e "virtual_gid_maps = static:5000" postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_domains_maps.cf" postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf" + postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf" #postconf "message_size_limit = 20971520" diff --git a/src/vendor/ee_ven_install_vimbadmin.sh b/src/vendor/ee_ven_install_vimbadmin.sh index 4f1d23a9..e76ac0a5 100644 --- a/src/vendor/ee_ven_install_vimbadmin.sh +++ b/src/vendor/ee_ven_install_vimbadmin.sh @@ -11,6 +11,9 @@ function ee_ven_install_vimbadmin() # Install ViMbAdmin ee_lib_echo "Installing ViMbAdmin, please wait..." ee_lib_echo "It will take nearly 10-20 minutes, please wait..." + mkdir -p /var/www/22222/htdocs/ \ + || ee_lib_error "Unable to create ViMbAdmin Directory, exit status = " $? + wget -cqO /var/www/22222/htdocs/vimbadmin.tar.gz https://github.com/opensolutions/ViMbAdmin/archive/${EE_VIMBADMIN_VERSION}.tar.gz \ || ee_lib_error "Unable to download ViMbAdmin, exit status = " $? @@ -25,7 +28,7 @@ function ee_ven_install_vimbadmin() || ee_lib_error "Unable to install ViMbAdmin, exit status = " $? # Fix permissions - chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/22222/htdocs/vimbadmin \ + chown -R $EE_PHP_USER:$EE_PHP_USER /var/www/22222/ \ || ee_lib_error "Unable to change ownership for ViMbAdmin, exit status = " $? # Remove unwanted files diff --git a/src/vendor/ee_ven_remove_utils.sh b/src/vendor/ee_ven_remove_utils.sh index 5772c4da..ec6f4067 100644 --- a/src/vendor/ee_ven_remove_utils.sh +++ b/src/vendor/ee_ven_remove_utils.sh @@ -8,6 +8,5 @@ function ee_ven_remove_utils() || ee_lib_error "Unable to remove EasyEngine (ee) admin utilities" # Drop Anemometer database - mysql -e "drop database if exists slow_query_log" \ - || ee_lib_error "Unable to drop slow_query_log database, exit status = " $? + mysql -e "drop database if exists slow_query_log" &>> $EE_COMMAND_LOG } diff --git a/templates/nginx/wp/wpfc.conf b/templates/nginx/wp/wpfc.conf index ba35bfae..68c33a51 100644 --- a/templates/nginx/wp/wpfc.conf +++ b/templates/nginx/wp/wpfc.conf @@ -1,4 +1,4 @@ -# WPSINGLE FAST CGI NGINX CONFIGURATION +# WPSINGLE FASTCGI NGINX CONFIGURATION server { diff --git a/templates/nginx/wpsubdir/wpfc.conf b/templates/nginx/wpsubdir/wpfc.conf index 6e59806c..556cefda 100644 --- a/templates/nginx/wpsubdir/wpfc.conf +++ b/templates/nginx/wpsubdir/wpfc.conf @@ -1,4 +1,4 @@ -# WPSUBDIR FAST CGI NGINX CONFIGURATION +# WPSUBDIR FASTCGI NGINX CONFIGURATION server { diff --git a/templates/nginx/wpsubdomain/wpfc.conf b/templates/nginx/wpsubdomain/wpfc.conf index 56e93a95..a2e02c85 100644 --- a/templates/nginx/wpsubdomain/wpfc.conf +++ b/templates/nginx/wpsubdomain/wpfc.conf @@ -1,4 +1,4 @@ -# WPSUBDOMAIN FAST CGI NGINX CONFIGURATION +# WPSUBDOMAIN FASTCGI NGINX CONFIGURATION server {