You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
885 lines
32 KiB
885 lines
32 KiB
#!/bin/bash
|
|
|
|
# Include library
|
|
for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do
|
|
source $ee_include
|
|
done
|
|
|
|
# Main EasyEngine (ee) function to log all the outputs
|
|
EasyEngine()
|
|
{
|
|
|
|
# Arguments
|
|
EE_FIRST=$1
|
|
EE_SECOND=$2
|
|
EE_THIRD=$3
|
|
EE_FOURTH=$4
|
|
EE_FIFTH=$5
|
|
|
|
# Let's capture the EasyEngine arguments
|
|
ee_lib_echo "EasyEngine (ee) $EE_VERSION execution started [$(date)]" &>> $EE_COMMAND_LOG
|
|
ee_lib_echo "EasyEngine (ee) command: $0 $@" &>> $EE_COMMAND_LOG
|
|
|
|
|
|
# EasyEngine version
|
|
if [ "$EE_FIRST" = "version" ] || [ "$EE_FIRST" = "--version" ] || [ "$EE_FIRST" = "-v" ];then
|
|
# Display Easy Engine Version
|
|
echo "EasyEngine (ee) version: $EE_VERSION"
|
|
|
|
# EasyEngine help
|
|
elif [ "$EE_FIRST" = "help" ] || [ "$EE_FIRST" = "--help" ] || [ "$EE_FIRST" = "-h" ]; then
|
|
# Display man page
|
|
man ee
|
|
|
|
# Display information about NGINX|PHP|MySQL
|
|
elif [ "$EE_FIRST" = "info" ];then
|
|
if [ "$EE_SECOND" = "nginx" ] || [ "$EE_SECOND" = "php" ] || [ "$EE_SECOND" = "mysql" ]; then
|
|
ee_lib_${EE_SECOND}_info
|
|
else
|
|
ee_lib_nginx_info
|
|
ee_lib_php_info
|
|
ee_lib_mysql_info
|
|
fi
|
|
|
|
# EasyEngine stack/system
|
|
elif [ "$EE_FIRST" = "stack" ] || [ "$EE_FIRST" = "system" ]; then
|
|
# EasyEngine install
|
|
if [ "$EE_SECOND" = "install" ]; then
|
|
# 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/Percona MySQL repository
|
|
ee_mod_repo_$EE_THIRD
|
|
|
|
# Fix GnuPG key
|
|
ee_lib_gpg_key_fix
|
|
fi
|
|
|
|
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then
|
|
# Execute: apt-get update
|
|
ee_lib_apt_get_update
|
|
|
|
# Install NGINX/PHP/MySQL/Postfix package
|
|
ee_mod_install_$EE_THIRD
|
|
fi
|
|
|
|
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ]; then
|
|
# Setup NGINX/PHP/MySQL
|
|
ee_mod_setup_$EE_THIRD
|
|
fi
|
|
|
|
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then
|
|
# Restart php5-fpm
|
|
if [ "$EE_THIRD" = "php" ];then
|
|
ee_lib_service php5-fpm restart
|
|
|
|
# Initialize Git
|
|
ee_lib_git /etc/php5/ "Initialize Git"
|
|
else
|
|
# Restart NGINX/MySQL/Postfix
|
|
ee_lib_service $EE_THIRD restart
|
|
|
|
# Initialize Git
|
|
ee_lib_git /etc/$EE_THIRD/ "Initialize Git"
|
|
fi
|
|
fi
|
|
|
|
if [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ];then
|
|
# Install Adminer/phpMyAdmin/WP-CLI/Utils
|
|
ee_ven_install_$EE_THIRD
|
|
fi
|
|
|
|
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/Percona MySQL repository
|
|
ee_mod_repo_nginx
|
|
ee_mod_repo_php
|
|
ee_mod_repo_mysql
|
|
|
|
# Fix GnuPG key
|
|
ee_lib_gpg_key_fix
|
|
|
|
# Execute: apt-get update
|
|
ee_lib_apt_get_update
|
|
|
|
# Install NGINX/PHP/MySQL/Postfix package
|
|
ee_mod_install_nginx
|
|
ee_mod_install_php
|
|
ee_mod_install_mysql
|
|
ee_mod_install_postfix
|
|
|
|
# Setup NGINX/PHP/MySQL
|
|
ee_mod_setup_nginx
|
|
ee_mod_setup_php
|
|
ee_mod_setup_mysql
|
|
|
|
# Restart NGINX/MySQL/Postfix
|
|
ee_lib_service nginx php5-fpm mysql restart
|
|
|
|
# Initialize Git
|
|
ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "Initialize Git"
|
|
|
|
# Install WP-CLI
|
|
ee_ven_install_wpcli
|
|
fi
|
|
# Install Adminer/phpMyAdmin/Utils
|
|
ee_ven_install_adminer
|
|
ee_ven_install_phpmyadmin
|
|
ee_ven_install_utils
|
|
fi
|
|
|
|
# EasyEngine mail server setup
|
|
if [ "$EE_THIRD" = "mail" ] || [ "$EE_THIRD" = "all" ];then
|
|
|
|
# Check required Packages are installed or not
|
|
dpkg --get-selections | grep -v deinstall | grep nginx > /dev/null \
|
|
&& dpkg --get-selections | grep -v deinstall | grep php5-fpm > /dev/null \
|
|
&& mysqladmin ping &>> $EE_COMMAND_LOG \
|
|
&& dpkg --get-selections | grep -v deinstall | grep postfix > /dev/null
|
|
if [ $? -ne 0 ];then
|
|
ee_lib_error "Failed to find NGINX PHP MySQL Postfix, exit status=" 1
|
|
fi
|
|
|
|
dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null
|
|
if [ $? -eq 0 ];then
|
|
ee_lib_error "Found installed Dovecot Packages, exit status=" 1
|
|
fi
|
|
|
|
# Check hostname is FQDN or not, if not asks user to set hostname as FQDN
|
|
ee_lib_check_fqdn $(hostname -f)
|
|
|
|
# Install Dovecot
|
|
ee_mod_install_dovecot
|
|
|
|
|
|
# Install ViMbAdmin
|
|
ee_ven_install_vimbadmin
|
|
|
|
# Install Roundcube
|
|
ee_ven_install_roundcube
|
|
|
|
# Configure PostFix
|
|
ee_mod_setup_postfix
|
|
|
|
# Configure Dovecot
|
|
ee_mod_setup_dovecot
|
|
|
|
# Setup ViMbAdmin
|
|
ee_ven_setup_vimbadmin
|
|
|
|
# Setup Roundcube
|
|
ee_ven_setup_roundcube
|
|
|
|
# Setup Sieve Rules
|
|
ee_mod_setup_sieve
|
|
|
|
if [ "$EE_SETUP_MAILSCANNER" != "no" ]; then
|
|
# Install mail scanner packages
|
|
ee_mod_install_mailscaner
|
|
|
|
# Setup Amavis
|
|
ee_mod_setup_mailscaner
|
|
else
|
|
ee_lib_echo_fail "RAM is less then 512MB, EasyEngine skip installing Mail Scanner Packages"
|
|
|
|
fi
|
|
ee_lib_service nginx postfix dovecot amavis restart
|
|
|
|
ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Initialize Git"
|
|
|
|
# Display message for mail server
|
|
ee_lib_echo_escape "Configure ViMbAdmin:\thttps://$(hostname -f):22222/vimbadmin"
|
|
ee_lib_echo_escape "Security Salt:\t\t${ee_security_salt}\n"
|
|
|
|
elif [ "$EE_THIRD" = "mailscanner" ]; then
|
|
|
|
dpkg --get-selections | grep -v deinstall | grep dovecot-core > /dev/null
|
|
if [ $? -ne 0 ];then
|
|
ee_lib_error "Failed to find Dovecot Packages, exit status = " 1
|
|
fi
|
|
|
|
# Install Mail Scanner
|
|
ee_mod_install_mailscaner
|
|
|
|
# Setup Mail Scanner
|
|
ee_mod_setup_mailscaner
|
|
|
|
ee_lib_service nginx postfix dovecot amavis restart
|
|
|
|
ee_lib_git /etc/nginx /etc/postfix /etc/dovecot /etc/amavis "Installed Mail Scanner Packages"
|
|
fi
|
|
|
|
# Display HTTP authentication details
|
|
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ] || [ "$EE_THIRD" = "all" ]; then
|
|
if [ "$EE_DISPLAY" = "true" ]; then
|
|
ee_lib_echo_info "HTTP authentication username: $EE_HTTP_AUTH_USER"
|
|
ee_lib_echo_info "HTTP authentication password: $EE_HTTP_AUTH_PASS"
|
|
fi
|
|
fi
|
|
# Display success message
|
|
if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ]; then
|
|
EE_THIRD="Web packages"
|
|
fi
|
|
ee_lib_echo "$EE_THIRD successfully installed"
|
|
|
|
# EasyEngine remove/purge
|
|
elif [ "$EE_SECOND" = "remove" ] || [ "$EE_SECOND" = "purge" ]; then
|
|
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ] || [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ]; then
|
|
|
|
# Remove/Purge NGINX/PHP/MySQL/Postfix package
|
|
if [ "$EE_THIRD" = "nginx" ] || [ "$EE_THIRD" = "php" ] || [ "$EE_THIRD" = "mysql" ] || [ "$EE_THIRD" = "postfix" ]; then
|
|
ee_mod_remove_$EE_THIRD
|
|
|
|
# Execute: apt-get autoremove
|
|
ee_lib_autoremove
|
|
fi
|
|
|
|
# Remove/Purge Adminer/phpMyAdmin/WP-CLI/Utils
|
|
if [ "$EE_THIRD" = "adminer" ] || [ "$EE_THIRD" = "phpmyadmin" ] || [ "$EE_THIRD" = "wpcli" ] || [ "$EE_THIRD" = "utils" ];then
|
|
ee_ven_remove_$EE_THIRD
|
|
fi
|
|
|
|
|
|
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
|
|
ee_mod_remove_php
|
|
ee_mod_remove_mysql
|
|
ee_mod_remove_postfix
|
|
|
|
# Remove/Purge WP-CLI
|
|
ee_ven_remove_wpcli
|
|
fi
|
|
# Remove/Purge Adminer/phpMyAdmin/Utils
|
|
ee_ven_remove_adminer
|
|
ee_ven_remove_phpmyadmin
|
|
ee_ven_remove_utils
|
|
|
|
# Execute: apt-get autoremove
|
|
ee_lib_autoremove
|
|
fi
|
|
if [ "$EE_THIRD" = "all" ] || [ "$EE_THIRD" = "mail" ];then
|
|
# Remove Dovecot
|
|
ee_mod_remove_dovecot
|
|
|
|
# Remove Mail Scanner
|
|
ee_mod_remove_mailscaner
|
|
|
|
# Remove ViMbAdmin
|
|
ee_ven_remove_vimbadmin
|
|
|
|
# Remove Roundcube
|
|
ee_ven_remove_roundcube
|
|
|
|
# Execute: apt-get autoremove
|
|
ee_lib_autoremove
|
|
|
|
# Restart Nginx
|
|
ee_lib_service nginx
|
|
|
|
ee_lib_git /etc/nginx "Removed Mail Server"
|
|
|
|
elif [ "$EE_THIRD" = "mailscanner" ]; then
|
|
# Remove Amavis
|
|
ee_mod_remove_mailscaner
|
|
|
|
# Execute: apt-get autoremove
|
|
ee_lib_autoremove
|
|
|
|
ee_lib_service nginx postfix dovecot restart
|
|
|
|
ee_lib_git /etc/postfix "Removed mailscanner"
|
|
fi
|
|
|
|
# Display success message
|
|
if [ "$EE_THIRD" = "" ] || [ "$EE_THIRD" = "web" ]; then
|
|
EE_THIRD="Web packages"
|
|
fi
|
|
if [ "$EE_SECOND" = "remove" ];then
|
|
ee_lib_echo "$EE_THIRD successfully removed"
|
|
elif [ "$EE_SECOND" = "purge" ];then
|
|
ee_lib_echo "$EE_THIRD successfully purged"
|
|
fi
|
|
|
|
elif [ "$EE_SECOND" = "status" ]; then
|
|
ee_mod_stack_status
|
|
elif [ "$EE_SECOND" = "start" ] || [ "$EE_SECOND" = "stop" ] || [ "$EE_SECOND" = "reload" ] || [ "$EE_SECOND" = "restart" ]; then
|
|
ee_lib_service nginx php5-fpm mysql postfix $EE_SECOND
|
|
else
|
|
ee_lib_echo "ee stack commands:"
|
|
ee_lib_echo_escape "\tinstall\tInstall NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI , Utils, Mailscanner and Admin tools"
|
|
ee_lib_echo_escape "\tremove\tRemove NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI, Utils, Mailscanner and Admin tools"
|
|
ee_lib_echo_escape "\tpurge\tPurge NGINX, PHP5, MySQL, Postfix, Adminer, phpMyAdmin, WP-CLI, Utils, Mailscanner and Admin tools"
|
|
ee_lib_echo_escape "\tstatus\tDisplay system status information"
|
|
ee_lib_echo_escape "\tstart\tStart NGINX, PHP5, MySQL and Postfix service"
|
|
ee_lib_echo_escape "\tstop\tStop NGINX, PHP5, MySQL and Postfix service"
|
|
ee_lib_echo_escape "\treload\tReload NGINX, PHP5, MySQL and Postfix service"
|
|
ee_lib_echo_escape "\trestart\tRestart NGINX, PHP5, MySQL and Postfix service"
|
|
fi
|
|
|
|
|
|
# EasyEngine site
|
|
elif [ "$EE_FIRST" = "site" ]; then
|
|
if [ "$EE_SECOND" = "list" ]; then
|
|
if [ "$EE_THIRD" = "available" ];then
|
|
ee_lib_echo "List of sites-available websites:"
|
|
ls /etc/nginx/sites-available/ \
|
|
|| ee_lib_error "Unable to display list of sites-available websites, exit status = " $?
|
|
else
|
|
ee_lib_echo "List of sites-enabled websites:"
|
|
ls /etc/nginx/sites-enabled/ \
|
|
|| ee_lib_error "Unable to display list of sites-enabled websites, exit status = " $?
|
|
fi
|
|
elif [ "$EE_SECOND" = "info" ] || [ "$EE_SECOND" = "show" ]; then
|
|
# Check the website name is empty or not
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
ee_lib_check_domain
|
|
|
|
if [ "$EE_SECOND" = "info" ]; then
|
|
# Display information about website
|
|
ee_mod_site_info
|
|
elif [ "$EE_SECOND" = "show" ]; then
|
|
# 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 = " $?
|
|
|
|
# Display NGINX configuration for $EE_DOMAIN
|
|
if [ $? -eq 0 ]; then
|
|
ee_lib_echo "Display NGINX configuration for $EE_DOMAIN"
|
|
cat /etc/nginx/sites-available/$EE_DOMAIN \
|
|
|| ee_lib_error "Unable to display NGINX configuration for $EE_DOMAIN, exit status = " $?
|
|
fi
|
|
fi
|
|
elif [ "$EE_SECOND" = "enable" ]; then
|
|
# Check the website name is empty or not
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
ee_lib_check_domain
|
|
|
|
# Creating symbolic link
|
|
ee_lib_echo "Creating symbolic link for $EE_DOMAIN"
|
|
ee_lib_symbolic_link /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/
|
|
|
|
# Execute: service nginx reload
|
|
ee_lib_service nginx reload
|
|
|
|
# Git commit
|
|
ee_lib_git /etc/nginx/ "Enable website: $EE_DOMAIN"
|
|
elif [ "$EE_SECOND" = "disable" ]; then
|
|
# Check the website name is empty or not
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
ee_lib_check_domain
|
|
|
|
# Remove symbolic link
|
|
ee_lib_echo "Removing symbolic link for $EE_DOMAIN"
|
|
rm /etc/nginx/sites-enabled/$EE_DOMAIN \
|
|
|| ee_lib_error "Unable to remove symbolic link for $EE_DOMAIN, exit status = " $?
|
|
|
|
# Execute: service nginx reload
|
|
ee_lib_service nginx reload
|
|
|
|
# Git commit
|
|
ee_lib_git /etc/nginx/ "Disable website: $EE_DOMAIN"
|
|
elif [ "$EE_SECOND" = "edit" ]; then
|
|
# Check the website name is empty or not
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
ee_lib_check_domain
|
|
|
|
# Edit the NGINX configuration for $EE_DOMAIN
|
|
ee_mod_site_edit $EE_FOURTH
|
|
|
|
if [ $(cd /etc/nginx; git status -s /etc/nginx/sites-available/$EE_DOMAIN | wc -l) -ne 0 ]; then
|
|
# Git commit
|
|
ee_lib_git /etc/nginx/ "Edit website: $EE_DOMAIN"
|
|
|
|
# Execute: service nginx reload
|
|
ee_lib_service nginx reload
|
|
fi
|
|
elif [ "$EE_SECOND" = "create" ]; then
|
|
# Configure variables
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
EE_SITE_CREATE_OPTION=$EE_FOURTH
|
|
EE_SITE_CACHE_OPTION=$EE_FIFTH
|
|
|
|
# Auto switch site options
|
|
ee_mod_site_option
|
|
|
|
# Install required packages
|
|
ee_mod_site_packages
|
|
|
|
# Lets create HTML|PHP|MySQL website
|
|
if [ "$EE_SITE_CREATE_OPTION" = "--html" ] || [ "$EE_SITE_CREATE_OPTION" = "--php" ] || [ "$EE_SITE_CREATE_OPTION" = "--mysql" ]; then
|
|
# Configure variable
|
|
EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/basic.conf
|
|
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_CONF = $EE_NGINX_CONF" &>> $EE_COMMAND_LOG
|
|
|
|
# Setup NGINX
|
|
ee_lib_check_domain
|
|
ee_mod_setup_domain
|
|
|
|
# Setup MySQL database
|
|
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
|
|
|
|
# Adjust permission
|
|
ee_lib_permissions
|
|
|
|
# Git commit
|
|
ee_lib_git /etc/nginx/ "$EE_DOMAIN created with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options"
|
|
|
|
# Display Http Auth credentials
|
|
if [ "$EE_DISPLAY" = "false" ]; then
|
|
ee_lib_echo_info "HTTP authentication username: easyengine"
|
|
ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')"
|
|
fi
|
|
# Display Success Message
|
|
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
|
|
|
|
# Configure variable
|
|
EE_NGINX_CONF=$(echo $EE_SITE_CREATE_OPTION | cut -c3-)/$(echo $EE_SITE_CACHE_OPTION | cut -c3-).conf
|
|
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_CONF = $EE_NGINX_CONF" &>> $EE_COMMAND_LOG
|
|
|
|
# Setup NGINX
|
|
ee_lib_check_domain
|
|
ee_mod_setup_domain
|
|
|
|
# Setup WordPress
|
|
ee_mod_setup_wordpress
|
|
|
|
# Adjust permission
|
|
ee_lib_permissions
|
|
|
|
# Git commit
|
|
ee_lib_git /etc/nginx/ "$EE_DOMAIN created with $EE_SITE_CREATE_OPTION $EE_SITE_CACHE_OPTION options"
|
|
|
|
# Execute: service nginx reload
|
|
ee_lib_service nginx reload
|
|
|
|
# Display Http Auth credentials
|
|
if [ "$EE_DISPLAY" = "false" ]; then
|
|
ee_lib_echo_info "HTTP authentication username: easyengine"
|
|
ee_lib_echo_info "HTTP authentication password: $(grep "HTTP authentication password:" $EE_COMMAND_LOG | tail -n1 | awk '{print $4}')"
|
|
fi
|
|
|
|
# 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
|
|
|
|
# Display Success Message
|
|
ee_lib_echo_info "Successfully created new website: http://$EE_WWW_DOMAIN"
|
|
fi
|
|
fi
|
|
elif [ "$EE_SECOND" = "delete" ]; then
|
|
# Check the website name is empty or not
|
|
EE_DELETE_ARGS=$EE_FOURTH
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
ee_lib_check_domain
|
|
|
|
# Check the $EE_DOMAIN exist or not
|
|
if [ ! -f /etc/nginx/sites-available/$EE_DOMAIN ]; then
|
|
ee_lib_error "$EE_DOMAIN does not exist, exit status = " $?
|
|
fi
|
|
|
|
# Use default whenever possible
|
|
# ee site delete example.com
|
|
# ee site delete example.com --no-prompt
|
|
if [ "$EE_DELETE_ARGS" = "" ]; then
|
|
EE_DELETE_ARGS="--all"
|
|
elif [ "$EE_DELETE_ARGS" = "--no-prompt" ]; then
|
|
EE_DELETE_ARGS="--all"
|
|
EE_FIFTH="--no-prompt"
|
|
fi
|
|
|
|
if [ "$EE_DELETE_ARGS" = "--db" ]; then
|
|
# Delete MySQL database
|
|
ee_mod_delete_database $EE_FIFTH
|
|
elif [ "$EE_DELETE_ARGS" = "--files" ]; then
|
|
# Delete webroot
|
|
ee_mod_delete_webroot $EE_FIFTH
|
|
elif [ "$EE_DELETE_ARGS" = "--all" ]; then
|
|
# Delete MySQL database
|
|
ee_mod_delete_database $EE_FIFTH
|
|
|
|
# Delete webroot
|
|
ee_mod_delete_webroot $EE_FIFTH
|
|
|
|
# Delete NGINX configuration file
|
|
ee_mod_delete_nginxconf $EE_FIFTH
|
|
|
|
# Git commit
|
|
ee_lib_git /etc/nginx/ "Delete website: $EE_DOMAIN"
|
|
|
|
# Execute: service nginx reload
|
|
ee_lib_service nginx reload
|
|
fi
|
|
elif [ "$EE_SECOND" = "update" ]; then
|
|
# Configure variables
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
EE_SITE_CREATE_OPTION=$EE_FOURTH
|
|
EE_SITE_CACHE_OPTION=$EE_FIFTH
|
|
|
|
# Check the website name is empty or not
|
|
ee_lib_check_domain
|
|
|
|
# Auto switch site options
|
|
ee_mod_site_option
|
|
|
|
# Let's use variable name as per action
|
|
# EE_SITE_CREATE_OPTION=$EE_SITE_CREATE_OPTION
|
|
|
|
# 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" ]; 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" ]; 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" ]; then
|
|
EE_SITE_CURRENT_WP="--wpsubdomain"
|
|
EE_SITE_CURRENT_CACHE="--wpfc"
|
|
EE_SITE_CURRENT_TYPE="--wpsubdomain --wpfc"
|
|
fi
|
|
|
|
# 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
|
|
|
|
# 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 \nEE_SITE_UPDATE_TYPE = $EE_SITE_UPDATE_TYPE" &>> $EE_COMMAND_LOG
|
|
|
|
# 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
|
|
|
|
|
|
if [ "$EE_UPDATE_WEBSITE" = "success" ]; then
|
|
# Adjust permission
|
|
ee_lib_permissions
|
|
|
|
# Execute: service nginx reload
|
|
ee_lib_service nginx reload
|
|
|
|
# Git commit
|
|
ee_lib_git /etc/nginx/ "After ee site update: $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"
|
|
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}
|
|
|
|
# EasyEngine cd
|
|
elif [ "$EE_SECOND" = "cd" ]; then
|
|
# Check the website name is empty or not
|
|
EE_DOMAIN_CHECK=$EE_THIRD
|
|
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 = " $?
|
|
|
|
# Change Directory to $EE_DOMAIN webroot
|
|
if [ $? -eq 0 ]; then
|
|
ee_site_cd
|
|
fi
|
|
|
|
else
|
|
ee_lib_echo "ee site commands:"
|
|
ee_lib_echo_escape "\tcd\tSwitch to website root directory"
|
|
ee_lib_echo_escape "\tlist\tList NGINX enabled website"
|
|
ee_lib_echo_escape "\tinfo\tDisplay information about given website"
|
|
ee_lib_echo_escape "\tshow\tDisplay NGINX configuration for given website"
|
|
ee_lib_echo_escape "\tenable\tEnable website"
|
|
ee_lib_echo_escape "\tdisable\tDisable website"
|
|
ee_lib_echo_escape "\tedit\tEdit NGINX configuration for given website"
|
|
ee_lib_echo_escape "\tcreate\tCreate new HTML, PHP, MySQL or WordPress website"
|
|
ee_lib_echo_escape "\tdelete\tDelete existing website"
|
|
ee_lib_echo_escape "\tlog\tMonitor access and error logs for single or multiple websites"
|
|
ee_lib_echo_escape "\tupdate\tupdate current website"
|
|
fi
|
|
|
|
# EasyEngine debug
|
|
elif [ "$EE_FIRST" = "debug" ]; then
|
|
# Default action
|
|
EE_DEBUG="--start"
|
|
|
|
# Auto arrange debug arguments
|
|
for ee_debug_args in $@; do
|
|
[ "$ee_debug_args" = "-i" ] && EE_DEBUG_INTERACTIVE=$ee_debug_args && echo EE_DEBUG_INTERACTIVE = $EE_DEBUG_INTERACTIVE &>> $EE_COMMAND_LOG
|
|
[ "$ee_debug_args" = "--stop" ] && EE_DEBUG=$ee_debug_args && echo EE_DEBUG = $EE_DEBUG &>> $EE_COMMAND_LOG
|
|
[ "$ee_debug_args" = "--nginx" ] && EE_DEBUG_NGINX=$ee_debug_args && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $EE_COMMAND_LOG
|
|
[ "$ee_debug_args" = "--rewrite" ] && EE_DEBUG_REWRITE=$ee_debug_args && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $EE_COMMAND_LOG
|
|
[ "$ee_debug_args" = "--php" ] && EE_DEBUG_PHP=$ee_debug_args && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $EE_COMMAND_LOG
|
|
[ "$ee_debug_args" = "--fpm" ] && EE_DEBUG_FPM=$ee_debug_args && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $EE_COMMAND_LOG
|
|
[ "$ee_debug_args" = "--mysql" ] && EE_DEBUG_MYSQL=$ee_debug_args && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $EE_COMMAND_LOG
|
|
[ "$ee_debug_args" = "--wp" ] && EE_DEBUG_WP=$ee_debug_args && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG
|
|
[ "${ee_debug_args%=*}" = "--import-slow-log-interval" ] && EE_DEBUG_IMPORT_SLOW_LOG=$ee_debug_args && echo EE_DEBUG_IMPORT_SLOW_LOG = $EE_DEBUG_IMPORT_SLOW_LOG &>> $EE_COMMAND_LOG
|
|
if [ "$ee_debug_args" != "debug" ] && [ "$ee_debug_args" != "-i" ] && [ "$ee_debug_args" != "--start" ] && [ "$ee_debug_args" != "--stop" ] && [ "$ee_debug_args" != "--nginx" ] && [ "$ee_debug_args" != "--rewrite" ] && [ "$ee_debug_args" != "--php" ] && [ "$ee_debug_args" != "--fpm" ] && [ "$ee_debug_args" != "--mysql" ] && [ "$ee_debug_args" != "--wp" ]; then
|
|
ls /etc/nginx/sites-available/ | grep $ee_debug_args &>> $EE_COMMAND_LOG
|
|
if [ $? -eq 0 ]; then
|
|
EE_DOMAIN_CHECK=$ee_debug_args && echo EE_DOMAIN_CHECK = $EE_DOMAIN_CHECK &>> $EE_COMMAND_LOG
|
|
|
|
# Domain name find out
|
|
ee_lib_check_domain
|
|
echo EE_DOMAIN = $EE_DOMAIN &>> $EE_COMMAND_LOG
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# The following code execute on
|
|
# ee debug
|
|
# ee debug -i
|
|
# ee debug --start
|
|
# ee debug --stop
|
|
# ee debug example.com
|
|
if [ -z "$EE_DEBUG_NGINX" ] && [ -z "$EE_DEBUG_REWRITE" ] && [ -z "$EE_DEBUG_PHP" ] && [ -z "$EE_DEBUG_FPM" ] && [ -z "$EE_DEBUG_MYSQL" ] && [ -z "$EE_DEBUG_WP" ]; then
|
|
EE_DEBUG_NGINX="--nginx" && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $EE_COMMAND_LOG
|
|
EE_DEBUG_REWRITE="--rewrite" && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $EE_COMMAND_LOG
|
|
EE_DEBUG_PHP="--php" && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $EE_COMMAND_LOG
|
|
EE_DEBUG_FPM="--fpm" && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $EE_COMMAND_LOG
|
|
EE_DEBUG_MYSQL="--mysql" && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $EE_COMMAND_LOG
|
|
|
|
if [ -n "$EE_DOMAIN" ]; then
|
|
EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG
|
|
fi
|
|
fi
|
|
|
|
# Actual debug function call
|
|
if [ "$EE_DEBUG_NGINX" = "--nginx" ]; then
|
|
# Debug NGINX
|
|
ee_mod_debug_nginx
|
|
fi
|
|
|
|
if [ "$EE_DEBUG_REWRITE" = "--rewrite" ]; then
|
|
# Debug NGINX rewrite rules
|
|
ee_mod_debug_rewrite
|
|
fi
|
|
|
|
if [ "$EE_DEBUG_PHP" = "--php" ]; then
|
|
# Debug PHP slow log and enable xdebug profiling
|
|
ee_mod_debug_php
|
|
fi
|
|
|
|
if [ "$EE_DEBUG_FPM" = "--fpm" ]; then
|
|
# Change PHP log_level from notice to debug
|
|
ee_mod_debug_fpm
|
|
fi
|
|
|
|
if [ "$EE_DEBUG_MYSQL" = "--mysql" ]; then
|
|
# Enable MySQL slow query
|
|
ee_mod_debug_mysql
|
|
fi
|
|
|
|
if [ "$EE_DEBUG_WP" = "--wp" ]; then
|
|
# Enable WordPress debug.log
|
|
ee_mod_debug_wp
|
|
fi
|
|
|
|
# Execute: service nginx reload
|
|
if [ "$EE_TRIGGER_NGINX" = "true" ]; then
|
|
ee_lib_service nginx reload
|
|
fi
|
|
|
|
if [ "$EE_TRIGGER_PHP" = "true" ]; then
|
|
ee_lib_service php5-fpm restart
|
|
fi
|
|
|
|
if [ "$EE_DEBUG_INTERACTIVE" = "-i" ]; then
|
|
# Debug stop on CTRL+C
|
|
trap "ee_mod_debug_stop" EXIT
|
|
|
|
if [ ! -z "$EE_DEBUG_MSG" ]; then
|
|
tail -f $EE_DEBUG_MSG
|
|
fi
|
|
elif [ "$EE_DEBUG_INTERACTIVE" != "-i" ] && [ "$EE_DEBUG" != "--stop" ]; then
|
|
if [ ! -z "$EE_DEBUG_MSG" ]; then
|
|
ee_lib_echo_info "tail -f $EE_DEBUG_MSG"
|
|
fi
|
|
fi
|
|
|
|
# EasyEngine secure
|
|
elif [ "$EE_FIRST" = "secure" ]; then
|
|
if [ "$EE_SECOND" = "--auth" ] || [ "$EE_SECOND" = "--port" ] || [ "$EE_SECOND" = "--ip" ]; then
|
|
ee_mod_secure_$(echo $EE_SECOND | sed 's/--//')
|
|
ee_lib_service nginx reload
|
|
else
|
|
ee_lib_echo "ee secure commands:"
|
|
ee_lib_echo_escape "\t--auth\tUpdate credential of HTTP authentication"
|
|
ee_lib_echo_escape "\t--port\tChange EasyEngine admin port 22222"
|
|
ee_lib_echo_escape "\t--ip\tUpdate whitelist IP address"
|
|
fi
|
|
|
|
# Clean NGINX FastCGI, Memcache, OPcache cache
|
|
elif [ "$EE_FIRST" = "clean" ]; then
|
|
ee_mod_clean ${@:2}
|
|
|
|
# Import MySQL slow log to Anememoter
|
|
elif [ "$EE_FIRST" = "import-slow-log" ];then
|
|
ee_lib_import_slow_log
|
|
|
|
# EasyEngine update
|
|
elif [ "$EE_FIRST" = "update" ]; then
|
|
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:"
|
|
ee_lib_echo_escape "\tversion\tDisplay EasyEngine (ee) version"
|
|
ee_lib_echo_escape "\thelp\tDisplay EasyEngine (ee) man page"
|
|
ee_lib_echo_escape "\tinfo\tDisplay Information about NGINX, PHP5, MySQL"
|
|
ee_lib_echo_escape "\tclean\tClean Nginx FastCGI cache/OPcache/Memcache/all cache"
|
|
ee_lib_echo_escape "\tstack\tInstall/Remove/Purge NGINX, PHP, MySQL, Postfix"
|
|
ee_lib_echo_escape "\tsite\tPerform various site specific operation"
|
|
ee_lib_echo_escape "\tdebug\tPerform various debugging operation"
|
|
ee_lib_echo_escape "\tsecure\tUpdate HTTP authentication and EasyEngine admin port"
|
|
ee_lib_echo_escape "\tupdate\tUpdate EasyEngine (ee) to latest version"
|
|
fi
|
|
|
|
}
|
|
|
|
EasyEngine $@ | tee -ai $EE_COMMAND_LOG
|
|
|
|
|
|
# If any command fails its return non-zero exit code [EasyEngine $@]
|
|
# But when failed command piped then its [EasyEngine $@] exit status
|
|
# is suppress by next piped command [| tee -ai $EE_COMMAND_LOG]
|
|
|
|
# Example:
|
|
# (call | tee -ai example.log); echo $?
|
|
# 0
|
|
|
|
# (call | tee -ai example.log; exit ${PIPESTATUS[0]}); echo $?
|
|
# 127
|
|
|
|
exit ${PIPESTATUS[0]}
|
|
|