Browse Source

Reuse code and comment codes

old-stable
Mitesh Shah 10 years ago
parent
commit
242db56227
  1. 134
      bin/easyengine
  2. 34
      src/modules/site/ee_mod_site_option.sh
  3. 46
      src/modules/site/update/ee_mod_update_domain.sh

134
bin/easyengine

@ -45,12 +45,13 @@ elif [ "$EE_FIRST" = "info" ];then
elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
# EasyEngine install
if [ "$EE_SECOND" = "install" ]; then
# Detect RAM of system and initialize the variables.
# EasyEngine RAM based settings
ee_lib_ram
# EasyEngine Swap creation
ee_lib_swap
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
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then
# Setup NGINX/PHP repository
# Setup NGINX/PHP/Percona MySQL repository
ee_mod_repo_$EE_THIRD
# Fix GnuPG key
@ -93,9 +94,9 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
# Display success message
ee_lib_echo "$EE_THIRD successfully installed"
elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then
elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then
if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then
# Setup NGINX/PHP/MySQL repository
# Setup NGINX/PHP/Percona MySQL repository
ee_mod_repo_nginx
ee_mod_repo_php
ee_mod_repo_mysql
@ -126,12 +127,11 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
# Install WP-CLI
ee_ven_install_wpcli
fi
if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then
# Install Adminer/phpMyAdmin/Utils
ee_ven_install_adminer
ee_ven_install_phpmyadmin
ee_ven_install_utils
fi
# Display success message
if [ "$EE_THIRD" != "all" ];then
ee_lib_echo "Successfully installed $([ "$EE_THIRD" != "" ] && echo $EE_THIRD || echo "web" ) server packages"
@ -247,7 +247,7 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
elif [ "$EE_SECOND" = "purge" ];then
ee_lib_echo "$EE_THIRD successfully purged"
fi
elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then
elif [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "admin" ] ; then
if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then
# Remove/Purge NGINX/PHP/MySQL/Postfix package
ee_mod_remove_nginx
@ -258,12 +258,10 @@ elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
# Remove/Purge WP-CLI
ee_ven_remove_wpcli
fi
if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "admin" ] || [ "$EE_THIRD" = "all" ]; then
# Remove/Purge Adminer/phpMyAdmin/Utils
ee_ven_remove_adminer
ee_ven_remove_phpmyadmin
ee_ven_remove_utils
fi
# Execute: apt-get autoremove
ee_lib_autoremove
@ -420,49 +418,27 @@ elif [ "$EE_FIRST" = "site" ]; then
EE_SITE_CREATE_OPTION=$EE_FOURTH
EE_SITE_CACHE_OPTION=$EE_FIFTH
# Auto switch options
if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then
if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then
EE_SITE_CREATE_OPTION=$EE_FIFTH
EE_SITE_CACHE_OPTION=$EE_FOURTH
else
EE_SITE_CREATE_OPTION=--wp
EE_SITE_CACHE_OPTION=$EE_FOURTH
fi
fi
# WordPresss subdirectory variables
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then
EE_SITE_CREATE_OPTION="--wpsubdir"
EE_NETWORK_ACTIVATE="--network"
fi
# WordPress sub-domain variables
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
EE_SITE_CREATE_OPTION="--wpsubdomain"
EE_NETWORK_ACTIVATE="--network"
EE_WP_SUBDOMAIN="--subdomains"
fi
# Use default whenever possible
if [ "$EE_SITE_CREATE_OPTION" = "" ]; then
EE_SITE_CREATE_OPTION=--html
fi
# For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_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
# Auto switch site options
ee_mod_site_option
if [ "$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
# Check & Install NGINX Packages
ee_lib_stack_packages nginx
fi
if [ "$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
# Check & Install PHP Packages
ee_lib_stack_packages php
fi
if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
# Check & Install Percona MySQL Packages
ee_lib_stack_packages mysql
fi
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
# Lets create HTML|PHP|MySQL website
@ -623,69 +599,43 @@ elif [ "$EE_FIRST" = "site" ]; then
elif [ "$EE_SECOND" = "update" ]; then
# Configure variables
EE_DOMAIN_CHECK=$EE_THIRD
EE_SITE_UPDATE_OPTION=$EE_FOURTH
EE_SITE_CREATE_OPTION=$EE_FOURTH
EE_SITE_CACHE_OPTION=$EE_FIFTH
# 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 = " $?
if [ "$EE_SITE_UPDATE_OPTION" = "--password" ]; then
if [ "$EE_SITE_CREATE_OPTION" = "--password" ]; then
ee_mod_site_update_password
else
# Auto switch options
if [ "$EE_SITE_UPDATE_OPTION" = "--basic" ] || [ "$EE_SITE_UPDATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpfc" ]; then
if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then
EE_SITE_UPDATE_OPTION=$EE_FIFTH
EE_SITE_CACHE_OPTION=$EE_FOURTH
else
EE_SITE_UPDATE_OPTION=--wp
EE_SITE_CACHE_OPTION=$EE_FOURTH
fi
fi
# WordPresss subdirectory variables
if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdirectory" ]; then
EE_SITE_UPDATE_OPTION="--wpsubdir"
EE_NETWORK_ACTIVATE="--network"
fi
# WordPress sub-domain variables
if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
EE_SITE_UPDATE_OPTION="--wpsubdomain"
EE_NETWORK_ACTIVATE="--network"
EE_WP_SUBDOMAIN="--subdomains"
fi
# Use default whenever possible
if [ "$EE_SITE_UPDATE_OPTION" = "" ]; then
EE_SITE_UPDATE_OPTION=--html
fi
# For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_OPTION
if [ "$EE_SITE_CACHE_OPTION" = "" ] && [ "$EE_SITE_UPDATE_OPTION" != "--html" ] && [ "$EE_SITE_UPDATE_OPTION" != "--php" ] && [ "$EE_SITE_UPDATE_OPTION" != "--mysql" ]; then
EE_SITE_CACHE_OPTION=--basic
fi
# 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_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ]; then
EE_NGINX_CONF=$(echo $EE_SITE_UPDATE_OPTION | cut -c3-)/basic.conf
elif [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
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_UPDATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf
EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf
fi
fi
# Install required packages
if [ "$EE_SITE_UPDATE_OPTION" = "--html" ] || [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
if [ "$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_stack_packages nginx
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--php" ] || [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
if [ "$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_stack_packages php
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--mysql" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
if [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] || [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
ee_lib_stack_packages mysql
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
ee_ven_install_wpcli
fi
ee_lib_stack_packages postfix
@ -693,21 +643,21 @@ elif [ "$EE_FIRST" = "site" ]; then
# Lets update HTML|PHP|MySQL website
if [ "$EE_SITE_CURRENT_OPTION" = "HTML" ] || [ "$EE_SITE_CURRENT_OPTION" = "PHP" ] || [ "$EE_SITE_CURRENT_OPTION" = "MYSQL" ]; then
if [[ "$EE_SITE_UPDATE_OPTION" = "--php" && "$EE_SITE_CURRENT_OPTION" != "PHP" ]] || [[ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]] \
|| [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then
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
# Update NGINX
ee_mod_update_domain
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then
if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then
ee_mod_setup_wordpress
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
ee_mod_setup_network
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then
if [ "$EE_SITE_CREATE_OPTION" = "--wp" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then
# Install WordPress plugins
ee_mod_plugin_nginx_helper
fi
@ -715,7 +665,7 @@ elif [ "$EE_FIRST" = "site" ]; then
ee_mod_update_cache
# Setup MySQL database
if [[ "$EE_SITE_UPDATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then
if [[ "$EE_SITE_CREATE_OPTION" = "--mysql" && "$EE_SITE_CURRENT_OPTION" != "MYSQL" ]]; then
ee_mod_setup_database
# Add Database Information On ee-config.php
@ -723,7 +673,7 @@ elif [ "$EE_FIRST" = "site" ]; then
&>> /var/www/$EE_DOMAIN/ee-config.php
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--wp" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then
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"
@ -738,20 +688,20 @@ elif [ "$EE_FIRST" = "site" ]; then
|| [[ "$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_UPDATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]; then
|| [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ]; then
# Update NGINX
ee_mod_update_domain
else
ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $?
ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $?
fi
if [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ]; then
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
ee_mod_setup_network
fi
ee_mod_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_UPDATE_OPTION" = "--wpsubdir" ]; then
|| [ "$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" ]] \
@ -759,13 +709,13 @@ elif [ "$EE_FIRST" = "site" ]; then
# Update NGINX
ee_mod_update_domain
else
ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $?
ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $?
fi
ee_mod_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_UPDATE_OPTION" = "--wpsubdomain" ]; then
|| [ "$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" ]] \
@ -773,7 +723,7 @@ elif [ "$EE_FIRST" = "site" ]; then
# Update NGINX
ee_mod_update_domain
else
ee_lib_error "Site already, $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $?
ee_lib_error "Site already, $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION, exit status =" $?
fi
ee_mod_update_cache
@ -788,7 +738,7 @@ elif [ "$EE_FIRST" = "site" ]; then
ee_lib_service nginx reload
# Git commit
ee_lib_git /etc/nginx/ "$EE_DOMAIN updated with $EE_SITE_UPDATE_OPTION $EE_SITE_CACHE_OPTION options"
ee_lib_git /etc/nginx/ "$EE_DOMAIN updated with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options"
# Display Success Message
ee_lib_echo_info "Successfully Updated Website: http://$EE_WWW_DOMAIN"

34
src/modules/site/ee_mod_site_option.sh

@ -0,0 +1,34 @@
# Auto switch site options
if [ "$EE_SITE_CREATE_OPTION" = "--basic" ] || [ "$EE_SITE_CREATE_OPTION" = "--w3tc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsc" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpfc" ]; then
if [ "$EE_SITE_CACHE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdirectory" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CACHE_OPTION" = "--wpsubdomain" ]; then
EE_SITE_CREATE_OPTION=$EE_FIFTH
EE_SITE_CACHE_OPTION=$EE_FOURTH
else
EE_SITE_CREATE_OPTION=--wp
EE_SITE_CACHE_OPTION=$EE_FOURTH
fi
fi
# WordPresss subdirectory variables
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ]; then
EE_SITE_CREATE_OPTION="--wpsubdir"
EE_NETWORK_ACTIVATE="--network"
fi
# WordPress sub-domain variables
if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ]; then
EE_SITE_CREATE_OPTION="--wpsubdomain"
EE_NETWORK_ACTIVATE="--network"
EE_WP_SUBDOMAIN="--subdomains"
fi
# Use default whenever possible
if [ "$EE_SITE_CREATE_OPTION" = "" ]; then
EE_SITE_CREATE_OPTION=--html
fi
# For WordPress sites if $EE_SITE_CACHE_OPTION is empty then used --basic as a $EE_SITE_CACHE_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

46
src/modules/site/update/ee_mod_update_domain.sh

@ -10,10 +10,10 @@ function ee_mod_update_domain()
EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/$EE_SITE_CURRENT_CONF/$EE_SITE_UPDATE_CONF/' $EE_SITE_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_UPDATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" ] \
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"] \
@ -21,65 +21,65 @@ function ee_mod_update_domain()
sed -i "s'server_name $EE_DOMAIN www.$EE_DOMAIN;'server_name $EE_DOMAIN *.$EE_DOMAIN;'" $EE_SITE_CONF && \
sed -i '/server_name.*;/i \\t# Uncomment the following line for domain mapping;\n\t# listen 80 default_server;\n' $EE_SITE_CONF && \
sed -i '/server_name.*;/a \\n\t# Uncomment the following line for domain mapping \n\t#server_name_in_redirect off;' $EE_SITE_CONF && \
sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i '/include common\/locations.conf/i \\tinclude common\/wpsubdir.conf;' $EE_SITE_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_CONF && \
sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] || [[ "$EE_SITE_UPDATE_OPTION" = "--php" || "$EE_SITE_UPDATE_OPTION" = "--mysql" ]]; then
sed -i '/include common\/locations.conf/i \\tinclude common\/php.conf;' $EE_SITE_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i '/location \/ {/,/}/c \\tindex index.php index.htm index.html' $EE_SITE_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_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i '/include common\/locations.conf/i \\tinclude common\/wpfc.conf;' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i '/include common\/locations.conf/i \\tinclude common\/wpsc.conf;' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i '/include common\/locations.conf/i \\tinclude common\/w3tc.conf;' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/php.conf/include common\/wpfc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/php.conf/include common\/wpsc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/php.conf/include common\/w3tc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/w3tc.conf/include common\/wpfc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/w3tc.conf/include common\/wpsc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/w3tc.conf/include common\/php.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/wpfc.conf/include common\/php.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/wpfc.conf/include common\/wpsc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/wpsc.conf/include common\/php.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/wpsc.conf/include common\/wpfc.conf;/' $EE_SITE_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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i 's/include common\/wpfc.conf/include common\/w3tc.conf;/' $EE_SITE_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_UPDATE_OPTION" = "--wp" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdomain" || "$EE_SITE_UPDATE_OPTION" = "--wpsubdir" ]] \
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_CONF || ee_lib_error "Unable to update nginx configuration to $EE_SITE_UPDATE_OPTION, $EE_SITE_CACHE_OPTION for $EE_DOMAIN, exit status =" $?
sed -i '/include common\/locations.conf/i \\tinclude common\/wpcommon.conf;' $EE_SITE_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 =" $?

Loading…
Cancel
Save