Refactor nginx upgrade process
This commit is contained in:
@@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
- Cleanup templates by removing all doublons (with/without php7) and replacing them with variables
|
- Cleanup templates by removing all doublons (with/without php7) and replacing them with variables
|
||||||
- Updated Nginx to v1.16.1 in response to HTTP/2 vulnerabilites discovered
|
- Updated Nginx to v1.16.1 in response to HTTP/2 vulnerabilites discovered
|
||||||
- Disable temporary adding swap feature (not working)
|
- Disable temporary adding swap feature (not working)
|
||||||
|
- `wo stack upgrade --nginx` is now able to apply new configurations during `wo update`, it highly reduce upgrade duration
|
||||||
|
|
||||||
#### Fixed
|
#### Fixed
|
||||||
|
|
||||||
|
|||||||
65
install
65
install
@@ -465,58 +465,41 @@ wo_upgrade_nginx() {
|
|||||||
fi
|
fi
|
||||||
# chec if the package nginx-ee is installed
|
# chec if the package nginx-ee is installed
|
||||||
CHECK_NGINX_EE=$(dpkg --list | grep nginx-ee)
|
CHECK_NGINX_EE=$(dpkg --list | grep nginx-ee)
|
||||||
CHECK_NGINX_WO=$(dpkg --list | grep nginx-wo)
|
|
||||||
CHECK_PHP72=$(command -v php-fpm7.2)
|
CHECK_PHP72=$(command -v php-fpm7.2)
|
||||||
|
|
||||||
# add new Nginx repository
|
# add new Nginx repository
|
||||||
if [ "$wo_linux_distro" = "Ubuntu" ]; then
|
if [ "$wo_distro_version" == "jessie" ]; then
|
||||||
if [ ! -f /etc/apt/sources.list.d/wordops-ubuntu-nginx-wo-"$(lsb_release -sc)".list ]; then
|
# import the respository key for updates
|
||||||
add-apt-repository ppa:wordops/nginx-wo -y -u
|
curl -sL https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_8.0/Release.key | apt-key add -
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [ "$wo_distro_version" == "jessie" ]; then
|
curl -sL https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_9.0/Release.key | apt-key add -
|
||||||
# import the respository key for updates
|
|
||||||
curl -sL https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_8.0/Release.key | apt-key add -
|
|
||||||
else
|
|
||||||
curl -sL https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_9.0/Release.key | apt-key add -
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# stop nginx
|
|
||||||
service nginx stop
|
|
||||||
|
|
||||||
# install new nginx package
|
# install new nginx package
|
||||||
if [ -n "$CHECK_NGINX_EE" ] || [ -n "$CHECK_NGINX_WO" ]; then
|
if [ -n "$CHECK_NGINX_EE" ]; then
|
||||||
if [ -x /usr/local/bin/wo ]; then
|
if [ -x /usr/local/bin/wo ]; then
|
||||||
if [ -n "$CHECK_NGINX_EE" ]; then
|
# stop nginx
|
||||||
# remove previous package
|
service nginx stop
|
||||||
apt-mark unhold nginx-ee nginx-common nginx-custom
|
# remove previous package
|
||||||
apt-get --assume-yes purge nginx-ee nginx-common nginx-custom --allow-change-held-packages
|
apt-mark unhold nginx-ee nginx-common nginx-custom
|
||||||
# remove previous php-fpm pool configuration
|
apt-get --assume-yes purge nginx-ee nginx-common nginx-custom --allow-change-held-packages
|
||||||
if [ -n "$CHECK_PHP72" ]; then
|
# remove previous php-fpm pool configuration
|
||||||
apt-get purge php7.2-fpm -y -qq
|
if [ -n "$CHECK_PHP72" ]; then
|
||||||
rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
|
apt-get purge php7.2-fpm -y -qq
|
||||||
fi
|
rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
|
||||||
elif [ -n "$CHECK_NGINX_WO" ]; then
|
|
||||||
apt-mark unhold nginx-wo nginx-common nginx-custom
|
|
||||||
apt-get --assume-yes purge nginx-wo nginx-common nginx-custom --allow-change-held-packages
|
|
||||||
if [ -n "$CHECK_PHP72" ]; then
|
|
||||||
apt-get purge php7.2-fpm -y -qq
|
|
||||||
rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
if [ -d /etc/nginx ]; then
|
if [ -d /etc/nginx ]; then
|
||||||
rm -rf /etc/nginx
|
rm -rf /etc/nginx
|
||||||
fi
|
fi
|
||||||
|
|
||||||
/usr/local/bin/wo stack install --nginx --php
|
/usr/local/bin/wo stack install --nginx --php
|
||||||
rm -f /etc/nginx/common/acl.conf /etc/nginx/conf.d/{map-wp-cache.conf,map-wp.conf,fascgi.conf,blockips.conf} /etc/nginx/htpasswd-wo
|
rm -f /etc/nginx/common/acl.conf /etc/nginx/htpasswd-wo
|
||||||
fi
|
/usr/bin/rsync -au --noatime /var/lib/wo-backup/nginx/ /etc/nginx/
|
||||||
fi
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
/usr/local/bin/wo stack upgrade --nginx
|
||||||
|
fi
|
||||||
# restore sites and configuration
|
# restore sites and configuration
|
||||||
/usr/bin/rsync -au --noatime /var/lib/wo-backup/nginx/ /etc/nginx/
|
|
||||||
[ -f /etc/nginx/htpasswd-ee ] && { mv /etc/nginx/htpasswd-ee /etc/nginx/htpasswd-wo; }
|
[ -f /etc/nginx/htpasswd-ee ] && { mv /etc/nginx/htpasswd-ee /etc/nginx/htpasswd-wo; }
|
||||||
sed -i "s/locations.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
sed -i "s/locations.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
||||||
sed -i "s/locations-php7.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
sed -i "s/locations-php7.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
||||||
@@ -772,11 +755,9 @@ else
|
|||||||
fi
|
fi
|
||||||
if [ -z "$wo_preserve_config" ]; then
|
if [ -z "$wo_preserve_config" ]; then
|
||||||
if [ -n "$(command -v nginx)" ]; then
|
if [ -n "$(command -v nginx)" ]; then
|
||||||
if [ ! -f /etc/nginx/common/release ] || ! grep -q "v3.9.7" /etc/nginx/common/release; then
|
if [ ! -f /etc/apt/preferences.d/nginx-block ]; then
|
||||||
if [ ! -f /etc/apt/preferences.d/nginx-block ]; then
|
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log
|
||||||
wo_lib_echo "Upgrading Nginx" | tee -ai $wo_install_log
|
wo_upgrade_nginx | tee -ai $wo_install_log
|
||||||
wo_upgrade_nginx | tee -ai $wo_install_log
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user