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.
 
 
 

530 lines
22 KiB

#!/bin/bash
# Define variables
readonly EE_UPDATE_LOG=/var/log/easyengine/update.log
# Define echo function
# Blue color
function ee_lib_echo()
{
echo $(tput setaf 4)$@$(tput sgr0)
}
# White color
function ee_lib_echo_info()
{
echo $(tput setaf 7)$@$(tput sgr0)
}
# Red color
function ee_lib_echo_fail()
{
echo $(tput setaf 1)$@$(tput sgr0)
}
# Capture errors
function ee_lib_error()
{
echo "[ `date` ] $(tput setaf 1)$@$(tput sgr0)" | tee -ai $EE_ERROR_LOG
exit $2
}
# Initialize Git
function ee_lib_git()
{
for ee_git_dir in ${@:1:$(($#-1))}; do
if [ -d $ee_git_dir ]; then
# Change directory
cd $ee_git_dir
# Check .git
if [ ! -d .git ]; then
# ee_lib_echo "Initialize Git on ${ee_git_dir}"
git init &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to initialize Git on $ee_git_dir, exit status = " $?
fi
# Check for untracked files
if [ $(git status -s | wc -l) -ne 0 ]; then
# Add files in Git version control
ee_lib_echo "Git commit on $ee_git_dir, please wait..."
git add --all && git commit -am "${@: -1}" &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to Git commit on $ee_git_dir, exit status = " $?
fi
fi
done
}
# Update EasyEngine (ee)
# EasyEngine version: 1.0.0
# EasyEngine (ee) version: 2.0.0
EE_CURRENT_VERSION=$(ee version | sed 's/(ee) //' | awk '{print $3}')
EE_LATEST_VERSION=$(curl -sL https://api.github.com/repos/rtCamp/easyengine/releases | grep tag_name | awk '{print($2)}' | cut -d'"' -f2 | cut -c2- | head -n1)
echo EE_CURRENT_VERSION = $EE_CURRENT_VERSION EE_LATEST_VERSION = $EE_LATEST_VERSION &>> $EE_UPDATE_LOG
if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then
read -p "Update EasyEngine to $EE_LATEST_VERSION (y/n): " EE_ANS
if [ "$EE_ANS" = "y" ] || [ "$EE_ANS" = "Y" ]; then
ee_lib_echo "EasyEngine (ee) update started [$(date)]" | tee -ai $EE_UPDATE_LOG
# Install required packages
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
ee_lib_package_check graphviz python-software-properties software-properties-common
elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then
ee_lib_package_check graphviz python-software-properties
fi
if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ -n "$EE_PACKAGE_NAME" ]; then
ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_INSTALL_LOG
apt-get -y install coreutils ed bc wget curl tar git-core $EE_PACKAGE_NAME | tee -ai $EE_INSTALL_LOG\
|| ee_lib_error "Unable to install required packages, exit status = " $?
fi
# Get Anemometer password
if [ -d /var/www/22222/htdocs/db/anemometer ]; then
if [ -f /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh ]; then
ee_anemometer_pass=$(grep "\-\-password" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh | cut -d"=" -f3 )
else
ee_anemometer_pass=$(grep "password=" /etc/logrotate.d/mysql-server | cut -d"=" -f3 )
fi
ee_anemometer_pass=$(echo $ee_anemometer_pass | rev | cut -c 3- | rev)
fi
# Git backup
ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix "EasyEngine version $EE_CURRENT_VERSION"
# Remove old version of EasyEngine (ee)
rm -rf /tmp/easyengine &>> /dev/null
# Let's clone EasyEngine (ee)
ee_lib_echo "Cloning EasyEngine (ee) stable branch, please wait..." | tee -ai $EE_UPDATE_LOG
git clone -b stable https://github.com/rtCamp/easyengine.git /tmp/easyengine &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to clone EasyEngine (ee) stable branch, exit status = " $?
# Setup EasyEngine (ee)
if [ ! -d /etc/easyengine ]; then
mkdir -p /etc/easyengine \
|| ee_lib_error "Unable to create /etc/easyengine directory, exit status = " $?
fi
if [ ! -d /usr/share/easyengine/ ]
then
mkdir -p /usr/share/easyengine/ \
|| ee_lib_error "Unable to create /usr/share/easyengine/ directory, exit status = " $?
fi
if [ ! -d /usr/local/lib/easyengine ]
then
mkdir -p /usr/local/lib/easyengine \
|| ee_lib_error "Unable to create /usr/local/lib/easyengine directory, exit status = " $?
fi
# Setup EasyEngine (ee)
# EasyEngine (ee) auto completion file
cp -av /tmp/easyengine/config/bash_completion.d/ee /etc/bash_completion.d/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy EasyEngine (ee) auto completion file, exit status = " $?
# Templates
cp -a /tmp/easyengine/config/nginx /tmp/easyengine/templates/* /usr/share/easyengine/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy NGINX sample files, exit status = " $?
# NGINX Setup
sed -i "s/X-Powered-By.*/X-Powered-By \"EasyEngine $EE_LATEST_VERSION\";/" /etc/nginx/nginx.conf
rsync -avz --exclude acl.conf /usr/share/easyengine/nginx/common/* /etc/nginx/common/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to rsync NGINX common files, exit status = " $?
# EasyEngine (ee) library and modules
cp -av /tmp/easyengine/src/* /usr/local/lib/easyengine &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy src files, exit status = " $?
# EasyEngine (ee) command
cp -av /tmp/easyengine/bin/easyengine /usr/local/sbin/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy EasyEngine (ee) command, exit status = " $?
# Change permission of EasyEngine (ee) command
chmod 750 /usr/local/sbin/easyengine || ee_lib_error "Unable to change permission of EasyEngine (ee) command, exit status = " $?
# Create symbolic link
if [ ! -L /usr/local/sbin/ee ]; then
ln -s /usr/local/sbin/easyengine /usr/local/sbin/ee
fi
# EasyEngine (ee) man page
cp -av /tmp/easyengine/docs/man/ee.8 /usr/share/man/man8/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy EasyEngine (ee) man page, exit status = " $?
if [[ $EE_CURRENT_VERSION < 1.9.0 ]]; then
# EasyEngine (ee) config file
cp -av /etc/easyengine/ee.conf /etc/easyengine/ee.bak &>> $EE_UPDATE_LOG
cp -av /tmp/easyengine/config/easyengine/ee.conf /etc/easyengine/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy EasyEngine (ee) config file, exit status = " $?
# Lets re-used our functions
# Include library
for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do
source $ee_include
done
# Avoid re-source and readonly errors
ee_source=1
# Lets modify the $EE_COMMAND_LOG value
# So all the logs write in $EE_UPDATE_LOG
EE_COMMAND_LOG=$EE_UPDATE_LOG
# Install required packages
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
ee_lib_package_check graphviz python-software-properties software-properties-common
elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then
ee_lib_package_check graphviz python-software-properties
fi
if [ ! -x /usr/bin/tee ] || [ ! -x /bin/ed ] || [ ! -x /usr/bin/bc ] || [ ! -x /usr/bin/wget ] || [ ! -x /usr/bin/curl ] || [ ! -x /bin/tar ] || [ ! -x /usr/bin/git ] || [ -n "$EE_PACKAGE_NAME" ]; then
ee_lib_echo "Installing required packages, please wait..." | tee -ai $EE_UPDATE_LOG
apt-get -y install coreutils ed bc wget curl tar git-core $EE_PACKAGE_NAME | tee -ai $EE_UPDATE_LOG\
|| ee_lib_error "Unable to install required packages, exit status = " $?
fi
# Get old value from ee.bak file
ee_stack_ip=$(grep ip_address /etc/easyengine/ee.bak | cut -d'=' -f2)
ee_mysql_host=$(grep mysqlhost /etc/easyengine/ee.bak | cut -d'=' -f2)
ee_wp_user=$(grep wpadminuser /etc/easyengine/ee.bak | cut -d'=' -f2)
ee_wp_pass=$(grep wpadminpass /etc/easyengine/ee.bak | cut -d'=' -f2)
#ee_wp_email=$(grep wpadminemail /etc/easyengine/ee.bak | cut -d'=' -f2)
# Set localhost when no host found
if [ -z $ee_mysql_host ]; then
ee_mysql_host=localhost
fi
# Ask email address
ee_lib_echo "Update your email address, which is used to setup WordPress"
read -p "Enter email address: " ee_wp_email
# Update value in ee.conf file
$EE_CONFIG_SET stack.ip-address "$(echo -n $ee_stack_ip)" && \
$EE_CONFIG_SET mysql.host "$(echo -n $ee_mysql_host)" && \
$EE_CONFIG_SET wordpress.user "$(echo -n $ee_wp_user)" && \
$EE_CONFIG_SET wordpress.password "$(echo -n $ee_wp_pass)" && \
$EE_CONFIG_SET wordpress.email "$(echo -n $ee_wp_email)" \
|| ee_lib_error "Unable to update ee.conf file, exit status = " $?
# NGINX conf.d
cp -v /usr/share/easyengine/nginx/conf.d/fastcgi.conf /etc/nginx/conf.d/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy fastcgi.conf file, exit status = " $?
cp -v /usr/share/easyengine/nginx/conf.d/upstream.conf /etc/nginx/conf.d/ &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to copy upstream.conf file, exit status = " $?
# NGINX common
if [[ $EE_CURRENT_VERSION = 1.0.0 ]] || [[ $EE_CURRENT_VERSION = 1.0.1 ]] || [[ $EE_CURRENT_VERSION = 1.1.0 ]]; then
# Move allowed_ip.conf to acl.conf
(sed "/allow/,+2d" /usr/share/easyengine/nginx/common/acl.conf; grep -v ^# /etc/nginx/common/allowed_ip.conf ) > /etc/nginx/common/acl.conf
sed -i '/allow ;/d' /etc/nginx/common/acl.conf
# Update nginx.conf
# SSL settings
grep ssl_ /etc/nginx/nginx.conf &>> $EE_UPDATE_LOG
if [ $? -ne 0 ]; then
sed -i "/client_max_body_size/a \ \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
fi
# Log format
sed -i "s/log_format rt_cache.*/log_format rt_cache '\$remote_addr \$upstream_response_time \$upstream_cache_status [\$time_local] '/" /etc/nginx/nginx.conf
sed -i "s/.*\$body_bytes_sent'/\t\t'\$http_host \"\$request\" \$status \$body_bytes_sent '/" /etc/nginx/nginx.conf
# Update PHP session storage to Memcache
sed -i "/extension/a \session.save_handler = memcache\nsession.save_path = \"tcp://localhost:11211\"" /etc/php5/mods-available/memcache.ini
# Set easyengine:easyengine as default http authentication
if [ ! -f /etc/nginx/htpasswd-ee ]; then
printf "easyengine:$(openssl passwd -crypt easyengine 2> /dev/null)\n" > /etc/nginx/htpasswd-ee 2> /dev/null
fi
# Update EasyEngine current version
EE_CURRENT_VERSION="1.2.2"
fi
if [[ $EE_CURRENT_VERSION = 1.2.2 ]]; then
# Update NGINX configuration
sed -i "/worker_processes/a \worker_rlimit_nofile 100000;" /etc/nginx/nginx.conf
sed -i "s/# multi_accept/multi_accept/" /etc/nginx/nginx.conf
sed -i "s/keepalive_timeout.*/keepalive_timeout 30;/" /etc/nginx/nginx.conf
# Setup port 22222
cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG
if [ "$EE_LINUX_DISTRO" == "Debian" ]; then
# Dotdeb nginx repository doesn't support spdy
sed -i "s/ spdy//;" /usr/share/easyengine/nginx/22222
fi
# Create a symbolic link for 22222
if [ ! -L /etc/nginx/sites-enabled/22222 ]; then
ln -s /etc/nginx/sites-available/22222 /etc/nginx/sites-enabled/
fi
# Setup logs for 22222
if [ ! -d /var/www/22222/logs ]; then
mkdir -p /var/www/22222/logs
ln -s /var/log/nginx/22222.access.log /var/www/22222/logs/access.log
ln -s /var/log/nginx/22222.error.log /var/www/22222/logs/error.log
fi
# Setup SSL
# Create SSL certificate directory
if [ ! -d /var/www/22222/cert ]; then
mkdir /var/www/22222/cert
fi
# Generate SSL key
ee_lib_echo "Generating SSL private key"
openssl genrsa -out /var/www/22222/cert/22222.key 2048 &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to generate SSL private key for port 22222, exit status = " $?
ee_lib_echo "Generating a certificate signing request (CSR)"
openssl req -new -batch -subj /commonName=127.0.0.1/ -key /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.csr &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to generate certificate signing request (CSR) for port 22222, exit status = " $?
ee_lib_echo "Removing pass phrase from SSL private key"
mv /var/www/22222/cert/22222.key /var/www/22222/cert/22222.key.org
openssl rsa -in /var/www/22222/cert/22222.key.org -out /var/www/22222/cert/22222.key &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to remove pass phrase from SSL for port 22222, exit status = " $?
ee_lib_echo "Generating SSL certificate"
openssl x509 -req -days 3652 -in /var/www/22222/cert/22222.csr -signkey /var/www/22222/cert/22222.key -out /var/www/22222/cert/22222.crt &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to generate SSL certificate for port 22222, exit status = " $?
# Update PHP configuration
dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG
if [ $? -eq 0 ]; then
ee_lib_echo "Installing php5-xdebug package, please wait..."
apt-get -y install php5-xdebug \
|| ee_lib_error "Unable to install php5-xdebug package, exit status = " $?
ee_lib_echo "Setting up PHP5, please wait..."
# Custom php5 log directory
if [ ! -d /var/log/php5/ ]; then
mkdir -p /var/log/php5/ \
|| ee_lib_error "Unable to create /var/log/PHP5/, exit status = " $?
fi
# Update timezone
local ee_time_zone=$(cat /etc/timezone | head -n1 | sed "s'/'\\\/'")
sed -i "s/;date.timezone.*/date.timezone = $ee_time_zone/" /etc/php5/fpm/php.ini
# Change php5-fpm error log location
sed -i "s'error_log.*'error_log = /var/log/php5/fpm.log'" /etc/php5/fpm/php-fpm.conf
# Separate php5-fpm for ee debug command
cp -v /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/debug.conf
sed -i "s'\[www\]'[debug]'" /etc/php5/fpm/pool.d/debug.conf \
|| ee_lib_error "Unable to change debug pool name, exit status = " $?
sed -i "s'listen = 127.0.0.1:9000'listen = 127.0.0.1:9001'" /etc/php5/fpm/pool.d/debug.conf \
|| ee_lib_error "Unable to change listen = 127.0.0.1:9001 for debug pool, exit status = " $?
sed -i "s';slowlog.*'slowlog = /var/log/php5/slow.log'" /etc/php5/fpm/pool.d/debug.conf \
|| ee_lib_error "Unable to change slowlog settings for debug pool, exit status = " $?
sed -i "s';request_slowlog_timeout.*'request_slowlog_timeout = 10s'" /etc/php5/fpm/pool.d/debug.conf \
|| ee_lib_error "Unable to change request_slowlog_timeout for debug pool, exit status = " $?
echo -e "php_admin_value[xdebug.profiler_output_dir] = /tmp/ \nphp_admin_value[xdebug.profiler_output_name] = cachegrind.out.%p-%H-%R \nphp_admin_flag[xdebug.profiler_enable_trigger] = on \nphp_admin_flag[xdebug.profiler_enable] = off" | tee -ai /etc/php5/fpm/pool.d/debug.conf &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to add xdebug settings for debug pool, exit status = " $?
fi
mysqladmin ping &> /dev/null &>> $EE_UPDATE_LOG
if [ $? -eq 0 ]; then
ee_lib_echo "Installing percona-toolkit package, please wait..."
apt-get -y install percona-toolkit \
|| ee_lib_error "Unable to install percona-toolkit package, exit status = " $?
fi
# Install 22222 admin tools
ee_ven_install_utils
ee_ven_install_phpmyadmin
# Update EasyEngine current version
EE_CURRENT_VERSION="1.3.0"
fi
if [[ $EE_CURRENT_VERSION = 1.3.0 ]] || [[ $EE_CURRENT_VERSION = 1.3.1 ]] || [[ $EE_CURRENT_VERSION = 1.3.2 ]] || [[ $EE_CURRENT_VERSION = 1.3.3 ]]; then
grep "^pm = ondemand" /etc/php5/fpm/pool.d/www.conf &>> $EE_UPDATE_LOG
if [ $? -ne 0 ]; then
sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/www.conf \
|| ee_lib_error "Unable to change process manager from dynamic to ondemand, exit status = " $?
fi
grep "^pm = ondemand" /etc/php5/fpm/pool.d/debug.conf &>> $EE_UPDATE_LOG
if [ $? -ne 0 ]; then
sed -i "s/pm = dynamic/pm = ondemand/" /etc/php5/fpm/pool.d/debug.conf \
|| ee_lib_error "Unable to change process manager from dynamic to ondemand on debug.conf, exit status = " $?
fi
# Update EasyEngine current version
EE_CURRENT_VERSION="1.3.4"
fi
if [[ $EE_CURRENT_VERSION = 1.3.4 ]] || [[ $EE_CURRENT_VERSION = 1.3.5 ]] || [[ $EE_CURRENT_VERSION = 1.3.6 ]] || [[ $EE_CURRENT_VERSION = 1.3.7 ]] || [[ $EE_CURRENT_VERSION = 1.3.8 ]]; then
# Update 22222 for fix #259
cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG
if [ "$EE_LINUX_DISTRO" == "Debian" ]; then
# Dotdeb nginx repository doesn't support spdy
sed -i "s/ spdy//;" /usr/share/easyengine/nginx/22222
fi
# Update NGINX
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
ls /etc/apt/sources.list.d/brianmercer-nginx* &>> $EE_UPDATE_LOG
if [ $? -eq 0 ]; then
rm /etc/apt/sources.list.d/brianmercer-nginx*
# Add rtCamp nginx launchpad repository
ee_lib_echo "Adding rtCamp NGINX launchpad repository, please wait..."
add-apt-repository -y ppa:rtcamp/nginx &>> $EE_UPDATE_LOG \
|| ee_lib_error "Unable to add rtCamp NGINX launchpad repository, exit status = " $?
# Execute: apt-get update
ee_lib_apt_get_update
# Install NGINX
apt-get -o Dpkg::Options::="--force-confold" -y install nginx-custom \
|| ee_lib_error "Unable to install nginx-custom package, exit status = " $?
fi
fi
# Update EasyEngine current version
EE_CURRENT_VERSION="2.0.0"
fi
fi
if [[ $EE_CURRENT_VERSION > 1.9.0 ]]; then
# Lets re-used our functions
# Include library
if [ -z $ee_source ]; then
for ee_include in $(find /usr/local/lib/easyengine/ -iname "*.sh"); do
source $ee_include
done
fi
if [[ $EE_CURRENT_VERSION = 2.0.0 ]] || [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then
sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf
# Add Vimbadmin rules
if [ -f /etc/nginx/sites-available/22222 ];then
ee_port=$(grep listen /etc/nginx/sites-available/22222 | awk '{ print $2 }')
cp -av /usr/share/easyengine/nginx/22222 /etc/nginx/sites-available/ &>> $EE_UPDATE_LOG
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
sed -i "s/listen.*/listen $ee_port default_server ssl spdy;/" /etc/nginx/sites-available/22222 \
|| ee_lib_error "Unable to change EasyEngine admin port, exit status = " $?
elif [ "$EE_LINUX_DISTRO" == "Debian" ]; then
# Dotdeb nginx repository doesn't support spdy
sed -i "s/listen.*/listen $ee_port default_server ssl;/" /etc/nginx/sites-available/22222 \
|| ee_lib_error "Unable to change EasyEngine admin port, exit status = " $?
fi
fi
if [ -d /var/www/22222/htdocs/db/anemometer ];then
# Download pt-query-advisor Fixed #189
wget -q http://bazaar.launchpad.net/~percona-toolkit-dev/percona-toolkit/2.1/download/head:/ptquerydigest-20110624220137-or26tn4expb9ul2a-16/pt-query-digest -O /usr/bin/pt-query-advisor \
|| ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $?
chmod 0755 /usr/bin/pt-query-advisor
# Enable pt-query-advisor plugin in Anemometer
sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \
|| ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $?
fi
# Update EasyEngine current version
EE_CURRENT_VERSION="2.1.0"
fi
if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then
# Change permission of EasyEngine log folder
chmod -R 700 /var/log/easyengine \
|| ee_lib_error "Unable to change permissions for EasyEngine log folder, exit status = " $?
# RAM based optimization settings
ee_lib_ram
if [ -f /etc/php5/fpm/pool.d/www.conf ]; then
sed -i "s/pm.max_children = .*/pm.max_children = ${EE_PHP_MAX_CHILDREN}/" /etc/php5/fpm/pool.d/www.conf
fi
# Setup Zend OpCache as per RAM
if [ -f /etc/php5/fpm/conf.d/05-opcache.ini ]; then
grep memory_consumption /etc/php5/fpm/conf.d/05-opcache.ini &> /dev/null
if [ $? -ne 0 ]; then
sed -i "s/zend_extension=opcache.so/zend_extension=opcache.so\nopcache.memory_consumption=${EE_OPCACHE_SIZE}\nopcache.max_accelerated_files=50000/" /etc/php5/fpm/conf.d/05-opcache.ini \
|| ee_lib_error "Unable to change opcache.memory_consumption, exit status = " $?
fi
fi
# Setup PHP Memcache as per RAM
if [ -f /etc/memcached.conf ]; then
sed -i "s/-m.*/-m ${EE_MEMCACHE_SIZE}/" /etc/memcached.conf \
|| ee_lib_error "Unable to change Memcache memory value, exit status = " $?
fi
# Add PHP GeoIP module
dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG
if [ $? -eq 0 ]; then
$EE_APT_GET install php5-geoip
ee_lib_echo "Downloading GeoIP Database, please wait..."
mkdir -p /usr/share/GeoIP
wget -qO /usr/share/GeoIP/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip /usr/share/GeoIP/GeoLiteCity.dat.gz
mv /usr/share/GeoIP/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
fi
# Fix PhpMyAdmin config issue
if [ -d /var/www/22222/htdocs/db/pma ]; then
ee_random=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 7 | head -n1)
if [ ! -f /var/www/22222/htdocs/db/pma/config.inc.php ]; then
cp -v /var/www/22222/htdocs/db/pma/config.sample.inc.php /var/www/22222/htdocs/db/pma/config.inc.php &>> $EE_COMMAND_LOG \
|| ee_lib_error "Unable to setup phpMyAdmin, exit status = " $?
fi
sed -i "s/a8b7c6d/$ee_random/" /var/www/22222/htdocs/db/pma/config.inc.php \
|| ee_lib_error "Unable to setup phpMyAdmin, exit status = " $?
fi
# Update EasyEngine current version
EE_CURRENT_VERSION="2.2.0"
fi
# if [[ $EE_CURRENT_VERSION = 2.2.0 ]]; then
# fi
fi
# Update WP-CLI
ee_ven_install_wpcli
# Set Anemometer password
if [ -d /var/www/22222/htdocs/db/anemometer ]; then
# Change Anemometer Hostname in ee_lib_import_slow_log
sed -i "s:hostname.*:hostname}=\\\\\"$EE_MYSQL_HOST\\\\\"\" /var/log/mysql/mysql-slow.log:" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \
|| ee_lib_error "Unable to change Anemometer hostnameme, exit status = " $?
# Change Anemometer password in ee_lib_import_slow_log
sed -i "s/--password.*/--password=${ee_anemometer_pass} \\\/" /usr/local/lib/easyengine/lib/ee_lib_import_slow_log.sh \
|| ee_lib_error "Unable to change Anemometer password, exit status = " $?
fi
# Restart service
ee_lib_service nginx php5-fpm restart
# Git backup
ee_lib_git /etc/nginx/ /etc/php5/ /etc/mysql/ /etc/postfix /etc/easyengine "EasyEngine version $EE_LATEST_VERSION"
# Enable EasyEngine (ee) auto completion
echo
ee_lib_echo "For EasyEngine (ee) auto completion, run the following command" | tee -ai $EE_UPDATE_LOG
ee_lib_echo_info "source /etc/bash_completion.d/ee" | tee -ai $EE_UPDATE_LOG
echo
ee_lib_echo "EasyEngine (ee) updated successfully"
fi
else
ee_lib_echo "Latest version ($EE_CURRENT_VERSION) already installed"
fi