#!/bin/bash EE_MYSQL_USERPASS() { read -p "Enter The MySQL Username [root]: " EE_MYSQL_USER # If Enter Is Pressed, Then Use root as MySQL User if [[ $EE_MYSQL_USER = "" ]] then EE_MYSQL_USER=root fi # Turn Off Echo For Passwords stty -echo read -p "Enter The MySQL Password: " EE_MYSQL_PASS stty echo echo } EE_MYSQL_PASSCHECK() { while [ -n $(mysqladmin -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS ping 2> /dev/null | grep alive) &> /dev/null ] do # Verify MySQL Credentials EE_MYSQL_USERPASS done } MYSQLROOT() { EE_MYSQL_USER=$(cat ~/.my.cnf | grep user | cut -d'=' -f2) EE_MYSQL_PASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2 | sed -e 's/^"//' -e 's/"$//') } # GET Information Function MYSQLINFO() { # Get The MySQL Host EE_MYSQL_HOST=$(grep mysqlhost /etc/easyengine/ee.conf | awk '{print($3)}') # MySQL Default Host: localhost if [[ $EE_MYSQL_HOST = "" ]] then EE_MYSQL_HOST=localhost fi if [ -f ~/.my.cnf ] then MYSQLROOT else # Verify MySQL Credentials EE_MYSQL_USERPASS fi # Verify MySQL Credentials EE_MYSQL_PASSCHECK # Replace Dot With Underscore In $EE_DOMAIN Name ee_replace_dot=$(echo $EE_DOMAIN | tr '.' '_') # Check Use Default DB Name Or Custom DB Name grep customdbname /etc/easyengine/ee.conf | grep -i true &>> /dev/null if [ $? -eq 0 ] then read -p "Enter The MySQL Database Name [$ee_replace_dot]: " EE_DB_NAME fi # If customdbname = false # Then It Never Ask For MySQL Database Name In This Case $EE_DB_NAME Is Empty # If customdbname = true # User Enter Custom Databse Name Then EE_DB_NAME Is Not Empty & We Used Provided Database Name # If User Pressed Enter Then $EE_DB_NAME Is Empty if [[ $EE_DB_NAME = "" ]] then EE_DB_NAME=$ee_replace_dot fi } EEWPDBPREFIX() { # Get The WordPress Database Table Prefix EE_WP_PREFIX=$(grep wpdbprefix /etc/easyengine/ee.conf | awk '{print($3)}') # Display EE_WP_PREFIX Valid Characters Warning & Try Again while [ $(echo $EE_WP_PREFIX | grep '[^[:alnum:] _]') ] do ee_lib_echo_fail "Warning: \033[34mTable Prefix Can Only Contain Numbers, Letters, And Underscores." # For Proper read Command Output stty echo read -p "Enter The MySQL Database Table Prefix [wp_]: " EE_WP_PREFIX done # WordPress Database Table Prefix Default: wp_ if [[ $EE_WP_PREFIX = "" ]] then EE_WP_PREFIX=wp_ fi } FIXEE_MYSQL_USER16() { # Fix MySQL USER ERROR 1470 (HY000) EE_MYSQL_USER16=$(echo -n $EE_DB_USER | wc -c) if [[ $EE_MYSQL_USER16 -gt 16 ]] then echo MySQL Database Username $EE_DB_USER = $EE_MYSQL_USER16 &>> $EE_COMMAND_LOG ee_lib_echo "Auto Fix MySQL Username To The 16 Characters" RANDOM_CHARACTER=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 10 | head -n1) EE_DB_USER=$(echo $ee_replace_dot | cut -c1-16 | sed "s/.\{10\}$/$RANDOM_CHARACTER/") #ee_lib_echo_fail "ERROR 1470 (HY000): $EE_DB_USER Is Too Long For MySQL Username" # Turn Off Echo For Passwords #stty echo #read -p "Enter The MySQL Database Username [$ee_replace_dot16]: " EE_DB_USER #if [[ $EE_DB_USER = "" ]] #then # EE_DB_USER=$ee_replace_dot16 #fi fi } ee_mod_setup_database() { # Create Database mysql -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "create database \`$EE_DB_NAME\`" \ || ee_lib_error "Unable To Create $EE_DB_NAME Database" # Check Use Default DB User Or Custom DB User WPDBRANDOMPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) grep customdbuser /etc/easyengine/ee.conf | grep -i true &>> /dev/null if [ $? -eq 0 ] then read -p "Enter The MySQL Database Username [$ee_replace_dot]: " EE_DB_USER if [[ $EE_DB_USER = "" ]] then EE_DB_USER=$ee_replace_dot fi # Fix MySQL USER ERROR 1470 (HY000) FIXEE_MYSQL_USER16 # Turn Off Echo For Passwords stty -echo read -p "Enter The MySQL Database Password [$WPDBRANDOMPASS]: " EE_DB_PASS stty echo echo fi if [[ $EE_DB_USER = "" ]] then EE_DB_USER=$ee_replace_dot # Fix MySQL USER ERROR 1470 (HY000) FIXEE_MYSQL_USER16 fi if [[ $EE_DB_PASS = "" ]] then EE_DB_PASS=$WPDBRANDOMPASS fi # Create Separate User & Grant Permission echo -e "EE_DB_NAME = $EE_DB_NAME \nEE_DB_USER = $EE_DB_USER \nEE_DB_PASS = $EE_DB_PASS" &>> $EE_COMMAND_LOG mysql -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "create user '$EE_DB_USER'@'$EE_MYSQL_HOST' identified by '$EE_DB_PASS'" mysql -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "grant all privileges on \`$EE_DB_NAME\`.* to '$EE_DB_USER'@'$EE_MYSQL_HOST'" mysql -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "flush privileges" } PHPUSERINFO() { # PHP User PHPUSER=$(grep ^user /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2 | cut -d' ' -f2) \ || ee_lib_error "Unable To Find Out PHP Username" } ee_mod_site_info() { # Display The Specific Site Configuration SITESTATUS=$(ls /etc/nginx/sites-enabled/$EE_DOMAIN &> /dev/null && echo Enable || echo Disable) SITEINFO=$(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) ACCESSLOG=$(grep access_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) EE_ERROR_LOG=$(grep error_log /etc/nginx/sites-available/$EE_DOMAIN | grep "/var/log/nginx/" | awk '{print($2)}' | cut -d ';' -f1) WEBROOT=$(grep root /etc/nginx/sites-available/$EE_DOMAIN | grep htdocs | awk '{print($2)}' | cut -d ';' -f1) EE_DB_NAME=$(grep DB_NAME /var/www/$EE_DOMAIN/wp-config.php 2> /dev/null | cut -d"'" -f4) ee_lib_echo "$EE_DOMAIN Information:\n" ee_lib_echo "Nginx Configuration:\t\t \033[37m$SITEINFO ($SITESTATUS)" ee_lib_echo "Nginx access_log:\t\t \033[37m$ACCESSLOG" ee_lib_echo "Nginx error_log:\t\t \033[37m$EE_ERROR_LOG" ee_lib_echo "Nginx root:\t\t\t \033[37m$WEBROOT" ee_lib_echo "$EE_DOMAIN Database:\t\t \033[37m$EE_DB_NAME" } EESITEEDIT() { # Open Website In Default Editor sensible-editor /etc/nginx/sites-available/$EE_DOMAIN 2> /dev/null } # EE Domain Functions ee_lib_check_domain() { # Check SITENAME Is Empty Or Not if [ -z "$EE_DOMAIN_CHECK" ] then # Ask Users To Enter Domain Name read -p "Enter Domain Name: " EE_DOMAIN_CHECK # Remove http:// https:// & www. EE_DOMAIN=$(echo $EE_DOMAIN_CHECK | tr 'A-Z' 'a-z' | sed "s'http://''" | sed "s'https://''" | sed "s'www.''" | sed "s'/''") else # Remove http:// https:// & www. EE_DOMAIN=$(echo $EE_DOMAIN_CHECK | tr 'A-Z' 'a-z' | sed "s'http://''" | sed "s'https://''" | sed "s'www.''" | sed "s'/''") fi # Remove http:// https:// For WordPress Setup (www.example.com) EE_WWW_DOMAIN=$(echo $EE_DOMAIN_CHECK | tr 'A-Z' 'a-z' | sed "s'http://''" | sed "s'https://''" | sed "s'/''") } ee_lib_symbolic_link() { # Creating Symbolic Link ee_lib_echo "Creating Symbolic Link For $EE_DOMAIN" ln -s /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/ \ || ee_lib_error "Unable To Create Symbolic Link For $EE_DOMAIN" } ee_mod_setup_domain() { #Check The Nginx Configuration Exist For $EE_DOMAIN ls /etc/nginx/sites-available/$EE_DOMAIN &> $EE_ERROR_LOG if [ $? -ne 0 ] then # Creating Website $EE_DOMAIN ee_lib_echo "Creating $EE_DOMAIN, Please Wait..." sed "s/example.com/$EE_DOMAIN/g" \ /usr/share/easyengine/nginx/$EE_NGINX_CONF \ > /etc/nginx/sites-available/$EE_DOMAIN \ || ee_lib_error "Unable To Create Nginx Configuration File For $EE_DOMAIN" # Creating Symbolic Link ee_lib_symbolic_link # Creating Htdocs & Logs Directory ee_lib_echo "Creating htdocs & logs Directory" mkdir -p /var/www/$EE_DOMAIN/htdocs && mkdir -p /var/www/$EE_DOMAIN/logs \ || ee_lib_error "Unable To Create htdocs & logs Directory" # Creating Symbolic Links For Logs ee_lib_echo "Creating Symbolic Link For Logs" ln -s /var/log/nginx/$EE_DOMAIN.access.log /var/www/$EE_DOMAIN/logs/access.log \ && ln -s /var/log/nginx/$EE_DOMAIN.error.log /var/www/$EE_DOMAIN/logs/error.log \ || ee_lib_error "Unable To Create Symbolic Link For $EE_DOMAIN Logs" else ee_lib_error "$EE_DOMAIN Already Exist" fi } # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress() { # Download Latest WordPress ee_lib_echo "Downloading WordPress, Please Wait..." wget --no-check-certificate -cqO /var/www/$EE_DOMAIN/htdocs/latest.tar.gz \ http://wordpress.org/latest.tar.gz \ || ee_lib_error "Unable To Download WordPress" # Extracting WordPress tar --strip-components=1 -zxf /var/www/$EE_DOMAIN/htdocs/latest.tar.gz \ -C /var/www/$EE_DOMAIN/htdocs/ \ || ee_lib_error "Unable To Extract WordPress" # Removing WordPress Archive rm /var/www/$EE_DOMAIN/htdocs/latest.tar.gz # Call MYSQLINFO Function For MySQL Values MYSQLINFO EEWPDBPREFIX ee_mod_setup_database # Modify wp-config.php & Move Outside The Webroot cp /var/www/$EE_DOMAIN/htdocs/wp-config-sample.php \ /var/www/$EE_DOMAIN/wp-config.php sed -i "s/database_name_here/$EE_DB_NAME/" \ /var/www/$EE_DOMAIN/wp-config.php sed -i "s/username_here/$EE_DB_USER/" \ /var/www/$EE_DOMAIN/wp-config.php sed -i "s/password_here/$EE_DB_PASS/" \ /var/www/$EE_DOMAIN/wp-config.php sed -i "s/localhost/$EE_MYSQL_HOST/" \ /var/www/$EE_DOMAIN/wp-config.php sed -i "s/wp_/$EE_WP_PREFIX/" \ /var/www/$EE_DOMAIN/wp-config.php printf '%s\n' "g/put your unique phrase here/d" \ a "$(curl -sL https://api.wordpress.org/secret-key/1.1/salt/)" . w \ | ed -s /var/www/$EE_DOMAIN/wp-config.php } # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress() { # Get WordPress Site Title #ee_lib_echo "WordPress Information Required..." # WordPress Default User: admin EE_WP_USER=$(grep EE_WP_USER /etc/easyengine/ee.conf | awk '{print($3)}') if [[ $EE_WP_USER = "" ]] then EE_WP_USER=admin fi # WordPress Default Password: Random Password EE_WP_PASS=$(grep wpadminpass /etc/easyengine/ee.conf | awk '{print($3)}') if [[ $EE_WP_PASS = "" ]] then EE_WP_PASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1) fi # WordPress Default Email: `git config user.email` EE_WP_EMAIL=$(grep wpadminemail /etc/easyengine/ee.conf | awk '{print($3)}') if [[ $EE_WP_EMAIL = "" ]] then EE_WP_EMAIL=`git config user.email` fi # Create WordPress Tables ee_lib_echo "Setting Up WordPress, Please Wait..." cd /var/www/$EE_DOMAIN/htdocs || ee_lib_error "Unable To Change Directory To Install WordPress" wp core install --allow-root --url=$EE_WWW_DOMAIN --title="$EE_WWW_DOMAIN" \ --admin_name=$EE_WP_USER --admin_password=$EE_WP_PASS --admin_email=$EE_WP_EMAIL &>> $EE_COMMAND_LOG \ || ee_lib_error "Unable To Create WordPress Tables For $EE_DOMAIN" # Update WordPress Permalink Structure Day and Postname 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" } ee_lib_permission() { # Call PHPUSERINFO Function For PHP User Details PHPUSERINFO # Change Ownership ee_lib_echo "Changing Ownership" chown -R $PHPUSER:$PHPUSER /var/www/$EE_DOMAIN/ || ee_lib_error "Unable To Change Ownership For $EE_DOMAIN" # Reload Nginx Configuration NGINXRELOAD } # NGINX Configuration Function SETUP_DOMAIN() { # Check SITENAME Is Empty Or Not ee_lib_check_domain # Creating Website $EE_DOMAIN ee_mod_setup_domain # Setup WordPress Webroot & Database # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup MySQL database ee_mod_setup_database # 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"() { # Change Webroot Permission ee_lib_permission # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx EE_GIT_MESSAGE="Create Website With $WPNETWORKSITE $EE_SITE_CACHE_OPTION Option: $EE_DOMAIN" ee_lib_git_commit } ee_mod_plugin_w3tc() { # Installing W3 Total Cache cd /var/www/$EE_DOMAIN/htdocs/ ee_lib_echo "Installing W3 Total Cache Plugin, Please Wait..." wp plugin --allow-root install w3-total-cache &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Install W3 Total Cache Plugin" # Activate W3 Total Cache wp plugin --allow-root activate w3-total-cache $EE_NETWORK_ACTIVATE &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Activate W3 Total Cache Plugin" } ee_mod_plugin_wpsc() { # Installing WP Super Cache cd /var/www/$EE_DOMAIN/htdocs/ ee_lib_echo "Installing WP Super Cache Plugin, Please Wait..." wp plugin --allow-root install wp-super-cache &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Install WP Super Cache Plugin" # Activate WP Super Cache wp plugin --allow-root activate wp-super-cache $EE_NETWORK_ACTIVATE &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Activate WP Super Cache Plugin" } ee_mod_plugin_nginx_helper() { # Installing Nginx Helper cd /var/www/$EE_DOMAIN/htdocs/ ee_lib_echo "Installing Nginx Helper Plugin, Please Wait..." wp plugin --allow-root install nginx-helper &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Install Nginx Helper" # Activate Nginx Helper wp plugin --allow-root activate nginx-helper $EE_NETWORK_ACTIVATE &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Activate Nginx Helper Plugin" } # Setup Wordpress Network SETUPWPNETWORK() { # Prepare wp-config.php File Foe WordPress Multisite With SubDirectory cd /var/www/$EE_DOMAIN/htdocs || ee_lib_error "Unable To Change Directory" wp core install-network --allow-root --title="$EE_WWW_DOMAIN" $EE_WP_SUBDOMAIN &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Setup WordPress SubDirectory Network" sed -i "/WP_DEBUG/a \define('WP_ALLOW_MULTISITE', true);" /var/www/$EE_DOMAIN/wp-config.php sed -i "/WP_ALLOW_MULTISITE/a \define('WPMU_ACCEL_REDIRECT', true);" /var/www/$EE_DOMAIN/wp-config.php # Remove index.php from permalink # Install Nginx Helper ee_mod_plugin_nginx_helper } # Remove Database ee_mod_delete_database() { # HTML & PHP Website Doesn't Have Database head -n1 /etc/nginx/sites-available/$EE_DOMAIN | egrep -e 'HTML|PHP' &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # MySQL Information MYSQLROOT EE_DB_NAME=$(grep DB_NAME /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) EE_DB_USER=$(grep DB_USER /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) EE_DB_PASS=$(grep DB_PASS /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) EE_MYSQL_HOST=$(grep DB_HOST /var/www/$EE_DOMAIN/*-config.php | cut -d"'" -f4) echo -e " EE_DB_NAME = $EE_DB_NAME \n EE_DB_USER = $EE_DB_USER \n EE_MYSQL_HOST = $EE_MYSQL_HOST" # Remove Database # For Proper read Command Output stty echo if [ "$1" = "--no-prompt" ] then # Assume yes ee_prompt="y" else # Ask user for confirmation read -p "Are You Sure To Drop $EE_DB_NAME Database (y/n): " ee_prompt fi if [ "$ee_prompt" = "y" ] then # Remove Database mysql -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "drop database \`$EE_DB_NAME\`" \ || ee_lib_error "Unable To Drop $EE_DB_NAME Database" # Never Remove root User if [ "$EE_DB_USER" != "root" ] then # Remove Database User mysql -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "drop user '$EE_DB_USER'@'$EE_MYSQL_HOST'" \ || ee_lib_error "Unable To Drop Database User $EE_DB_USER" mysql -h $EE_MYSQL_HOST -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "flush privileges" \ || ee_lib_error "Unable To Flush MySQL Privileges" fi else # User Denied Messages ee_lib_echo_fail "User Denied To Drop $EE_DB_NAME Database." fi else ee_lib_echo_fail "No Database Found For $EE_DOMAIN" fi } ee_mod_delete_webroot() { # Remove Webroot # For Proper read Command Output stty echo if [ "$1" = "--no-prompt" ] then # Assume yes ee_prompt="y" else # Ask user for confirmation read -p "Are You Sure To Remove $EE_DOMAIN Webroot (y/n): " ee_prompt fi if [ "$ee_prompt" = "y" ] then # Remove Webroot rm -rf /var/www/$EE_DOMAIN || ee_lib_error "Unable To Remove $EE_DOMAIN Webroot" else # User Denied Messages ee_lib_echo_fail "User Denied To Remove $EE_DOMAIN Webroot." fi } ee_mod_delete_nginxconf() { # Remove Nginx Configuration # For Proper read Command Output stty echo if [ "$1" = "--no-prompt" ] then # Assume yes ee_prompt="y" else # Ask user for confirmation read -p "Are You Sure To Remove $EE_DOMAIN Nginx Configuration (y/n): " ee_prompt fi if [ "$ee_prompt" = "y" ] then # Remove Webroot rm -rf /etc/nginx/sites-available/$EE_DOMAIN /etc/nginx/sites-enabled/$EE_DOMAIN \ || ee_lib_error "Unable To Remove $EE_DOMAIN Nginx Configuration" else # User Denied Messages ee_lib_echo_fail "User Denied To Remove $EE_DOMAIN Nginx Configuration." fi } ee_mod_debug_nginx_start() { # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" if [ -z "$EE_IP_ADDRESS" ] then #read -p "Enter The Single IP Address For Debugging: " EE_IP_ADDRESS EE_IP_ADDRESS="0.0.0.0/0" fi for ee_debug_ip_address in $(echo $EE_IP_ADDRESS) do grep "debug_connection $ee_debug_ip_address" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Enable Debug Connection ee_lib_echo "Setting Up Nginx Debug Connection, Please Wait..." # EasyEngine Found New IP Address Which Is Not Present In nginx.conf sed -i "/events {/a \\\t$(echo debug_connection $ee_debug_ip_address\;)" /etc/nginx/nginx.conf # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" fi done if [ -z "$EE_DEBUG_NGINX" ] then ee_lib_echo "Nginx Debug Connection Already Enabled" fi } ee_mod_debug_nginx_stop() { grep "debug_connection" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then ee_lib_echo "Stopping Nginx Debug Connection, Please Wait..." sed -i "/debug_connection.*/d" /etc/nginx/nginx.conf else # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" ee_lib_echo "Nginx Debug Connection Already Stopped" fi } ee_mod_debug_nginx_rewrite_start() { grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Enable Nginx Rewrite Logs ee_lib_echo "Setting Up Nginx Rewrite Logs, Please Wait..." sed -i '/http {/a \\trewrite_log on;' /etc/nginx/nginx.conf else # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" ee_lib_echo "Nginx Rewrites Logs Already ON" fi } ee_mod_debug_nginx_rewrite_stop() { grep "rewrite_log on;" /etc/nginx/nginx.conf &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then # Disable Nginx Rewrite Logs ee_lib_echo "Stopping Nginx Rewrite Logs, Please Wait..." sed -i "/rewrite_log.*/d" /etc/nginx/nginx.conf else # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" ee_lib_echo "Nginx Rewrites Logs Already STOP" fi } ee_mod_debug_nginx_site_start() { grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Enable Nginx Debug Log ee_lib_echo "Setting Up $EE_DOMAIN Error Logs In Debugging Mode,Please Wait..." sed -i "s/error.log;/error.log debug;/" /etc/nginx/sites-available/$EE_DOMAIN else # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" ee_lib_echo "Already Started $EE_DOMAIN Error Logs In Debugging Mode" fi } ee_mod_debug_nginx_site_stop() { grep "error.log debug" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then # Disable Nginx Debug Log ee_lib_echo "Disable $EE_DOMAIN Error Logs In Debugging Mode,Please Wait..." sed -i "s/error.log debug;/error.log;/" /etc/nginx/sites-available/$EE_DOMAIN else # Lets Disable Nginx Reload Trigger EE_DEBUG_NGINX="" ee_lib_echo "Already Stopped $EE_DOMAIN Error Logs In Debugging Mode" fi } ee_mod_nginx_rewrite_site_start() { grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Enable Nginx Rewrite Logs ee_lib_echo "Setting Up Nginx Rewrite Logs For $EE_DOMAIN" sed -i "/access_log/i \\\trewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN else # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" ee_lib_echo "Rewrites Logs Already ON For $EE_DOMAIN" fi } ee_mod_nginx_rewrite_site_stop() { grep "rewrite_log on;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then # Disable Nginx Rewrite Logs ee_lib_echo "Stopping Up Nginx Rewrite Logs For $EE_DOMAIN" sed -i "/rewrite_log.*/d" /etc/nginx/sites-available/$EE_DOMAIN else # Lets Disable Nginx Reload Trigger EE_DEBUG_REWRITE="" ee_lib_echo "Rewrites Logs Already Stop For $EE_DOMAIN" fi } ee_mod_debug_php_start() { # Lets Disable PHP Restart Trigger EE_DEBUG_PHP="" if [ -z $EE_DEBUG_SITENAME ] then grep -B2 9001 /etc/nginx/conf.d/upstream.conf | grep php &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then ee_lib_echo "Enable PHP5-FPM Slow Log, Please Wait..." sed -i "4 s/9000/9001/" /etc/nginx/conf.d/upstream.conf # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" else ee_lib_echo "PHP5-FPM Slow Log Already Enabled" fi else grep 9001 /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then ee_lib_echo "Enable PHP5-FPM Slow Log For $EE_DOMAIN, Please Wait..." sed -i "s/fastcgi_pass.*/fastcgi_pass debug;/g" /etc/nginx/sites-available/$EE_DOMAIN # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" else ee_lib_echo "PHP5-FPM Slow Log Already Enabled For $EE_DOMAIN" fi fi } ee_mod_debug_php_stop() { # Lets Disable PHP Restart Trigger EE_DEBUG_PHP="" if [ -z $EE_DEBUG_SITENAME ] then grep -B2 9001 /etc/nginx/conf.d/upstream.conf | grep php &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then ee_lib_echo "Disable PHP5-FPM Slow Log, Please Wait..." sed -i "4 s/9001/9000/" /etc/nginx/conf.d/upstream.conf # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" else ee_lib_echo "PHP5-FPM Slow Log Already Disabled" fi else grep "fastcgi_pass debug;" /etc/nginx/sites-available/$EE_DOMAIN &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then ee_lib_echo "Disable PHP5-FPM Slow Log For $EE_DOMAIN, Please Wait..." sed -i "s/fastcgi_pass.*/fastcgi_pass php;/g" /etc/nginx/sites-available/$EE_DOMAIN # Lets Trigger The Nginx Reload EE_DEBUG_NGINX="--nginx" else ee_lib_echo "PHP5-FPM Slow Log Already Disabled For $EE_DOMAIN" fi fi } ee_mod_debug_php_fpm_start() { grep "log_level = debug" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Enable PHP5-FPM Error Logs In Debug Mode ee_lib_echo "Setting Up PHP5-FPM Log Level In Debug Mode, Please Wait..." sed -i "s';log_level.*'log_level = debug'" /etc/php5/fpm/php-fpm.conf else EE_DEBUG_FPM="" ee_lib_echo "PHP5-FPM Log Level Is Already In Debug Mode" fi } ee_mod_debug_php_fpm_stop() { grep "log_level = notice" /etc/php5/fpm/php-fpm.conf &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Disable PHP5-FPM Error Logs In Debug Mode ee_lib_echo "Stopping PHP5-FPM Log Level In Debug Mode, Please Wait..." sed -i "s/log_level = debug/log_level = notice/" /etc/php5/fpm/php-fpm.conf else EE_DEBUG_FPM="" ee_lib_echo "PHP5-FPM Log Level Already In Notice (Default) Mode" fi } ee_mod_debug_mysql_start() { # Collect MySQL Login Details MYSQLROOT # Check MySql Slow Logs Is ON #grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Enable MySQL Slow Logs ee_lib_echo "Setting Up MySQL Slow Log, Please Wait..." mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global slow_query_log = 'ON';" mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global long_query_time=2;" mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global log_queries_not_using_indexes = 'ON';" #sed -i "/#long_query_time/i slow-query-log = 1\nslow-query-log-file = /var/log/mysql/slow.log" /etc/mysql/my.cnf #sed -i "s/#long_query_time/long_query_time/" /etc/mysql/my.cnf #sed -i "s/#log-queries-not-using-indexes/log-queries-not-using-indexes/" /etc/mysql/my.cnf else # Lets Disable MySQL Restart Trigger #EE_DEBUG_MYSQL="" ee_lib_echo "MySQL Slow Log Already Enabled" fi } ee_mod_debug_mysql_stop() { # Collect MySQL Login Details MYSQLROOT # Check MySql Slow Logs Is OFF #grep slow-query-log /etc/mysql/my.cnf &>> $EE_COMMAND_LOG mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "show variables like 'slow_query_log';" | grep ON &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then # Disable MySQL Slow Logs ee_lib_echo "Stopping MySQL Slow Log, Please Wait..." mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global slow_query_log = 'OFF';" mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global slow_query_log_file = '/var/log/mysql/slow.log';" mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global long_query_time=10;" mysql -u $EE_MYSQL_USER -p$EE_MYSQL_PASS -e "set global log_queries_not_using_indexes = 'OFF';" #sed -i "/slow-query-log/d" /etc/mysql/my.cnf #sed -i "s/long_query_time/#long_query_time/" /etc/mysql/my.cnf #sed -i "s/log-queries-not-using-indexes/#log-queries-not-using-indexes/" /etc/mysql/my.cnf else # Lets Disable MySQL Restart Trigger #EE_DEBUG_MYSQL="" ee_lib_echo "MySQL Slow Log Already Disable" fi } ee_mod_debug_wordpress_start() { if [ -e /var/www/$EE_DOMAIN/wp-config.php ] then grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG if [ $? -ne 0 ] then # Debug WordPress ee_lib_echo "Start WordPress Debug Logs For $EE_DOMAIN" # Call PHPUSERINFO Function For PHP User Details PHPUSERINFO # Create debug.log & Change Permission touch /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log chown $PHPUSER:$PHPUSER /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log # Turn On Debug sed -i "s/define('WP_DEBUG'.*/define('WP_DEBUG', true);\ndefine('WP_DEBUG_DISPLAY', false);\ndefine('WP_DEBUG_LOG', true);\ndefine('SAVEQUERIES', true);/" /var/www/$EE_DOMAIN/wp-config.php # Install Developer Plugin # Installing Nginx Helper cd /var/www/$EE_DOMAIN/htdocs/ ee_lib_echo "Installing Developer Plugin, Please Wait..." wp plugin --allow-root install developer &>> $EE_COMMAND_LOG || ee_lib_error "Unable To Install Developer Plugin" else ee_lib_echo "WordPress Debug Log Already Started For $EE_DOMAIN" fi else ee_lib_echo_fail "Unable To Find wp-config.php File, Seems Like Not WordPress Site" fi } ee_mod_debug_wordpress_stop() { grep "'WP_DEBUG'" /var/www/$EE_DOMAIN/wp-config.php | grep true &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then # Stop Debug WordPress ee_lib_echo "Stopping WordPress Debug Logs For $EE_DOMAIN" sed -i "s/define('WP_DEBUG', true);/define('WP_DEBUG', false);/" /var/www/$EE_DOMAIN/wp-config.php sed -i "/define('WP_DEBUG_DISPLAY', false);/d" /var/www/$EE_DOMAIN/wp-config.php sed -i "/define('WP_DEBUG_LOG', true);/d" /var/www/$EE_DOMAIN/wp-config.php sed -i "/define('SAVEQUERIES', true);/d" /var/www/$EE_DOMAIN/wp-config.php else ee_lib_echo "WordPress Debug Log Already Stopped For $EE_DOMAIN" fi } ee_mod_debug_kill() { if [ "$EE_DEBUG" = "--start" ] then if [ -z "$EE_DEBUG_SITENAME" ] then ee debug --stop else ee debug --stop $EE_DEBUG_SITENAME fi fi # Unset Trap So We Don't Get Infinate Loop trap - EXIT # Flush File System Buffers # More Details: info coreutils 'sync invocation' sync # Successfull Exit exit 0; } trap "ee_mod_debug_kill" EXIT ee_mod_debug_interactive() { if [ -z "$EE_DEBUG_SITENAME" ] then tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log else tail -f /var/log/nginx/*.error.log /var/log/php5/*.log /var/log/mysql/*.log /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log fi } # Easy Engine Version # Easy Engine Help if [ "$1" = "help" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ] then # Display Man Pages man ee # Easy Engine Site Settings elif [ "$1" = "site" ] then # Easy Engine Site Enabled List if [ "$2" = "list" ] then if [ "$3" = "available" ] then # Display The List Of Available Sites ee_lib_echo "Display The List Of Available Websites:" ls /etc/nginx/sites-available/ \ || ee_lib_error "Unable To Display The List Of Available Websites" else # Display The List Of Enabled Websites ee_lib_echo "Display The List Of Enabled Websites:" ls /etc/nginx/sites-enabled/ \ || ee_lib_error "Unable To Display The List Of Enabled Websites" fi elif [ "$2" = "show" ] then # Check SITENAME Is Empty Or Not EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain # Check The Website Is Exist ls /etc/nginx/sites-available/$EE_DOMAIN &> /dev/null \ || ee_lib_error "The $EE_DOMAIN Is Not Found In Available Websites List" if [ $? -eq 0 ] then # Display The Specific Site Configuration 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" fi elif [ "$2" = "info" ] then # Check SITENAME Is Empty Or Not EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain # Display The Specific Site Configuration ee_mod_site_info elif [ "$2" = "create" ] then # Configure variables EE_DOMAIN_CHECK=$EE_THIRD EE_SITE_CREATE_OPTION=$4 EE_SITE_CACHE_OPTION=$5 # Auto Switch The 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=$5 EE_SITE_CACHE_OPTION=$4 else EE_SITE_CREATE_OPTION=--wp EE_SITE_CACHE_OPTION=$4 fi fi # WordPress SubDirectory Variables if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ] then EE_NETWORK_ACTIVATE="--network" fi # WordPress SubDomain Variables if [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] then EE_NETWORK_ACTIVATE="--network" EE_WP_SUBDOMAIN="--subdomains" fi # USE DEFAULT WHEN POSSIBLES # ee site create example.com if [ "$EE_SITE_CREATE_OPTION" = "" ] then EE_SITE_CREATE_OPTION=--html fi # If No Cache Specified Use --basic As Default On WordPress Sites 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 if [ "$EE_SITE_CREATE_OPTION" = "--html" ] then # Configure variable EE_NGINX_CONF=html/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 HTML Nginx ee_lib_check_domain ee_mod_setup_domain # 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 Success Message ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CREATE_OPTION" = "--php" ] then # Configure variable EE_NGINX_CONF=php/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 PHP Nginx ee_lib_check_domain ee_mod_setup_domain # 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 Success Message ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CREATE_OPTION" = "--mysql" ] then # Configure variable EE_NGINX_CONF=mysql/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 PHP Nginx ee_lib_check_domain ee_mod_setup_domain # 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" # Call MYSQLINFO Function For MySQL Values MYSQLINFO 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 # Display Success Message ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CREATE_OPTION" = "--wp" ] then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] then # Configure variable EE_NGINX_CONF=wp/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 Basic Nginx ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress ee_mod_plugin_nginx_helper # 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 Success Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] then # Configure variable EE_NGINX_CONF=wp/w3tc.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 W3 Total Cache Nginx ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress ee_mod_plugin_nginx_helper ee_mod_plugin_w3tc # 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 WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "W3 Total Cache: http://$EE_DOMAIN/wp-admin/admin.php?page=w3tc_general" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] then # Configure variable EE_NGINX_CONF=wp/wpsc.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 WP Super Cache Nginx ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress ee_mod_plugin_nginx_helper ee_mod_plugin_wpsc # 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 WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "WP Super Cache: http://$EE_DOMAIN/wp-admin/options-general.php?page=wpsupercache" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ] then # Configure variable EE_NGINX_CONF=wp/wpfc.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 Fastcgi Cache Nginx ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress ee_mod_plugin_nginx_helper ee_mod_plugin_w3tc # 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 WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "Nginx Helper: http://$EE_DOMAIN/wp-admin/options-general.php?page=nginx" ee_lib_echo "W3 Total Cache: http://$EE_DOMAIN/wp-admin/admin.php?page=w3tc_general" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" fi elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdir" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdirectory" ] then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] then # Configure variable EE_NGINX_CONF=wpsubdir/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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display Success Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] then # Configure variable EE_NGINX_CONF=wpsubdir/w3tc.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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK ee_mod_plugin_w3tc # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "W3 Total Cache: http://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] then # Configure variable EE_NGINX_CONF=wpsubdir/wpsc.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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK ee_mod_plugin_wpsc # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "WP Super Cache: http://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ] then # Configure variable EE_NGINX_CONF=wpsubdir/wpfc.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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK ee_mod_plugin_w3tc # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "Nginx Helper: http://$EE_DOMAIN/wp-admin/network/settings.php?page=nginx" ee_lib_echo "W3 Total Cache: http://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" fi elif [ "$EE_SITE_CREATE_OPTION" = "--wpsubdom" ] || [ "$EE_SITE_CREATE_OPTION" = "--wpsubdomain" ] then if [ "$EE_SITE_CACHE_OPTION" = "--basic" ] then # Configure variable EE_NGINX_CONF=wpsubdomain/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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display Success Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--w3tc" ] then # Configure variable EE_NGINX_CONF=wpsubdomain/w3tc.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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK ee_mod_plugin_w3tc # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "W3 Total Cache: http://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--wpsc" ] then # Configure variable EE_NGINX_CONF=wpsubdomain/wpsc.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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK ee_mod_plugin_wpsc # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "WP Super Cache: http://$EE_DOMAIN/wp-admin/network/settings.php?page=wpsupercache" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" elif [ "$EE_SITE_CACHE_OPTION" = "--wpfc" ] then # Configure variable EE_NGINX_CONF=wpsubdomain/wpfc.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 Domain WordPress & Database ee_lib_check_domain ee_mod_setup_domain # Setup MySQL database ee_mod_setup_database # Setup WordPress ee_mod_setup_wordpress # Setup WordPress SubDirectory Network SETUPWPNETWORK ee_mod_plugin_w3tc # 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" # Setup phpMyAdmin #ln -s /var/www/22222/htdocs/db/pma /var/www/$EE_DOMAIN/htdocs/pma # Display WordPress Plugin Configuration Message echo ee_lib_echo_info "WordPress Admin Username: $EE_WP_USER" ee_lib_echo_info "WordPress Admin Password: $EE_WP_PASS" echo ee_lib_echo "Please Configure The Following Settings..." #ee_lib_echo "Permalink Settings: http://$EE_DOMAIN/wp-admin/options-permalink.php" ee_lib_echo "Nginx Helper: http://$EE_DOMAIN/wp-admin/network/settings.php?page=nginx" ee_lib_echo "W3 Total Cache: http://$EE_DOMAIN/wp-admin/network/admin.php?page=w3tc_general" # Display Success Message echo ee_lib_echo_info "Successfully Created New Website: http://$EE_WWW_DOMAIN" fi fi elif [ "$2" = "enable" ] then # Check SITENAME Is Empty Or Not EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain # Creating Symbolic Link ee_lib_symbolic_link # Reload Nginx Configuration NGINXRELOAD # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx EE_GIT_MESSAGE="Enable Website: $EE_DOMAIN" ee_lib_git_commit elif [ "$2" = "disable" ] then # Check SITENAME 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" # Reload Nginx Configuration NGINXRELOAD # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx EE_GIT_MESSAGE="Disable Website: $EE_DOMAIN" ee_lib_git_commit elif [ "$2" = "delete" ] then # Check SITENAME Is Empty Or Not EE_DOMAIN_CHECK=$EE_THIRD EE_DELETE_ARGS=$4 ee_lib_check_domain # USE DEFAULT WHEN POSSIBLES if [ "$EE_DELETE_ARGS" = "" ] then EE_DELETE_ARGS=--all fi if [ "$EE_DELETE_ARGS" = "--db" ] then # Remove Database ee_mod_delete_database elif [ "$EE_DELETE_ARGS" = "--files" ] then # Remove Webroot ee_mod_delete_webroot elif [ "$EE_DELETE_ARGS" = "--all" ] then # Remove All Database And Webroot ee_mod_delete_database ee_mod_delete_webroot # Remove Nginx Configuration ee_mod_delete_nginxconf # Reload Nginx NGINXRELOAD # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx EE_GIT_MESSAGE="Delete Website With $EE_DELETE_ARGS Option: $EE_DOMAIN" ee_lib_git_commit elif [ "$EE_DELETE_ARGS" = "--all---no-prompt" ] then # Remove All Database And Webroot ee_mod_delete_database "--no-prompt" ee_mod_delete_webroot "--no-prompt" # Remove Nginx Configuration ee_mod_delete_nginxconf "--no-prompt" # Reload Nginx NGINXRELOAD # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx EE_GIT_MESSAGE="Delete Website With $EE_DELETE_ARGS Option: $EE_DOMAIN" ee_lib_git_commit fi elif [ "$2" = "edit" ] then # Check SITENAME Is Empty Or Not EE_DOMAIN_CHECK=$EE_THIRD ee_lib_check_domain # Edit The Nginx Configuration For $EE_DOMAIN EESITEEDIT if [ $(cd /etc/nginx; git status -s /etc/nginx/sites-available/$EE_DOMAIN | wc -l) -ne 0 ] then # Take Nginx Configuration In Git Version Control EE_GIT_DIR=/etc/nginx EE_GIT_MESSAGE="Edited Website: $EE_DOMAIN" ee_lib_git_commit # Reload Nginx Configuration NGINXRELOAD fi else ee_lib_echo "List Of Available Commands:" echo -e "\tinfo:\t Dispaly Information About Given Website" echo -e "\tlist:\t List Nginx Enabled Websites" echo -e "\tshow:\t Display Nginx Configuration For Given Website" echo -e "\tcreate:\t Create A New HTML PHP MySQL & WordPress Website" echo -e "\tdelete:\t Delete Existing Website" echo -e "\tenable:\t Enable Website" echo -e "\tedit: Manually Edit Website" fi elif [ "$1" = "debug" ] then # Default Action = Start Debugging EE_DEBUG="--start" # Auto Arrenge Options for ARGS in $@ do [ "$ARGS" = "-i" ] && EE_DEBUG_INTERACTIVE=$ARGS && echo EE_DEBUG_INTERACTIVE = $EE_DEBUG_INTERACTIVE &>> $EE_COMMAND_LOG [ "$ARGS" = "--stop" ] && EE_DEBUG=$ARGS && echo EE_DEBUG = $EE_DEBUG &>> $EE_COMMAND_LOG [ "$ARGS" = "--nginx" ] && EE_DEBUG_NGINX=$ARGS && echo EE_DEBUG_NGINX = $EE_DEBUG_NGINX &>> $EE_COMMAND_LOG [ "$ARGS" = "--rewrite" ] && EE_DEBUG_REWRITE=$ARGS && echo EE_DEBUG_REWRITE = $EE_DEBUG_REWRITE &>> $EE_COMMAND_LOG [ "$ARGS" = "--php" ] && EE_DEBUG_PHP=$ARGS && echo EE_DEBUG_PHP = $EE_DEBUG_PHP &>> $EE_COMMAND_LOG [ "$ARGS" = "--fpm" ] && EE_DEBUG_FPM=$ARGS && echo EE_DEBUG_FPM = $EE_DEBUG_FPM &>> $EE_COMMAND_LOG [ "$ARGS" = "--mysql" ] && EE_DEBUG_MYSQL=$ARGS && echo EE_DEBUG_MYSQL = $EE_DEBUG_MYSQL &>> $EE_COMMAND_LOG [ "$ARGS" = "--wp" ] && EE_DEBUG_WP=$ARGS && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG if [ "$ARGS" != "debug" ] && [ "$ARGS" != "-i" ] && [ "$ARGS" != "--start" ] && [ "$ARGS" != "--stop" ] && [ "$ARGS" != "--nginx" ] && [ "$ARGS" != "--rewrite" ] && [ "$ARGS" != "--php" ] && [ "$ARGS" != "--fpm" ] && [ "$ARGS" != "--mysql" ] && [ "$ARGS" != "--wp" ] then ls /etc/nginx/sites-available/ | grep $ARGS &>> $EE_COMMAND_LOG if [ $? -eq 0 ] then EE_DEBUG_SITENAME=$ARGS && echo EE_DEBUG_SITENAME = $EE_DEBUG_SITENAME &>> $EE_COMMAND_LOG fi fi done if [ "$EE_DEBUG" = "--start" ] then 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_DEBUG_SITENAME" ] then EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG fi fi if [ -z "$EE_DEBUG_SITENAME" ] then if [ "$EE_DEBUG_NGINX" = "--nginx" ] then # Debug Nginx ee_mod_debug_nginx_start # Log Message LOGMESSAGE="/var/log/nginx/*.error.log" fi if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Debug Nginx Rewrite Logs ee_mod_debug_nginx_rewrite_start # Log Message LOGMESSAGE="$LOGMESSAGE /var/log/nginx/*.error.log" fi if [ "$EE_DEBUG_WP" = "--wp" ] then ee_lib_echo_fail "The --wp Option Can Be Enabled For WordPress Site Only" fi else # Get The Domain Name EE_DOMAIN_CHECK=$EE_DEBUG_SITENAME ee_lib_check_domain if [ "$EE_DEBUG_NGINX" = "--nginx" ] then # Debug Nginx ee_mod_debug_nginx_site_start # Log Message LOGMESSAGE="/var/www/$EE_DOMAIN/logs/error.log" fi if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Debug Nginx Rewrite Logs ee_mod_nginx_rewrite_site_start # Log Message LOGMESSAGE="$LOGMESSAGE /var/log/$EE_DOMAIN/logs/error.log" fi if [ "$EE_DEBUG_WP" = "--wp" ] then # Debug WordPress Debug Log ee_mod_debug_wordpress_start # Log Message LOGMESSAGE="$LOGMESSAGE /var/www/$EE_DOMAIN/htdocs/wp-content/debug.log" fi fi if [ "$EE_DEBUG_PHP" = "--php" ] then # Debug PHP ee_mod_debug_php_start # Log Message LOGMESSAGE="$LOGMESSAGE /var/log/php5/slow.log" fi if [ "$EE_DEBUG_FPM" = "--fpm" ] then # Debug PHP FPM ee_mod_debug_php_fpm_start # Log Message LOGMESSAGE="$LOGMESSAGE /var/log/php5/fpm.log" fi if [ "$EE_DEBUG_MYSQL" = "--mysql" ] then # Debug MySQL Slow Query ee_mod_debug_mysql_start # Log Message LOGMESSAGE="$LOGMESSAGE /var/log/mysql/slow.log" fi elif [ "$EE_DEBUG" = "--stop" ] then 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 EE_DEBUG_WP="--wp" && echo EE_DEBUG_WP = $EE_DEBUG_WP &>> $EE_COMMAND_LOG fi if [ -z "$EE_DEBUG_SITENAME" ] then if [ "$EE_DEBUG_NGINX" = "--nginx" ] then # Debug Nginx ee_mod_debug_nginx_stop fi if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Debug Nginx Rewrite Logs ee_mod_debug_nginx_rewrite_stop fi else # Get The Domain Name EE_DOMAIN_CHECK=$EE_DEBUG_SITENAME ee_lib_check_domain if [ "$EE_DEBUG_NGINX" = "--nginx" ] then # Debug Nginx ee_mod_debug_nginx_site_stop fi if [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Debug Nginx Rewrite Logs ee_mod_nginx_rewrite_site_stop fi if [ "$EE_DEBUG_WP" = "--wp" ] then # Debug WordPress Debug Log ee_mod_debug_wordpress_stop fi fi if [ "$EE_DEBUG_PHP" = "--php" ] then # Debug PHP ee_mod_debug_php_stop fi if [ "$EE_DEBUG_FPM" = "--fpm" ] then # Debug PHP FPM ee_mod_debug_php_fpm_stop fi if [ "$EE_DEBUG_MYSQL" = "--mysql" ] then # Debug MySQL Slow Query ee_mod_debug_mysql_stop fi fi # Lets Restart Services if [ "$EE_DEBUG_NGINX" = "--nginx" ] || [ "$EE_DEBUG_REWRITE" = "--rewrite" ] then # Reload Nginx NGINXRELOAD fi if [ "$EE_DEBUG_PHP" = "--php" ] || [ "$EE_DEBUG_FPM" = "--fpm" ] then # Restart PHP5-FPM PHPRESTART fi #if [ "$EE_DEBUG_MYSQL" = "--mysql" ] #then # Restart MySQL #MYSQLRESTART #fi if [ "$EE_DEBUG_INTERACTIVE" = "-i" ] then # Lets Start Debug In Interactive Mode ee_mod_debug_interactive elif [ "$EE_DEBUG_INTERACTIVE" != "-i" ] && [ "$EE_DEBUG" != "--stop" ] then ee_lib_echo_info "tail -f $LOGMESSAGE" fi elif [ "$1" = "update" ] then # Update EasyEngine ee_lib_echo "Checking EasyEngine Update, Please Wait..." /bin/bash <(curl -sL https://raw.github.com/rtCamp/easyengine/stable/usr/local/sbin/eeupdate) else ee_lib_echo "List Of Available Commands:" echo -e "\tinfo:\t Display Nginx PHP MySQL Information\t" echo -e "\thelp:\t Display EasyEngine Help\t" echo -e "\tsite:\t Do Various Site Specific Operations\t" echo -e "\tdebug:\t Do Various Debugging Operations\t" echo -e "\tsystem:\t Do Various System Level Operations\t" echo -e "\tupdate:\t Update EasyEngine (ee)\t" echo -e "\tversion: Display EasyEngine (ee) Version\t" fi } EasyEngine $@ | tee -ai $EE_COMMAND_LOG