Browse Source

Optimized Update script and WP-CLI setup

bugfixes
gau1991 11 years ago
parent
commit
dea32668b8
  1. 76
      bin/update
  2. 22
      src/vendor/ee_ven_install_wpcli.sh

76
bin/update

@ -363,8 +363,8 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then
fi fi
# Update NGINX # Update NGINX
if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then if [ "$EE_LINUX_DISTRO" == "Ubuntu" ]; then
nginx -v 2>&1 | grep 1.6.0 &>> $EE_UPDATE_LOG ls /etc/apt/sources.list.d/brianmercer-nginx* &>> $EE_UPDATE_LOG
if [ $? -ne 0 ]; then if [ $? -eq 0 ]; then
rm /etc/apt/sources.list.d/brianmercer-nginx* rm /etc/apt/sources.list.d/brianmercer-nginx*
# Add rtCamp nginx launchpad repository # Add rtCamp nginx launchpad repository
ee_lib_echo "Adding rtCamp NGINX launchpad repository, please wait..." ee_lib_echo "Adding rtCamp NGINX launchpad repository, please wait..."
@ -395,57 +395,45 @@ if [[ $EE_CURRENT_VERSION < $EE_LATEST_VERSION ]]; then
done done
fi fi
if [[ $EE_CURRENT_VERSION = 2.0.0 ]]; then if [[ $EE_CURRENT_VERSION = 2.0.0 ]] || [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then
dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_UPDATE_LOG sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf
if [ $? -eq 0 ]; then
# WP-CLI change the installation method
rm -rf /usr/share/easyengine/wp-cli /usr/share/wp-cli /usr/bin/wp /etc/bash_completion.d/wp-completion.bash
# Install WP-CLI # Add Vimbadmin rules
ee_ven_install_wpcli 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 fi
# Update EasyEngine current version
EE_CURRENT_VERSION="2.0.1"
fi
if [[ $EE_CURRENT_VERSION = 2.0.1 ]]; then if [ -d /var/www/22222/htdocs/db/anemometer ];then
sed -i 's/host =.*/grant-host = localhost/' /etc/easyengine/ee.conf # Download pt-query-advisor Fixed #189
fi 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 \
fi || ee_lib_error "Unable to copy download pt-query-advisor, exit status = " $?
chmod 0755 /usr/bin/pt-query-advisor
if [[ $EE_CURRENT_VERSION < 2.1.0 ]];then # Enable pt-query-advisor plugin in Anemometer
if [ -f /etc/nginx/sites-available/22222 ];then sed -i "s/# 'query_advisor'/ 'query_advisor'/" /var/www/22222/htdocs/db/anemometer/conf/config.inc.php \
ee_port=$(grep listen /etc/nginx/sites-available/22222 | awk '{ print $2 }') || ee_lib_error "Unable to to activate pt-query-advisor plugin, exit status = " $?
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
fi
if [ -d /var/www/22222/htdocs/db/anemometer ];then # Update EasyEngine current version
# Download pt-query-advisor Fixed #189 EE_CURRENT_VERSION="2.1.0"
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 fi
# Update EasyEngine current version # if [[ $EE_CURRENT_VERSION = 2.1.0 ]]; then
EE_CURRENT_VERSION="2.1.0" # fi
fi
if [[ $EE_CURRENT_VERSION < 2.1.1 ]]; then
# Install WP-CLI
ee_ven_install_wpcli
fi fi
# Update WP-CLI
ee_ven_install_wpcli
# Restart service # Restart service
ee_lib_service nginx php5-fpm restart ee_lib_service nginx php5-fpm restart

22
src/vendor/ee_ven_install_wpcli.sh

@ -2,16 +2,20 @@
function ee_ven_install_wpcli() function ee_ven_install_wpcli()
{ {
if [ ! -f /usr/bin/wp ]; then dpkg --get-selections | grep -v deinstall | grep php5-fpm &>> $EE_COMMAND_LOG
ee_lib_echo "Downloading WP-CLI, please wait..." if [ $? -eq 0 ]; then
wget -qO /usr/bin/wp https://github.com/wp-cli/wp-cli/releases/download/v${EE_WP_CLI_VERSION}/wp-cli.phar \ ee_wp_cli_current=$(wp --allow-root --info 2> /dev/null | grep 'WP-CLI' | grep version | awk '{print $3}')
|| ee_lib_error "Unable to download WP-CLI, exit status = " $? if [[ $ee_wp_cli_current < $EE_WP_CLI_VERSION ]]; then
ee_lib_echo "Downloading WP-CLI, please wait..."
wget -qO /usr/bin/wp https://github.com/wp-cli/wp-cli/releases/download/v${EE_WP_CLI_VERSION}/wp-cli.phar \
|| ee_lib_error "Unable to download WP-CLI, exit status = " $?
# Executable permission # Executable permission
chmod a+x /usr/bin/wp \ chmod a+x /usr/bin/wp \
|| ee_lib_error "Unable to set executable permission for wp-cli, exit status = " $? || ee_lib_error "Unable to set executable permission for wp-cli, exit status = " $?
# Download auto completion # Download auto completion
wget -qO /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/v${EE_WP_CLI_VERSION}/utils/wp-completion.bash wget -qO /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/v${EE_WP_CLI_VERSION}/utils/wp-completion.bash
fi
fi fi
} }

Loading…
Cancel
Save