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.
 
 
 

1955 lines
54 KiB

#!/bin/bash
# This script is free software: you can redistribute it and/or modify
# it under the terms of the MIT License (MIT).
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MIT License (MIT) at (http://opensource.org/licenses/MIT) for
# more details.
# Make Variables Available For Later Use
LOGDIR=/var/log/easyengine
ERRORLOG=/var/log/easyengine/error.log
INSTALLLOG=/var/log/easyengine/install.log
# Main EasyEngine Function To Log All The Outputs
EasyEngine()
{
# Add TimeStamps In Install Log File
echo &>> $INSTALLLOG
echo &>> $INSTALLLOG
echo -e "\033[34mEasyEngine (ee) Execution Started [$(date)]\e[0m" &>> $INSTALLLOG
echo -e "\033[34mEasyEngine (ee) Command: $0 $@\e[0m" &>> $INSTALLLOG
# Check Auto Assume Yes Or No To Apt-Get
grep apt-get-assume-yes /etc/easyengine/ee.conf | grep -i true &>> /dev/null
if [ $? -eq 0 ]
then
EEAPTGET="apt-get -y"
else
# Check Any WebServer Package Is Installed Or Not
dpkg -l | egrep -e 'nginx|php|mysql|postfix|apache' &>> $INSTALLLOG
if [ $? -ne 0 ]
then
EEAPTGET="apt-get -y"
else
EEAPTGET="apt-get"
fi
fi
# Capture Errors
OwnError()
{
echo -e "[ `date` ] \033[31m $@ \e[0m" | tee -ai $ERRORLOG
exit 101
}
# Install Package Functions
PYTHONSOFTWARE()
{
# Install Python Software Properties
echo -e "\033[34mInstalling Python Software Properties, Please Wait...\e[0m"
sudo $EEAPTGET install python-software-properties \
|| OwnError "Unable To Install Python Software Properties"
}
NGINXREPO()
{
# Add Nginx Launchpad Repository
echo -e "\033[34mAdding Brianmercer Nginx Launchpad Repository, Please Wait...\e[0m"
sudo add-apt-repository -y ppa:brianmercer/nginx &>> $INSTALLLOG \
|| OwnError "Unable To Add Nginx Launchpad Repository"
}
PHPREPO()
{
# Add PHP Launchpad Repository
echo -e "\033[34mAdding Ondrej PHP5 Launchpad Repository, Please Wait...\e[0m"
sudo add-apt-repository -y ppa:ondrej/php5 &>> $INSTALLLOG \
|| OwnError "Unable To Add PHP5 Launchpad Repository"
}
GPGKEY()
{
# Force GPG KEYS Check
grep gpg-keys-fix /etc/easyengine/ee.conf | grep -i true &>> /dev/null
if [ $? -eq 0 ]
then
# Fix GPG Key Problems
echo -e "\033[34mChecking GPG Keys For Brianmercer Nginx Repository, Please Wait...\e[0m"
sudo apt-get update > /dev/null 2> /tmp/keymissing \
|| OwnError "Unable To Fix GPG Keys For Brianmercer Nginx Repository "
for key in $(grep "NO_PUBKEY" /tmp/keymissing |sed "s/.*NO_PUBKEY //")
do
echo -e "\033[34mProcessing key: $key\e[0m"
gpg --keyserver subkeys.pgp.net --recv $key && sudo gpg --export --armor $key | apt-key add -
done
fi
}
UPDATEAPT()
{
# Update The APT Cache
echo -e "\033[34mUpdating APT Cache, Please Wait...\e[0m"
sudo apt-get update &>> $INSTALLLOG || OwnError "Unable To Update APT Cache"
}
INSTALLNGINX()
{
# Install Nginx
echo -e "\033[34mInstalling Nginx, Please Wait...\e[0m"
sudo $EEAPTGET install nginx-custom || OwnError "Unable To Install Nginx"
}
EEMD5SUM()
{
SOURCE=$EESOURCE
DEST=$EEDEST
for i in $SOURCE/*
do
# Get File Name
EEFILE=$(basename $i)
SOURCEMD5SUM=$(md5sum $SOURCE/$EEFILE | cut -d' ' -f1)
DESTMD5SUM=$(md5sum $DEST/$EEFILE 2> /dev/null | cut -d' ' -f1)
# Check If Destination File Exist
if [ -z "$DESTMD5SUM" ]
then
# Copy Missing Destination Files
cp -i $SOURCE/$EEFILE $DEST/$EEFILE
elif [ "$SOURCEMD5SUM" != "$DESTMD5SUM" ]
then
# Update Destination On MD5SUM Not Matched
cp -i $SOURCE/$EEFILE $DEST/$EEFILE
fi
done
}
COMMONNGINX()
{
# Personal Settings For Nginx
echo -e "\033[34mUpdating Nginx Configuration Files, Please Wait...\e[0m"
grep "Easy Engine" /etc/nginx/nginx.conf &> /dev/null
if [ $? -ne 0 ]
then
# Change Nginx Worker Processes Connections And Gzip
sed -i "s/# gzip/gzip/" /etc/nginx/nginx.conf
sed -i "s/worker_connections.*/worker_connections 1024;/" /etc/nginx/nginx.conf
sed -i "s/worker_processes.*/worker_processes `cat /proc/cpuinfo | grep processor | wc -l`;/" /etc/nginx/nginx.conf
# Disable Nginx Version Set Custom Headers Variables And Proxy Settings
sed -i "s/http {/http {\n\t##\n\t# Easy Engine Settings\n\t##\n\n\tserver_tokens off;\n\tadd_header X-Powered-By "EasyEngine";\n\tadd_header rt-Fastcgi-Cache \$upstream_cache_status;\n\n\t# Limit Request\n\tlimit_req_status 403;\n\tlimit_req_zone \$binary_remote_addr zone=one:10m rate=1r\/s;\n\n\t# Proxy Settings\n\t# set_real_ip_from\tproxy-server-ip;\n\t# real_ip_header\tX-Forwarded-For;\n\n\tfastcgi_read_timeout 300;\n\tclient_max_body_size 100m;\n\n\t# SSL Settings\n\tssl_session_cache shared:SSL:20m;\n\tssl_session_timeout 10m;\n\tssl_prefer_server_ciphers on;\n\tssl_ciphers HIGH:\!aNULL:\!MD5:\!kEDH;\n\n/" /etc/nginx/nginx.conf
# Set Custom Logs
sed -i "s/error_log.*/error_log \/var\/log\/nginx\/error.log;\n\n\tlog_format rt_cache '\$remote_addr \$upstream_response_time \$upstream_cache_status [\$time_local] '\n\t\t'\$http_host \"\$request\" \$status \$body_bytes_sent '\n\t\t'\"\$http_referer\" \"\$http_user_agent\"';/" /etc/nginx/nginx.conf
fi
# Check Directory Exist
if [ ! -d /etc/nginx/conf.d ]
then
mkdir /etc/nginx/conf.d || OwnError "Unable To Create /etc/nginx/conf.d"
fi
if [ ! -d /etc/nginx/common ]
then
mkdir /etc/nginx/common || OwnError "Unable To Create /etc/nginx/common"
fi
# Update Nginx Configuration Files
EESOURCE="/usr/share/easyengine/nginx/conf.d"
EEDEST="/etc/nginx/conf.d"
EEMD5SUM
# Update Nginx Common Files
EESOURCE="/usr/share/easyengine/nginx/common"
EEDEST="/etc/nginx/common"
EEMD5SUM
# White List IP Address
sed -i "s/deny.*/$(echo "allow $(w | grep $(echo $SSH_TTY| cut -d'/' -f3,4) | awk '{print($3)}');")\ndeny all;/" /etc/nginx/common/allowed_ip.conf
# Protect EE Locations
# Get The htpasswd Details
HTPASSWDUSER=$(grep htpasswduser /etc/easyengine/ee.conf | awk '{print($3)}')
HTPASSWDPASS=$(grep htpasswdpass /etc/easyengine/ee.conf | awk '{print($3)}')
if [[ $HTPASSWDUSER = "" ]]
then
HTPASSWDUSER=easyengine
fi
if [[ $HTPASSWDPASS = "" ]]
then
HTPASSWDPASS=easyengine
fi
# Generate htpasswd-ee file
printf "$HTPASSWDUSER:$(openssl passwd -crypt $HTPASSWDPASS)\n" > /etc/nginx/htpasswd-ee
}
INSTALLPHP()
{
# Install PHP5
echo -e "\033[34mInstalling PHP5, Please Wait...\e[0m"
sudo $EEAPTGET install php5-common php5-mysqlnd php5-xmlrpc \
php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \
php5-memcache memcached || OwnError "Unable To Install PHP5"
}
COMMONPHP()
{
# Personal Settings For PHP
echo -e "\033[34mUpdating PHP Configuration Files, Please Wait...\e[0m"
grep "Easy Engine" /etc/php5/fpm/php.ini &> /dev/null
if [ $? -ne 0 ]
then
# Change PHP Settings
sed -i "s/\[PHP\]/[PHP]\n; Easy Engine/" /etc/php5/fpm/php.ini
sed -i "s/expose_php.*/expose_php = Off/" /etc/php5/fpm/php.ini
sed -i "s/post_max_size.*/post_max_size = 100M/" /etc/php5/fpm/php.ini
sed -i "s/upload_max_filesize.*/upload_max_filesize = 100M/" /etc/php5/fpm/php.ini
sed -i "s/max_execution_time.*/max_execution_time = 300/" /etc/php5/fpm/php.ini
# Enable PHP Status & Ping
sed -i "s/;ping.path/ping.path/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/;pm.status_path/pm.status_path/" /etc/php5/fpm/pool.d/www.conf
# Change PHP Pool Settings MAX Servers & Request Terminate Timeout
sed -i "s/;pm.max_requests/pm.max_requests/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/pm.max_children = 5/pm.max_children = 100/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/pm.start_servers = 2/pm.start_servers = 20/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/pm.min_spare_servers = 1/pm.min_spare_servers = 10/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/pm.max_spare_servers = 3/pm.max_spare_servers = 30/" /etc/php5/fpm/pool.d/www.conf
sed -i "s/;request_terminate_timeout.*/request_terminate_timeout = 300/" /etc/php5/fpm/pool.d/www.conf
# Change PHP Fastcgi Socket
sed -i "s'listen = /var/run/php5-fpm.sock'listen = 127.0.0.1:9000'" /etc/php5/fpm/pool.d/www.conf || OwnError "Unable To Change PHP Fastcgi Socket"
fi
}
WP-CLI()
{
# Install WP-CLI
if [ ! -d /usr/share/easyengine/wp-cli ]
then
echo -e "\033[31mWP-CLI Command Not Found\e[0m"
echo -e "\033[34mInstalling WP-CLI, Please Wait...\e[0m"
curl -s http://wp-cli.org/installer.sh | INSTALL_DIR='/usr/share/easyengine/wp-cli' bash &>> $INSTALLLOG \
|| OwnError "Unable To Install WP-CLI"
# Add WP-CLI Command In PATH Variable
ln -s /usr/share/easyengine/wp-cli/bin/wp /usr/bin/wp || OwnError "Unable To Create Symbolic Link For WP-CLI Command"
# Add WP-CLI Auto Completion
cp -i /usr/share/easyengine/wp-cli/vendor/wp-cli/wp-cli/utils/wp-completion.bash /etc/bash_completion.d/
source /etc/bash_completion.d/wp-completion.bash
else
echo -e "\033[34mAlready Installed WP-CLI (/usr/share/easyengine/wp-cli)...\e[0m"
fi
}
INSTALLPMA()
{
# Install PMA/phpMyAdmin
if [ ! -d /var/www/shared/pma ]
then
echo -e "\033[34mInstalling phpMyAdmin, Please Wait...\e[0m"
# Setup PMA/phpMyAdmin
mkdir -p /var/www/shared/pma/ || OwnError "Unable To Create phpMyAdmin Directory: /var/www/shared/pma/"
# Download PMA/phpMyAdmin
wget -cqO /var/www/shared/pma/pma.tar.gz http://dl.cihar.com/phpMyAdmin/master/phpMyAdmin-master-latest.tar.gz \
|| OwnError "Unable To Download phpMyAdmin"
# Extract PMA/phpMyAdmin
tar --strip-components=1 -zxf /var/www/shared/pma/pma.tar.gz -C /var/www/shared/pma/ \
|| OwnError "Unable To Extract phpMyAdmin"
# Remove Unwanted Files
rm -f /var/www/shared/pma/pma.tar.gz
else
echo -e "\033[34mAlready Installed phpMyAdmin (/var/www/shared/pma)...\e[0m"
fi
}
MYSQLINSTALLTWEAKS()
{
# MySQL Password Only Set If MySQL Is Not Installed
# If MySQL Is Installed Don't Set Wrong Password In ~/.my.cnf
dpkg -l | grep mysql-server &>> $INSTALLLOG
if [ $? -ne 0 ]
then
# Setting Up MySQL Password
MYSQLAUTOPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1)
debconf-set-selections <<< "mysql-server mysql-server/root_password password $MYSQLAUTOPASS"
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $MYSQLAUTOPASS"
# Generate ~/.my.cnf
echo -e "[client]\nuser=root\npassword=$MYSQLAUTOPASS" > ~/.my.cnf
fi
}
INSTALLMYSQL()
{
# Setting Up MySQL Password
MYSQLINSTALLTWEAKS
# Install MySQL
echo -e "\033[34mInstalling MySQL, Please Wait...\e[0m"
sudo $EEAPTGET install mysql-server mysqltuner \
|| OwnError "Unable To Install MySQL"
}
POSTFIXINSTALLTWEAKS()
{
# Setting Up Postfix
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
debconf-set-selections <<< "postfix postfix/mailname string $(hostname -f)"
}
INSTALLPOSTFIX()
{
# Setting Up Postfix
POSTFIXINSTALLTWEAKS
# Install Postfix
echo -e "\033[34mInstalling Postfix, Please Wait...\e[0m"
sudo $EEAPTGET install postfix || OwnError "Unable To Install Postfix"
}
INSTALLALL()
{
# Setting Up MySQL & Postfix
MYSQLINSTALLTWEAKS
POSTFIXINSTALLTWEAKS
# Install Nginx PHP5 MySQL Postfix
echo -e "\033[34mInstalling Nginx PHP5 MySQL Postfix, Please Wait...\e[0m"
sudo $EEAPTGET install nginx-custom php5-common php5-mysqlnd php5-xmlrpc \
php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \
php5-memcache memcached mysql-server mysqltuner postfix \
|| OwnError "Unable To Install Nginx PHP5 MySQL Postfix"
}
# Remove Package Functions
REMOVENGINX()
{
# Remove Nginx
echo -e "\033[34mRemoving Nginx, Please Wait...\e[0m"
sudo $EEAPTGET remove nginx-custom nginx-common || OwnError "Unable To Remove Nginx"
}
REMOVEPHP()
{
# Remove PHP5
echo -e "\033[34mRemoving PHP5, Please Wait...\e[0m"
sudo $EEAPTGET remove php5-common php5-mysqlnd php5-xmlrpc \
php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \
php5-memcache memcached || OwnError "Unable To Remove PHP5"
}
REMOVEWPCLI()
{
# Remove WP-CLI
echo -e "\033[34mRemoving WP-CLI, Please Wait...\e[0m"
rm -rf /usr/share/easyengine/wp-cli /usr/bin/wp /etc/bash_completion.d/wp-completion.bash || OwnError "Unable To Remove WP-CLI"
}
REMOVEPMA()
{
# Remove PMA/phpMyAdmin
echo -e "\033[34mRemoving phpMyAdmin, Please Wait...\e[0m"
rm -rf /var/www/shared/pma || OwnError "Unable To Remove phpMyAdmin"
}
REMOVEMYSQL()
{
# Remove MySQL
echo -e "\033[34mRemoving MySQL, Please Wait...\e[0m"
sudo $EEAPTGET remove mysql-server mysqltuner \
|| OwnError "Unable To Remove MySQL"
}
REMOVEPOSTFIX()
{
# Remove Postfix
echo -e "\033[34mRemoving Postfix, Please Wait...\e[0m"
sudo $EEAPTGET remove postfix || OwnError "Unable To Remove Postfix"
}
REMOVEALL()
{
# Remove Nginx PHP5 MySQL Postfix
echo -e "\033[34mRemoving Nginx PHP5 MySQL Postfix, Please Wait...\e[0m"
sudo $EEAPTGET remove nginx-custom nginx-common php5-common php5-mysqlnd php5-xmlrpc \
php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \
php5-memcache memcached mysql-server mysqltuner postfix \
|| OwnError "Unable To Remove Nginx PHP5 MySQL Postfix"
}
AUTOREMOVE()
{
# Remove Unwanted Packages
echo -e "\033[34mRemoving Unwanted Packages, Please Wait...\e[0m"
sudo $EEAPTGET autoremove || OwnError "Unable To Auto Remove"
}
# Purge Package Functions
PURGENGINX()
{
# Purge Nginx
echo -e "\033[34mPurge Nginx, Please Wait...\e[0m"
sudo $EEAPTGET purge nginx-custom nginx-common || OwnError "Unable To Purge Nginx"
}
PURGEPHP()
{
# Purge PHP5
echo -e "\033[34mPurge PHP5, Please Wait...\e[0m"
sudo $EEAPTGET purge php5-common php5-mysqlnd php5-xmlrpc \
php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \
php5-memcache memcached || OwnError "Unable To Purge PHP5"
}
PURGEMYSQL()
{
# Purge MySQL
echo -e "\033[34mPurge MySQL, Please Wait...\e[0m"
sudo $EEAPTGET purge mysql-server mysqltuner \
|| OwnError "Unable To Purge MySQL"
}
PURGEPOSTFIX()
{
# Purge Postfix
echo -e "\033[34mPurge Postfix, Please Wait...\e[0m"
sudo $EEAPTGET purge postfix || OwnError "Unable To Purge Postfix"
}
PURGEALL()
{
# Purge Nginx PHP5 MySQL Postfix
echo -e "\033[34mRemoving Nginx PHP5 MySQL Postfix, Please Wait...\e[0m"
sudo $EEAPTGET purge nginx-custom nginx-common php5-common php5-mysqlnd php5-xmlrpc \
php5-curl php5-gd php5-cli php5-fpm php5-imap php5-mcrypt \
php5-memcache memcached mysql-server mysqltuner postfix \
|| OwnError "Unable To Purge Nginx PHP5 MySQL Postfix"
}
# EE GIT Function
EEGITINIT()
{
# Change Directory
cd $EEGITDIR || OwnError "Unable To Change Directory $EEGITDIR"
# Check .git
if [ ! -d .git ]
then
# Initialise Git
echo -e "\033[34mInitialise Git On $EEGITDIR...\e[0m"
git init &>> $INSTALLLOG || OwnError "Unable To Initialize Git On $EEGITDIR"
fi
# Check For Untracked Files
git status | grep clean
if [ $? -ne 0 ]
then
# Add Files In Git Version Control
git add . && git commit -am "Initialize Git On $EEGITDIR" &>> $INSTALLLOG \
|| OwnError "Unable To Git Commit On $EEGITDIR"
fi
}
EEGITCOMMIT()
{
cd $EEGITDIR || OwnError "Unable To Change Directory $EEGITDIR"
git status | grep --color=auto clean
if [ $? -ne 0 ]
then
# Git Commit Functionality
echo -e "\033[34mTake $EEGITDIR Configuration In Git Version Control...\e[0m"
# Add Newly Created Files && Commit It
git add . && git commit -am "$EEGITMESSAGE" &>> $INSTALLLOG \
|| OwnError "Unable To Git Commits On $EEGITDIR"
fi
}
MYSQLUSERPASS()
{
read -p "Enter The MySQL Username [root]: " MYSQLUSER
# If Enter Is Pressed, Then Use root as MySQL User
if [[ $MYSQLUSER = "" ]]
then
MYSQLUSER=root
fi
# Turn Off Echo For Passwords
stty -echo
read -p "Enter The MySQL Password: " MYSQLPASS
stty echo
echo
}
MYSQLPASSCHECK()
{
while [ -n $(mysqladmin -h $MYSQLHOST -u $MYSQLUSER -p$MYSQLPASS ping 2> /dev/null | grep alive) &> /dev/null ]
do
# Verify MySQL Credentials
MYSQLUSERPASS
done
}
# GET Information Function
MYSQLINFO()
{
# Get The MySQL Host
MYSQLHOST=$(grep mysqlhost /etc/easyengine/ee.conf | awk '{print($3)}')
# MySQL Default Host: localhost
if [[ $MYSQLHOST = "" ]]
then
MYSQLHOST=localhost
fi
if [ -f ~/.my.cnf ]
then
MYSQLUSER=$(cat ~/.my.cnf | grep user | cut -d'=' -f2)
MYSQLPASS=$(cat ~/.my.cnf | grep pass | cut -d'=' -f2)
else
# Verify MySQL Credentials
MYSQLUSERPASS
fi
# Verify MySQL Credentials
MYSQLPASSCHECK
# Replace Dot With Underscore In $DOMAIN Name
REPLACEDOT=$(echo $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 [$REPLACEDOT]: " WPDBNAME
fi
# If customdbname = false
# Then It Never Ask For MySQL Database Name In This Case $WPDBNAME Is Empty
# If customdbname = true
# User Enter Custom Databse Name Then WPDBNAME Is Not Empty & We Used Provided Database Name
# If User Pressed Enter Then $WPDBNAME Is Empty
if [[ $WPDBNAME = "" ]]
then
WPDBNAME=$REPLACEDOT
fi
# Get The WordPress Database Table Prefix
WPDBPREFIX=$(grep wpdbprefix /etc/easyengine/ee.conf | awk '{print($3)}')
# Display WPDBPREFIX Valid Characters Warning & Try Again
while [ $(echo $WPDBPREFIX | grep '[^[:alnum:] _]') ]
do
echo -e "\033[31mWarning: \033[34mTable Prefix Can Only Contain Numbers, Letters, And Underscores.\e[0m"
# For Proper read Command Output
stty echo
read -p "Enter The MySQL Database Table Prefix [wp_]: " WPDBPREFIX
done
# WordPress Database Table Prefix Default: wp_
if [[ $WPDBPREFIX = "" ]]
then
WPDBPREFIX=wp_
fi
# Create Database
mysql -h $MYSQLHOST -u $MYSQLUSER -p$MYSQLPASS -e "create database \`$WPDBNAME\`" \
|| OwnError "Unable To Create $WPDBNAME Database"
}
PHPUSERINFO()
{
# PHP User
PHPUSER=$(grep ^user /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2 | cut -d' ' -f2) \
|| OwnError "Unable To Find Out PHP Username"
}
SYSTEMINFO()
{
# Nginx Information
NGINXVER=$(nginx -v 2>&1 | cut -d':' -f2 | cut -d' ' -f2)
NGINXUSER=$(grep ^user /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1)
NGINXPROCESSES=$(grep worker_processes /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1)
NGINXCONNECTIONS=$(grep worker_connections /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1)
NGINXKEEPALIVE=$(grep keepalive_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1)
FASTCGITIMEOUT=$(grep fastcgi_read_timeout /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1)
CLIENTMAXBODYSIZE=$(grep client_max_body_size /etc/nginx/nginx.conf | cut -d' ' -f2 | cut -d';' -f1)
NGINXALLOWEDIPADD=$(grep ^allow /etc/nginx/common/allowed_ip.conf | cut -d' ' -f2 | cut -d';' -f1 | tr '\n' ' ')
echo -e "\033[34mNginx ($NGINXVER) Information:\n\e[0m"
echo -e "\033[34mNginx User:\t\t\t \033[37m$NGINXUSER\e[0m"
echo -e "\033[34mNginx worker_processes:\t\t \033[37m$NGINXPROCESSES\e[0m"
echo -e "\033[34mNginx worker_connections:\t \033[37m$NGINXCONNECTIONS\e[0m"
echo -e "\033[34mNginx keepalive_timeout:\t \033[37m$NGINXKEEPALIVE\e[0m"
echo -e "\033[34mNginx fastcgi_read_timeout:\t \033[37m$FASTCGITIMEOUT\e[0m"
echo -e "\033[34mNginx client_max_body_size:\t \033[37m$CLIENTMAXBODYSIZE\e[0m"
echo -e "\033[34mNginx Allowed IP Address:\t \033[37m$NGINXALLOWEDIPADD\e[0m"
# PHP Information
# Collect Information From php.ini
PHPUSERINFO
PHPVER=$(php -v | head -n1 | cut -d' ' -f2 | cut -d'+' -f1)
PHPEXPOSE=$(grep ^expose_php /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2)
PHPPOSTMAXSIZE=$(grep post_max_size /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2)
PHPUPLOADMAXFSIZE=$(grep upload_max_filesize /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2)
PHPMAXEXECUTIONTIME=$(grep max_execution_time /etc/php5/fpm/php.ini | cut -d'=' -f2 | cut -d' ' -f2)
# Collect Information From www.conf
PHPPINGPATH=$(grep ^ping.path /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PHPSTATUSPATH=$(grep ^pm.status_path /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PMMAXREQUEST=$(grep ^pm.max_requests /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PMMAXCHILDREN=$(grep ^pm.max_children /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PMSTARTSERVERS=$(grep ^pm.start_servers /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PMMINSPARESERVERS=$(grep ^pm.min_spare_servers /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PMMAXSPARESERVERS=$(grep ^pm.max_spare_servers /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PHPREQUESTTERMINATE=$(grep ^request_terminate_timeout /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
PHPFASTCGIREQUEST=$(grep ^listen /etc/php5/fpm/pool.d/www.conf | cut -d'=' -f2| cut -d' ' -f2)
echo -e "\033[34m\n\n PHP ($PHPVER) Information:\n\e[0m"
echo -e "\033[34mPHP User:\t\t\t \033[37m$PHPUSER\e[0m"
echo -e "\033[34mPHP expose_php:\t\t\t \033[37m$PHPEXPOSE\e[0m"
echo -e "\033[34mPHP post_max_size:\t\t \033[37m$PHPPOSTMAXSIZE\e[0m"
echo -e "\033[34mPHP upload_max_filesize:\t \033[37m$PHPUPLOADMAXFSIZE\e[0m"
echo -e "\033[34mPHP max_execution_time:\t\t \033[37m$PHPMAXEXECUTIONTIME\n\e[0m"
echo -e "\033[34mPHP ping.path:\t\t\t \033[37m$PHPPINGPATH\e[0m"
echo -e "\033[34mPHP pm.status_path:\t\t \033[37m$PHPSTATUSPATH\e[0m"
echo -e "\033[34mPHP pm.max_requests:\t\t \033[37m$PMMAXREQUEST\e[0m"
echo -e "\033[34mPHP pm.max_children:\t\t \033[37m$PMMAXCHILDREN\e[0m"
echo -e "\033[34mPHP pm.start_servers:\t\t \033[37m$PMSTARTSERVERS\e[0m"
echo -e "\033[34mPHP pm.min_spare_servers:\t \033[37m$PMMINSPARESERVERS\e[0m"
echo -e "\033[34mPHP pm.max_spare_servers:\t \033[37m$PMMAXSPARESERVERS\e[0m"
echo -e "\033[34mPHP request_terminate_timeout:\t \033[37m$PHPREQUESTTERMINATE\e[0m"
echo -e "\033[34mPHP Fastcgi Listen:\t\t \033[37m$PHPFASTCGIREQUEST\e[0m"
}
NGINXBUCKETSIZE()
{
nginx -t 2>&1 | grep server_names_hash_bucket_size
if [ $? -eq 0 ]
then
NGINXCALCULATION=$(echo "l($(ls /etc/nginx/sites-enabled/ | wc -c))/l(2)+2" | bc -l)
NGINXSETBUCKET=$(echo "2^$NGINXCALCULATION" | bc -l)
sed -i "s/.*server_names_hash_bucket_size.*/\tserver_names_hash_bucket_size $NGINXSETBUCKET;/" /etc/nginx/nginx.conf
fi
}
NGINXRELOAD()
{
# Check Nginx server_names_hash_bucket_size Value
NGINXBUCKETSIZE
# Reload Nginx Configuration
echo -e "\033[34mReloading Nginx Configuration, Please Wait...\e[0m"
(nginx -t && service nginx reload) &>> $INSTALLLOG || OwnError "Unable To Reload Nginx"
}
NGINXRESTART()
{
# Check Nginx server_names_hash_bucket_size Value
NGINXBUCKETSIZE
# Test & Reload Nginx
echo -e "\033[34mRestarting Nginx Configuration, Please Wait...\e[0m"
(nginx -t && service nginx restart) &>> $INSTALLLOG || OwnError "Unable To Restart Nginx"
}
PHPRESTART()
{
# Reload PHP
echo -e "\033[34mRestarting PHP5-FPM Configuration, Please Wait...\e[0m"
service php5-fpm restart &>> $INSTALLLOG || OwnError "Unable To Restart PHP5-FPM"
}
# EE Domian Functions
EESITENAME()
{
# Check SITENAME Is Empty Or Not
if [ -z "$SITENAMECHECK" ]
then
# Ask Users To Enter Domain Name
read -p "Enter Domain Name: " SITENAMECHECK
# Remove http:// https:// & www.
DOMAIN=$(echo $SITENAMECHECK | tr 'A-Z' 'a-z' | sed "s'http://''" | sed "s'https://''" | sed "s'www.''" | sed "s'/''")
else
# Remove http:// https:// & www.
DOMAIN=$(echo $SITENAMECHECK | tr 'A-Z' 'a-z' | sed "s'http://''" | sed "s'https://''" | sed "s'www.''" | sed "s'/''")
fi
}
NGINXSYMBOLICLINK()
{
# Creating Symbolic Link
echo -e "\033[34mCreating Symbolic Link For $DOMAIN\e[0m"
ln -s /etc/nginx/sites-available/$DOMAIN /etc/nginx/sites-enabled/ \
|| OwnError "Unable To Create Symbolic Link For $DOMAIN"
}
EEDOMAINSETUP()
{
#Check The Nginx Configuration Exist For $DOMAIN
ls /etc/nginx/sites-available/$DOMAIN &> $ERRORLOG
if [ $? -ne 0 ]
then
# Creating Website $DOMAIN
echo -e "\033[34mCreating $DOMAIN, Please Wait...\e[0m"
sed "s/example.com/$DOMAIN/g" \
/usr/share/easyengine/nginx/$NGINXCONF \
> /etc/nginx/sites-available/$DOMAIN \
|| OwnError "Unable To Create Nginx Configuration File For $DOMAIN"
# Creating Symbolic Link
NGINXSYMBOLICLINK
# Creating Htdocs & Logs Directory
echo -e "\033[34mCreating htdocs & logs Directory\e[0m"
mkdir -p /var/www/$DOMAIN/htdocs && mkdir -p /var/www/$DOMAIN/logs \
|| OwnError "Unable To Create htdocs & logs Directory"
# Creating Symbolic Links For Logs
echo -e "\033[34mCreating Symbolic Link For Logs\e[0m"
ln -s /var/log/nginx/$DOMAIN.access.log /var/www/$DOMAIN/logs/access.log \
&& ln -s /var/log/nginx/$DOMAIN.error.log /var/www/$DOMAIN/logs/error.log \
|| OwnError "Unable To Create Symbolic Link For $DOMAIN Logs"
else
OwnError "$DOMAIN Already Exist"
fi
}
EEWPSETUP()
{
# Download Latest WordPress
echo -e "\033[34mDownloading WordPress, Please Wait...\e[0m"
wget -cqO /var/www/$DOMAIN/htdocs/latest.tar.gz \
http://wordpress.org/latest.tar.gz \
|| OwnError "Unable To Download WordPress"
# Extracting WordPress
tar --strip-components=1 -zxf /var/www/$DOMAIN/htdocs/latest.tar.gz \
-C /var/www/$DOMAIN/htdocs/ \
|| OwnError "Unable To Extract WordPress"
# Removing WordPress Archive
rm /var/www/$DOMAIN/htdocs/latest.tar.gz
# Call MYSQLINFO Function For MySQL Values
MYSQLINFO
# Modify wp-config.php & Move Outside The Webroot
cp /var/www/$DOMAIN/htdocs/wp-config-sample.php \
/var/www/$DOMAIN/wp-config.php
sed -i "s/database_name_here/$WPDBNAME/" \
/var/www/$DOMAIN/wp-config.php
sed -i "s/username_here/$MYSQLUSER/" \
/var/www/$DOMAIN/wp-config.php
sed -i "s/password_here/$MYSQLPASS/" \
/var/www/$DOMAIN/wp-config.php
sed -i "s/localhost/$MYSQLHOST/" \
/var/www/$DOMAIN/wp-config.php
sed -i "s/wp_/$WPDBPREFIX/" \
/var/www/$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/$DOMAIN/wp-config.php
}
EEWPDBSETUP()
{
# Get WordPress Site Title
#echo -e "\033[34mWordPress Information Required...\e[0m"
# WordPress Default User: admin
WPADMINUSER=$(grep wpadminuser /etc/easyengine/ee.conf | awk '{print($3)}')
if [[ $WPADMINUSER = "" ]]
then
WPADMINUSER=admin
fi
# WordPress Default Password: Random Password
WPADMINPASS=$(grep wpadminpass /etc/easyengine/ee.conf | awk '{print($3)}')
if [[ $WPADMINPASS = "" ]]
then
WPADMINPASS=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 15 | head -n1)
fi
# WordPress Default Email: `whoami`@`hostname -f`
WPADMINEMAIL=$(grep wpadminemail /etc/easyengine/ee.conf | awk '{print($3)}')
if [[ $WPADMINEMAIL = "" ]]
then
WPADMINEMAIL=`whoami`@`hostname -f`
fi
# Create WordPress Tables
echo -e "\033[34mSetting Up WordPress, Please Wait...\e[0m"
cd /var/www/$DOMAIN/htdocs || OwnError "Unable To Change Directory To Install WordPress"
wp core install --url=$DOMAIN --title="$DOMAIN" \
--admin_name=$WPADMINUSER --admin_password=$WPADMINPASS --admin_email=$WPADMINEMAIL &>> $INSTALLLOG \
|| OwnError "Unable To Create WordPress Tables For $DOMAIN"
}
EEPERMISSION()
{
# Call PHPUSERINFO Function For PHP User Details
PHPUSERINFO
# Change Ownership
echo -e "\033[34mChanging Ownership\e[0m"
chown -R $PHPUSER:$PHPUSER /var/www/$DOMAIN/ || OwnError "Unable To Change Ownership For $DOMAIN"
# Reload Nginx Configuration
NGINXRELOAD
}
# NGINX Configuration Function
SETUPDOMAIN()
{
# Check SITENAME Is Empty Or Not
EESITENAME
# Creating Website $DOMAIN
EEDOMAINSETUP
# Setup WordPress Webroot & Database
EEWPSETUP
EEWPDBSETUP
}
PERMISSIONANDGIT()
{
# Change Webroot Permission
EEPERMISSION
# Take Nginx Configuration In Git Version Control
EEGITDIR=/etc/nginx
EEGITMESSAGE="Created New $WPNETWORKSITE $WPCACHEOPTION Website: $DOMAIN"
EEGITCOMMIT
}
EEOPMEMCACHE()
{
# Opcache Settings
if [ ! -d /var/www/shared/opcache ]
then
mkdir -p /var/www/shared/opcache || OwnError "Unable To Create Opcache Directory"
# Download Opcache Status Files
wget -cqO /var/www/shared/opcache/opcache.php https://raw.github.com/rlerdorf/opcache-status/master/opcache.php
wget -cqO /var/www/shared/opcache/opgui.php https://raw.github.com/amnuts/opcache-gui/master/index.php
wget -cqO /var/www/shared/opcache/ocp.php https://gist.github.com/ck-on/4959032/raw/0b871b345fd6cfcd6d2be030c1f33d1ad6a475cb/ocp.php
fi
# Memcache Settings
if [ ! -d /var/www/shared/memcache ]
then
mkdir -p /var/www/shared/memcache || OwnError "Unable To Create Memcache Directory"
# Download phpMemcachedAdmin
wget -cqO /var/www/shared/memcache/memcache.tar.gz http://phpmemcacheadmin.googlecode.com/files/phpMemcachedAdmin-1.2.2-r262.tar.gz
# Extract phpMemcachedAdmin
tar -zxf /var/www/shared/memcache/memcache.tar.gz -C /var/www/shared/memcache
# Remove Unwanted Files
rm -f /var/www/shared/memcache/memcache.tar.gz
fi
}
TOTALCACHENGINX()
{
# Installing W3 Total Cache
cd /var/www/$DOMAIN/htdocs/
echo -e "\033[34mInstalling W3 Total Cache Plugin, Please Wait...\e[0m"
wp plugin install w3-total-cache &>> $INSTALLLOG || OwnError "Unable To Install W3 Total Cache Plugin"
# Activate W3 Total Cache
wp plugin activate w3-total-cache $NETWORKACTIVATE &>> $INSTALLLOG || OwnError "Unable To Activate W3 Total Cache Plugin"
# Install Opcache & Memcache
EEOPMEMCACHE
}
SUPERCACHENGINX()
{
# Installing WP Super Cache
cd /var/www/$DOMAIN/htdocs/
echo -e "\033[34mInstalling WP Super Cache Plugin, Please Wait...\e[0m"
wp plugin install wp-super-cache &>> $INSTALLLOG || OwnError "Unable To Install WP Super Cache Plugin"
# Activate WP Super Cache
wp plugin activate wp-super-cache $NETWORKACTIVATE &>> $INSTALLLOG || OwnError "Unable To Activate WP Super Cache Plugin"
}
NGINXHELPER()
{
# Installing Nginx Helper
cd /var/www/$DOMAIN/htdocs/
echo -e "\033[34mInstalling Nginx Helper Plugin, Please Wait...\e[0m"
wp plugin install nginx-helper &>> $INSTALLLOG || OwnError "Unable To Install Nginx Helper"
# Activate Nginx Helper
wp plugin activate nginx-helper $NETWORKACTIVATE &>> $INSTALLLOG || OwnError "Unable To Activate Nginx Helper Plugin"
}
# Setup Wordpress Network
SETUPWPNETWORK()
{
# Prepare wp-config.php File Foe WordPress Multisite With SubDirectory
cd /var/www/$DOMAIN/htdocs || OwnError "Unable To Change Directory"
wp core install-network --title="$SITETITLE" $WPSUBDOMAINS || OwnError "Unable To Setup WordPress SubDirectory Network"
sed -i "/WP_DEBUG/a \define('WP_ALLOW_MULTISITE', true);" /var/www/$DOMAIN/wp-config.php
sed -i "/WP_ALLOW_MULTISITE/a \define('WPMU_ACCEL_REDIRECT', true);" /var/www/$DOMAIN/wp-config.php
# Remove index.php from permalink
# Install Nginx Helper
NGINXHELPER
}
# Remove Database
REMOVEDB()
{
# HTML & PHP Website Doesn't Have Database
head -n1 /etc/nginx/sites-available/$DOMAIN | egrep -e 'HTML|PHP' &>> $INSTALLLOG
if [ $? -ne 0 ]
then
# MySQL Information
WPDBNAME=$(grep DB_NAME /var/www/$DOMAIN/wp-config.php | cut -d"'" -f4)
MYSQLUSER=$(grep DB_USER /var/www/$DOMAIN/wp-config.php | cut -d"'" -f4)
MYSQLPASS=$(grep DB_PASS /var/www/$DOMAIN/wp-config.php | cut -d"'" -f4)
echo -e " WPDBNAME = $WPDBNAME \n MYSQLUSER = $MYSQLUSER"
# Remove Database
# For Proper read Command Output
stty echo
read -p "Are You Sure To Drop $WPDBNAME Database (y/n): " ANSWER
if [ "$ANSWER" = "y" ]
then
# Remove Database
mysql -u $MYSQLUSER -p$MYSQLPASS -e "drop database \`$WPDBNAME\`" \
|| OwnError "Unable To Drop $WPDBNAME Database"
else
# User Denied Messages
echo -e "\033[31mUser Denied To Drop $WPDBNAME Database.\e[0m"
fi
else
echo -e "\033[31mNo Database Found For $DOMAIN\e[0m"
fi
}
REMOVEFILES()
{
# Remove Webroot
# For Proper read Command Output
stty echo
read -p "Are You Sure To Remove $DOMAIN Webroot (y/n): " ANSWER
if [ "$ANSWER" = "y" ]
then
# Remove Webroot
rm -rf /var/www/$DOMAIN || OwnError "Unable To Remove $DOMAIN Webroot"
else
# User Denied Messages
echo -e "\033[31mUser Denied To Remove $DOMAIN Webroot.\e[0m"
fi
}
REMOVENGINXCONF()
{
# Remove Nginx Configuration
# For Proper read Command Output
stty echo
read -p "Are You Sure To Remove $DOMAIN Nginx Configuraion (y/n): " ANSWER
if [ "$ANSWER" = "y" ]
then
# Remove Webroot
rm -rf /etc/nginx/sites-available/$DOMAIN /etc/nginx/sites-enabled/$DOMAIN \
|| OwnError "Unable To Remove $DOMAIN Nginx Configuration"
else
# User Denied Messages
echo -e "\033[31mUser Denied To Remove $DOMAIN Nginx Configuration.\e[0m"
fi
}
# Easy Engine Help
if [ "$1" = "-h" ] || [ "$1" = "help" ] || [ "$1" = "--help" ]
then
# Display Man Pages
man ee
# Easy Engine Version
elif [ "$1" = "-v" ] || [ "$1" = "version" ] || [ "$1" = "--version" ]
then
# Display Easy Engine Version
echo "easyengine version: 1.0.0"
# Easy Engine System Settings
elif [ "$1" = "system" ]
then
# Easy Engine Install
if [ "$2" = "install" ]
then
if [ "$3" = "nginx" ]
then
# Install Python Software Properties
PYTHONSOFTWARE
# Add Nginx Launchpad Repository
NGINXREPO
# Fix GPG Key Problems
GPGKEY
# Update The APT Cache
UPDATEAPT
# Install Nginx
INSTALLNGINX
# Personal Settings For Nginx
COMMONNGINX
# Restart Nginx To Take Effect Of COMMONNGINX Functions
NGINXRESTART
# Initialise Git
EEGITDIR=/etc/nginx/
EEGITINIT
# Display Success Message
echo -e "\033[34mNginx Successfully Installed\e[0m"
elif [ "$3" = "php" ]
then
# Install Python Software Properties
PYTHONSOFTWARE
# Add PHP Launchpad Repository
PHPREPO
# Fix GPG Key Problems
GPGKEY
# Update The APT Cache
UPDATEAPT
# Install PHP5
INSTALLPHP
# Personal Settings For PHP
COMMONPHP
# Restart PHP To Take Effect Of COMMONPHP Functions
PHPRESTART
# Install WP-CLI
WP-CLI
# Initialise Git
EEGITDIR=/etc/php5/
EEGITINIT
# Display Success Message
echo -e "\033[34mPHP5 & WP-CLI Successfully Installed\e[0m"
elif [ "$3" = "pma" ]
then
# Install PMA/phpMyAdmin
INSTALLPMA
# Initialise Git
EEGITDIR=/var/www/shared/pma/
EEGITINIT
# Display Success Message
echo -e "\033[34mphpMyAdmin Successfully Installed\e[0m"
elif [ "$3" = "mysql" ]
then
# Update The APT Cache
UPDATEAPT
# Install MySQL
INSTALLMYSQL
# Initialize Git
EEGITDIR=/etc/mysql/
EEGITINIT
# Display Success Message
echo -e "\033[34mMySQL Successfully Installed\e[0m"
elif [ "$3" = "postfix" ]
then
# Update The APT Cache
UPDATEAPT
# Install Postfix
INSTALLPOSTFIX
# Initialize Git
EEGITDIR=/etc/postfix/
EEGITINIT
# Display Success Message
echo -e "\033[34mPostfix Successfully Installed\e[0m"
elif [ "$3" = "all" ] || [ "$3" = "" ]
then
# Install Python Software Properties
PYTHONSOFTWARE
# Add Nginx Launchpad Repository
NGINXREPO
# Add PHP Launchpad Repository
PHPREPO
# Fix GPG Key Problems
GPGKEY
# Update The APT Cache
UPDATEAPT
# Install Nginx PHP5 MySQL Postfix
INSTALLALL
# Personal Settings For Nginx
COMMONNGINX
# Reload Nginx To Take Effect Of COMMONNGINX Functions
NGINXRESTART
# Personal Settings For PHP
COMMONPHP
# Restart PHP To Take Effect Of COMMONPHP Functions
PHPRESTART
# Install WP-CLI
WP-CLI
# Install PMA/phpMyAdmin
INSTALLPMA
# Initialize Git
EEGITDIR=/etc/nginx/
EEGITINIT
# Initialize Git
EEGITDIR=/etc/php5/
EEGITINIT
# Initialize Git
EEGITDIR=/etc/mysql/
EEGITINIT
# Initialize Git
EEGITDIR=/var/www/shared/pma/
EEGITINIT
# Initialize Git
EEGITDIR=/etc/postfix/
EEGITINIT
# Display Success Message
echo -e "\033[34mNginx PHP5 WP-CLI MySQL Postfix phpMyAdmin Successfully Installed\e[0m"
echo -e "\033[34mYou Can Now Create Your First WordPress Site Powered By Nginx Using:\e[0m"
echo -e "\033[37mee site create wp basic $(hostname -f)\e[0m"
fi
# Easy Engine Remove
elif [ "$2" = "remove" ]
then
if [ "$3" = "nginx" ]
then
# Remove Nginx
REMOVENGINX
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mNginx Successfully Removed\e[0m"
elif [ "$3" = "php" ]
then
# Remove PHP5
REMOVEPHP
REMOVEWPCLI
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mPHP5 & WP-CLI Successfully Removed\e[0m"
elif [ "$3" = "pma" ]
then
# Remove PMA/phpMyAdmin
REMOVEPMA
# Display Success Message
echo -e "\033[34mphpMyAdmin Successfully Removed\e[0m"
elif [ "$3" = "mysql" ]
then
# Remove MySQL
REMOVEMYSQL
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mMySQL Successfully Removed\e[0m"
elif [ "$3" = "postfix" ]
then
# Remove Postfix
REMOVEPOSTFIX
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mPostfix Successfully Removed\e[0m"
elif [ "$3" = "all" ] || [ "$3" = "" ]
then
# Remove Nginx PHP5 MySQL Postfix
REMOVEALL
# Remove Unwanted Packages
AUTOREMOVE
REMOVEWPCLI
REMOVEPMA
# Display Success Message
echo -e "\033[34mNginx PHP5 WP-CLI MySQL Postfix phpMyAdmin Successfully Removed\e[0m"
fi
# Easy Engine Purge
elif [ "$2" = "purge" ]
then
if [ "$3" = "nginx" ]
then
# Purge Nginx
PURGENGINX
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mNginx Successfully Purged\e[0m"
elif [ "$3" = "php" ]
then
# Purge PHP5
PURGEPHP
REMOVEWPCLI
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mPHP5 & WP-CLI Successfully Purged\e[0m"
elif [ "$3" = "pma" ]
then
# Purge PMA/phpMyAdmin
REMOVEPMA
# Display Success Message
echo -e "\033[34mphpMyAdmin Successfully Purged\e[0m"
elif [ "$3" = "mysql" ]
then
# Purge MySQL
PURGEMYSQL
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mMySQL Successfully Purged\e[0m"
elif [ "$3" = "postfix" ]
then
# Purge Postfix
PURGEPOSTFIX
# Remove Unwanted Packages
AUTOREMOVE
# Display Success Message
echo -e "\033[34mPostfix Successfully Purged\e[0m"
elif [ "$3" = "all" ] || [ "$3" = "" ]
then
# Purge Nginx PHP5 MySQL Postfix
PURGEALL
# Remove Unwanted Packages
AUTOREMOVE
REMOVEWPCLI
REMOVEPMA
# Display Success Message
echo -e "\033[34mNginx PHP5 WP-CLI MySQL Postfix phpMyAdmin Successfully Purged\e[0m"
fi
# Easy Engine Info
elif [ "$2" = "info" ]
then
# Get Nginx PHP & MySQL Information
SYSTEMINFO
fi
# Easy Engine Site Settings
elif [ "$1" = "site" ]
then
# Easy Engine Site Enabled List
if [ "$2" = "list" ]
then
# Display The List Of Enabled Websites
echo -e "\033[34mDisplay The List Of Enabled Websites:\e[0m"
ls /etc/nginx/sites-enabled/ \
|| OwnError "Unable To Display The List Of Enabled Websites"
elif [ "$2" = "listall" ]
then
# Display The List Of Available Sites
echo -e "\033[34mDisplay The List Of Available Websites:\e[0m"
ls /etc/nginx/sites-available/ \
|| OwnError "Unable To Display The List Of Available Websites"
elif [ "$2" = "show" ]
then
# Check SITENAME Is Empty Or Not
SITENAMECHECK=$3
EESITENAME
# Check The Website Is Exist
ls /etc/nginx/sites-available/$DOMAIN &> /dev/null \
|| OwnError "The $DOMAIN Is Not Found In Available Websites List"
if [ $? -eq 0 ]
then
# Display The Specific Site Configuration
echo -e "\033[34mDisplay Nginx Configuration For $DOMAIN\e[0m"
cat /etc/nginx/sites-available/$DOMAIN \
|| OwnError "Unable To Display Nginx Configuration For $DOMAIN"
fi
elif [ "$2" = "create" ]
then
if [ "$3" = "html" ]
then
# Check SITENAME Is Empty Or Not
SITENAMECHECK=$4
EESITENAME
# Creating Website $DOMAIN
NGINXCONF=html/basic.conf
EEDOMAINSETUP
EEPERMISSION
# Take Nginx Configuration In Git Version Control
EEGITDIR=/etc/nginx
EEGITMESSAGE="Created New $3 Website: $DOMAIN"
EEGITCOMMIT
# Display Success Message
echo -e "\033[34mhttp://$DOMAIN Domain Successfully Created\e[0m"
elif [ "$3" = "php" ]
then
# Check SITENAME Is Empty Or Not
SITENAMECHECK=$4
EESITENAME
# Creating Website $DOMAIN
NGINXCONF=php/basic.conf
EEDOMAINSETUP
EEPERMISSION
# Take Nginx Configuration In Git Version Control
EEGITDIR=/etc/nginx
EEGITMESSAGE="Created New $3 Website: $DOMAIN"
EEGITCOMMIT
# Display Success Message
echo -e "\033[34mhttp://$DOMAIN Domain Successfully Created\e[0m"
elif [ "$3" = "wp" ]
then
if [ "$4" = "basic" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/basic.conf
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Basic Nginx
SETUPDOMAIN
NGINXHELPER
PERMISSIONANDGIT
# Display Success Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "w3tc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/w3tc.conf
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup W3 Total Cache Nginx
SETUPDOMAIN
NGINXHELPER
TOTALCACHENGINX
PERMISSIONANDGIT
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mW3 Total Cache: http://$DOMAIN/wp-admin/admin.php?page=w3tc_general\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "wpsc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/wpsc.conf
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup WP Super Cache Nginx
SETUPDOMAIN
NGINXHELPER
SUPERCACHENGINX
PERMISSIONANDGIT
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mWP Super Cache: http://$DOMAIN/wp-admin/options-general.php?page=wpsupercache\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "wpfc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/wpfc.conf
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Fastcgi Cache Nginx
SETUPDOMAIN
NGINXHELPER
TOTALCACHENGINX
PERMISSIONANDGIT
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mNginx Helper: http://$DOMAIN/wp-admin/options-general.php?page=nginx\e[0m"
echo -e "\033[34mW3 Total Cache: http://$DOMAIN/wp-admin/admin.php?page=w3tc_general\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
fi
elif [ "$3" = "wpsubdir" ]
then
if [ "$4" = "basic" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/basic.conf
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display Success Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "w3tc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/w3tc.conf
NETWORKACTIVATE="--network"
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
TOTALCACHENGINX
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mW3 Total Cache: http://$DOMAIN/wp-admin/network/admin.php?page=w3tc_general\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "wpsc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/wpsc.conf
NETWORKACTIVATE="--network"
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
SUPERCACHENGINX
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mWP Super Cache: http://$DOMAIN/wp-admin/network/settings.php?page=wpsupercache\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "wpfc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/wpfc.conf
NETWORKACTIVATE="--network"
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
TOTALCACHENGINX
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mNginx Helper: http://$DOMAIN/wp-admin/network/settings.php?page=nginx\e[0m"
echo -e "\033[34mW3 Total Cache: http://$DOMAIN/wp-admin/network/admin.php?page=w3tc_general\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
fi
elif [ "$3" = "wpsubdomain" ]
then
if [ "$4" = "basic" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/basic.conf
WPSUBDOMAINS="--subdomains"
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display Success Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "w3tc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/w3tc.conf
WPSUBDOMAINS="--subdomains"
NETWORKACTIVATE="--network"
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
TOTALCACHENGINX
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mW3 Total Cache: http://$DOMAIN/wp-admin/network/admin.php?page=w3tc_general\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "wpsc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/wpsc.conf
WPSUBDOMAINS="--subdomains"
NETWORKACTIVATE="--network"
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
SUPERCACHENGINX
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mWP Super Cache: http://$DOMAIN/wp-admin/network/settings.php?page=wpsupercache\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
elif [ "$4" = "wpfc" ]
then
# Configure Variable
WPNETWORKSITE=$3
WPCACHEOPTION=$4
SITENAMECHECK=$5
NGINXCONF=$3/wpfc.conf
WPSUBDOMAINS="--subdomains"
NETWORKACTIVATE="--network"
#echo -e " WPNETWORKSITE = $WPNETWORKSITE \n WPCACHEOPTION = $WPCACHEOPTION \n SITENAMECHECK = $SITENAMECHECK \n NGINXCONF = $NGINXCONF \n WPSUBDOMAINS = $WPSUBDOMAINS \n NETWORKACTIVATE = $NETWORKACTIVATE"
# Setup Domain WordPress & Database
SETUPDOMAIN
# Setup WordPress SubDirectory Network
SETUPWPNETWORK
TOTALCACHENGINX
PERMISSIONANDGIT
# Setup phpMyAdmin
ln -s /var/www/shared /var/www/$DOMAIN/htdocs/ee
# Display WordPress Plugin Configuration Message
echo
echo -e "\033[37mWordPress Admin Username: $WPADMINUSER\e[0m"
echo -e "\033[37mWordPress Admin Password: $WPADMINPASS\e[0m"
echo
echo -e "\033[34mPlease Configure The Following Settings...\e[0m"
echo -e "\033[34mPermalink Settings: http://$DOMAIN/wp-admin/options-permalink.php\e[0m"
echo -e "\033[34mNginx Helper: http://$DOMAIN/wp-admin/network/settings.php?page=nginx\e[0m"
echo -e "\033[34mW3 Total Cache: http://$DOMAIN/wp-admin/network/admin.php?page=w3tc_general\e[0m"
# Display Success Message
echo
echo -e "\033[37mSuccessfully Created New $3 $4 Website: http://$DOMAIN\e[0m"
fi
fi
elif [ "$2" = "enable" ]
then
# Check SITENAME Is Empty Or Not
SITENAMECHECK=$3
EESITENAME
# Creating Symbolic Link
NGINXSYMBOLICLINK
# Reload Nginx Configuration
NGINXRELOAD
# Take Nginx Configuration In Git Version Control
EEGITDIR=/etc/nginx
EEGITMESSAGE="Enable Website: $DOMAIN"
EEGITCOMMIT
elif [ "$2" = "disable" ]
then
# Check SITENAME Is Empty Or Not
SITENAMECHECK=$3
EESITENAME
# Remove Symbolic Link
echo -e "\033[34mRemoving Symbolic Link For $DOMAIN\e[0m"
rm /etc/nginx/sites-enabled/$DOMAIN \
|| OwnError "Unable To Remove Symbolic Link For $DOMAIN"
# Reload Nginx Configuration
NGINXRELOAD
# Take Nginx Configuration In Git Version Control
EEGITDIR=/etc/nginx
EEGITMESSAGE="Disable Website: $DOMAIN"
EEGITCOMMIT
elif [ "$2" = "delete" ]
then
# Check SITENAME Is Empty Or Not
SITENAMECHECK=$4
EESITENAME
if [ "$3" = "db" ]
then
# Remove Database
REMOVEDB
elif [ "$3" = "files" ]
then
# Remove Webroot
REMOVEFILES
elif [ "$3" = "all" ]
then
# Remove All Database And Webroot
REMOVEDB
REMOVEFILES
# Remove Nginx Configuration
REMOVENGINXCONF
# Reload Nginx
NGINXRELOAD
# Take Nginx Configuration In Git Version Control
EEGITDIR=/etc/nginx
EEGITMESSAGE="Delete Website with $3 Option: $DOMAIN"
EEGITCOMMIT
fi
fi
fi
}
EasyEngine $@ | tee -ai $INSTALLLOG