update migration script
This commit is contained in:
262
install
262
install
@@ -10,7 +10,7 @@
|
|||||||
# Version 3.9.4 - 2019-03-15
|
# Version 3.9.4 - 2019-03-15
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
readonly wo_version_old="2.2.3"
|
readonly wo_version_old="2.2.3"
|
||||||
readonly wo_version_new="3.9.4.1"
|
readonly wo_version_new="3.9.4.2"
|
||||||
# CONTENTS
|
# CONTENTS
|
||||||
# ---
|
# ---
|
||||||
# 1. VARIABLES AND DECLARATIONS
|
# 1. VARIABLES AND DECLARATIONS
|
||||||
@@ -28,19 +28,19 @@ TPUT_INFO=$(tput setaf 7)
|
|||||||
TPUT_ECHO=$(tput setaf 4)
|
TPUT_ECHO=$(tput setaf 4)
|
||||||
|
|
||||||
wo_lib_echo () {
|
wo_lib_echo () {
|
||||||
|
|
||||||
echo "${*}${TPUT_RESET}"
|
echo "${TPUT_ECHO}${*}${TPUT_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wo_lib_echo_info()
|
wo_lib_echo_info()
|
||||||
{
|
{
|
||||||
|
|
||||||
echo "${TPUT_INFO}${*}${TPUT_RESET}"
|
echo "${TPUT_INFO}${*}${TPUT_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
wo_lib_echo_fail()
|
wo_lib_echo_fail()
|
||||||
{
|
{
|
||||||
|
|
||||||
echo "${TPUT_FAIL}${*}${TPUT_RESET}"
|
echo "${TPUT_FAIL}${*}${TPUT_RESET}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ echo ""
|
|||||||
# 1- Update the apt sewers with fresh info
|
# 1- Update the apt sewers with fresh info
|
||||||
###
|
###
|
||||||
wo_lib_echo "Updating apt-get repository info"
|
wo_lib_echo "Updating apt-get repository info"
|
||||||
apt-get update &>> /dev/null
|
apt-get update -qq &>> /dev/null
|
||||||
|
|
||||||
###
|
###
|
||||||
# 1- Check whether lsb_release is installed, and if not, install it
|
# 1- Check whether lsb_release is installed, and if not, install it
|
||||||
@@ -91,7 +91,7 @@ readonly wo_linux_distro=$(lsb_release -is)
|
|||||||
readonly wo_distro_version=$(lsb_release -sc)
|
readonly wo_distro_version=$(lsb_release -sc)
|
||||||
readonly wo_distro_id=$(lsb_release -rs)
|
readonly wo_distro_id=$(lsb_release -rs)
|
||||||
|
|
||||||
if [ -x /usr/loca/bin/ee ]; then
|
if [ -x /usr/local/bin/ee ]; then
|
||||||
migration=1
|
migration=1
|
||||||
else
|
else
|
||||||
migration=0
|
migration=0
|
||||||
@@ -116,13 +116,13 @@ fi
|
|||||||
###
|
###
|
||||||
# 1 - To prevent errors or unexpected behaviour, create the log and ACL it
|
# 1 - To prevent errors or unexpected behaviour, create the log and ACL it
|
||||||
###
|
###
|
||||||
if [ ! -d $wo_log_dir ]; then
|
if [ ! -d "$wo_log_dir" ]; then
|
||||||
|
|
||||||
wo_lib_echo "Creating WordOps log directory, just a second..."
|
wo_lib_echo "Creating WordOps log directory, just a second..."
|
||||||
mkdir -p $wo_log_dir || wo_lib_error "Whoops - seems we are unable to create the log directory $wo_log_dir, exit status " $?
|
mkdir -p "$wo_log_dir" || wo_lib_error "Whoops - seems we are unable to create the log directory $wo_log_dir, exit status " $?
|
||||||
|
|
||||||
touch /var/log/wo/{wordops.log,install.log}
|
touch /var/log/wo/{wordops.log,install.log}
|
||||||
|
|
||||||
chmod -R 700 /var/log/wo || wo_lib_error "Whoops, there was an error setting the permissions on the WordOps log folder, exit status " $?
|
chmod -R 700 /var/log/wo || wo_lib_error "Whoops, there was an error setting the permissions on the WordOps log folder, exit status " $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -131,15 +131,15 @@ fi
|
|||||||
####
|
####
|
||||||
wo_install_dep()
|
wo_install_dep()
|
||||||
{
|
{
|
||||||
|
|
||||||
{
|
{
|
||||||
if [ "$wo_linux_distro" == "Ubuntu" ]; then
|
if [ "$wo_linux_distro" == "Ubuntu" ]; then
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar software-properties-common pigz gnupg2 fail2ban cron ccze > /dev/null 2>&1
|
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip python3 python3-apt python3-setuptools python3-dev sqlite3 git tar software-properties-common pigz gnupg2 fail2ban cron ccze rsync tree > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
|
wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip dirmngr sudo python3 python3-apt python3-setuptools python3-dev ca-certificates sqlite3 git tar software-properties-common pigz apt-transport-https gnupg2 fail2ban cron ccze > /dev/null 2>&1
|
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confold" -y install build-essential curl gzip dirmngr sudo python3 python3-apt python3-setuptools python3-dev ca-certificates sqlite3 git tar software-properties-common pigz apt-transport-https gnupg2 fail2ban cron ccze rsync tree > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
locale-gen en
|
locale-gen en
|
||||||
} >> /var/log/wo/install.log 2>&1
|
} >> /var/log/wo/install.log 2>&1
|
||||||
# Support PFS
|
# Support PFS
|
||||||
@@ -150,7 +150,7 @@ wo_install_dep()
|
|||||||
# Change the TLS protocols
|
# Change the TLS protocols
|
||||||
sed -i "s/ssl_protocols\ \(.*\);/ssl_protocols TLSv1.2;/" /etc/nginx/nginx.conf
|
sed -i "s/ssl_protocols\ \(.*\);/ssl_protocols TLSv1.2;/" /etc/nginx/nginx.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Let's Encrypt .well-known folder setup
|
# Let's Encrypt .well-known folder setup
|
||||||
if [ ! -d /var/www/html/.well-known/acme-challenge ]; then
|
if [ ! -d /var/www/html/.well-known/acme-challenge ]; then
|
||||||
mkdir -p /var/www/html/.well-known/acme-challenge
|
mkdir -p /var/www/html/.well-known/acme-challenge
|
||||||
@@ -169,23 +169,23 @@ wo_sync_db()
|
|||||||
if [ -f /var/lib/ee/ee.db ]; then
|
if [ -f /var/lib/ee/ee.db ]; then
|
||||||
# Create the WordOps folder
|
# Create the WordOps folder
|
||||||
mkdir -p /var/lib/wo
|
mkdir -p /var/lib/wo
|
||||||
|
|
||||||
# Backup the nginx directory
|
# Backup the nginx directory
|
||||||
tar -cvf - /etc/nginx /etc/ee /var/lib/ee | pigz -9 > /var/lib/wo/ee-backup.tgz
|
tar -cvf - /etc/nginx /etc/ee /var/lib/ee | pigz -9 > /var/lib/wo/ee-backup.tgz
|
||||||
|
|
||||||
# Copy the EasyEngine database
|
# Copy the EasyEngine database
|
||||||
cp /var/lib/ee/ee.db /var/lib/wo/dbase-ee.db
|
cp /var/lib/ee/ee.db /var/lib/wo/dbase-ee.db
|
||||||
|
|
||||||
# Set the migration variable for the closing text
|
# Set the migration variable for the closing text
|
||||||
migration=1
|
migration=1
|
||||||
|
|
||||||
###
|
###
|
||||||
# Clean WO installation
|
# Clean WO installation
|
||||||
###
|
###
|
||||||
elif [ ! -d /var/lib/wo ]; then
|
elif [ ! -d /var/lib/wo ]; then
|
||||||
# Create the directory holding the WordOps database
|
# Create the directory holding the WordOps database
|
||||||
mkdir -p /var/lib/wo
|
mkdir -p /var/lib/wo
|
||||||
|
|
||||||
# Create an empty database for WordOps
|
# Create an empty database for WordOps
|
||||||
echo "CREATE TABLE sites (
|
echo "CREATE TABLE sites (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -205,12 +205,12 @@ wo_sync_db()
|
|||||||
is_hhvm INT INT DEFAULT '0',
|
is_hhvm INT INT DEFAULT '0',
|
||||||
php_version VARCHAR
|
php_version VARCHAR
|
||||||
);" | sqlite3 /var/lib/wo/dbase.db
|
);" | sqlite3 /var/lib/wo/dbase.db
|
||||||
|
|
||||||
if [ -f /var/lib/wo/dbase-ee.db ]; then
|
if [ -f /var/lib/wo/dbase-ee.db ]; then
|
||||||
# Copy the main EasyEngine database over since we are migrating
|
# Copy the main EasyEngine database over since we are migrating
|
||||||
cp /var/lib/wo/dbase-ee.db /var/lib/wo/dbase.db
|
cp /var/lib/wo/dbase-ee.db /var/lib/wo/dbase.db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check site is enable/live or disable
|
# Check site is enable/live or disable
|
||||||
cd /etc/nginx/sites-available || exit 1
|
cd /etc/nginx/sites-available || exit 1
|
||||||
for site in $(echo \* | grep -v default);
|
for site in $(echo \* | grep -v default);
|
||||||
@@ -220,10 +220,10 @@ wo_sync_db()
|
|||||||
else
|
else
|
||||||
wo_site_status='0'
|
wo_site_status='0'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Acquire information about the current nginx configuration
|
# Acquire information about the current nginx configuration
|
||||||
wo_site_current_type=$(head -n1 "/etc/nginx/sites-available/$site" | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5)
|
wo_site_current_type=$(head -n1 "/etc/nginx/sites-available/$site" | grep "NGINX CONFIGURATION" | rev | cut -d' ' -f3,4,5,6,7 | rev | cut -d ' ' -f2,3,4,5)
|
||||||
|
|
||||||
# Sniff out the vhost type and cache configuration
|
# Sniff out the vhost type and cache configuration
|
||||||
if [ "$wo_site_current_type" = "HTML" ]; then
|
if [ "$wo_site_current_type" = "HTML" ]; then
|
||||||
wo_site_current="html"
|
wo_site_current="html"
|
||||||
@@ -234,7 +234,7 @@ wo_sync_db()
|
|||||||
elif [ "$wo_site_current_type" = "MYSQL" ]; then
|
elif [ "$wo_site_current_type" = "MYSQL" ]; then
|
||||||
wo_site_current="mysql"
|
wo_site_current="mysql"
|
||||||
wo_site_current_cache="basic"
|
wo_site_current_cache="basic"
|
||||||
|
|
||||||
# Caching types on a single WordPress installation
|
# Caching types on a single WordPress installation
|
||||||
elif [ "$wo_site_current_type" = "WPSINGLE BASIC" ]; then
|
elif [ "$wo_site_current_type" = "WPSINGLE BASIC" ]; then
|
||||||
wo_site_current="wp"
|
wo_site_current="wp"
|
||||||
@@ -245,7 +245,7 @@ wo_sync_db()
|
|||||||
elif [ "$wo_site_current_type" = "WPSINGLE FAST CGI" ] || [ "$wo_site_current_type" = "WPSINGLE FASTCGI" ]; then
|
elif [ "$wo_site_current_type" = "WPSINGLE FAST CGI" ] || [ "$wo_site_current_type" = "WPSINGLE FASTCGI" ]; then
|
||||||
wo_site_current="wp"
|
wo_site_current="wp"
|
||||||
wo_site_current_cache="wpfc"
|
wo_site_current_cache="wpfc"
|
||||||
|
|
||||||
# Caching types on a single, subdirectory WordPress installation
|
# Caching types on a single, subdirectory WordPress installation
|
||||||
elif [ "$wo_site_current_type" = "WPSUBDIR BASIC" ]; then
|
elif [ "$wo_site_current_type" = "WPSUBDIR BASIC" ]; then
|
||||||
wo_site_current="wpsubdir"
|
wo_site_current="wpsubdir"
|
||||||
@@ -256,7 +256,7 @@ wo_sync_db()
|
|||||||
elif [ "$wo_site_current_type" = "WPSUBDIR FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDIR FASTCGI" ]; then
|
elif [ "$wo_site_current_type" = "WPSUBDIR FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDIR FASTCGI" ]; then
|
||||||
wo_site_current="wpsubdir"
|
wo_site_current="wpsubdir"
|
||||||
wo_site_current_cache="wpfc"
|
wo_site_current_cache="wpfc"
|
||||||
|
|
||||||
# Caching types on a single, subdomain WordPress installation
|
# Caching types on a single, subdomain WordPress installation
|
||||||
elif [ "$wo_site_current_type" = "WPSUBDOMAIN BASIC" ]; then
|
elif [ "$wo_site_current_type" = "WPSUBDOMAIN BASIC" ]; then
|
||||||
wo_site_current="wpsubdomain"
|
wo_site_current="wpsubdomain"
|
||||||
@@ -268,9 +268,9 @@ wo_sync_db()
|
|||||||
wo_site_current="wpsubdomain"
|
wo_site_current="wpsubdomain"
|
||||||
wo_site_current_cache="wpfc"
|
wo_site_current_cache="wpfc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wo_webroot="/var/www/$site"
|
wo_webroot="/var/www/$site"
|
||||||
|
|
||||||
# Import the configuration into the WordOps SQLite database
|
# Import the configuration into the WordOps SQLite database
|
||||||
echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db)
|
echo "INSERT INTO sites (sitename, site_type, cache_type, site_path, is_enabled, is_ssl, storage_fs, storage_db)
|
||||||
VALUES (\"$site\", \"$wo_site_current\", \"$wo_site_current_cache\", \"$wo_webroot\", \"$wo_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/wo/dbase.db
|
VALUES (\"$site\", \"$wo_site_current\", \"$wo_site_current_cache\", \"$wo_webroot\", \"$wo_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/wo/dbase.db
|
||||||
@@ -285,22 +285,22 @@ wo_sync_db()
|
|||||||
echo "ALTER TABLE sites ADD COLUMN is_hhvm INT DEFAULT '0';" | sqlite3 /var/lib/wo/dbase.db
|
echo "ALTER TABLE sites ADD COLUMN is_hhvm INT DEFAULT '0';" | sqlite3 /var/lib/wo/dbase.db
|
||||||
echo "ALTER TABLE sites ADD COLUMN php_version varchar DEFAULT \"$wo_php_version\";" | sqlite3 /var/lib/wo/dbase.db
|
echo "ALTER TABLE sites ADD COLUMN php_version varchar DEFAULT \"$wo_php_version\";" | sqlite3 /var/lib/wo/dbase.db
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo "UPDATE sites SET php_version = REPLACE(php_version, '5.6', '7.2');" | sqlite3 /var/lib/wo/dbase.db
|
echo "UPDATE sites SET php_version = REPLACE(php_version, '5.6', '7.2');" | sqlite3 /var/lib/wo/dbase.db
|
||||||
echo "UPDATE sites SET php_version = REPLACE(php_version, '7.0', '7.3');" | sqlite3 /var/lib/wo/dbase.db
|
echo "UPDATE sites SET php_version = REPLACE(php_version, '7.0', '7.3');" | sqlite3 /var/lib/wo/dbase.db
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Once again, set the proper ACL on the WordOps configuration directory
|
# Once again, set the proper ACL on the WordOps configuration directory
|
||||||
secure_wo_db()
|
secure_wo_db()
|
||||||
{
|
{
|
||||||
|
|
||||||
# The owner is root
|
# The owner is root
|
||||||
chown -R root:root /var/lib/wo/
|
chown -R root:root /var/lib/wo/
|
||||||
# Only allow access by root, block others
|
# Only allow access by root, block others
|
||||||
chmod -R 600 /var/lib/wo/
|
chmod -R 600 /var/lib/wo/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update the WP-CLI version
|
# Update the WP-CLI version
|
||||||
@@ -350,13 +350,13 @@ wo_install_acme_sh() {
|
|||||||
--cert-home /etc/letsencrypt/renewal
|
--cert-home /etc/letsencrypt/renewal
|
||||||
# enable auto-upgrade
|
# enable auto-upgrade
|
||||||
/etc/letsencrypt/acme.sh --config-home /etc/letsencrypt/config --upgrade --auto-upgrade
|
/etc/letsencrypt/acme.sh --config-home /etc/letsencrypt/config --upgrade --auto-upgrade
|
||||||
|
|
||||||
# Let's Encrypt .well-known folder setup
|
# Let's Encrypt .well-known folder setup
|
||||||
if [ ! -d /var/www/html/.well-known/acme-challenge ]; then
|
if [ ! -d /var/www/html/.well-known/acme-challenge ]; then
|
||||||
mkdir -p /var/www/html/.well-known/acme-challenge
|
mkdir -p /var/www/html/.well-known/acme-challenge
|
||||||
chown -R www-data:www-data /var/www/html /var/www/html/.well-known
|
chown -R www-data:www-data /var/www/html /var/www/html/.well-known
|
||||||
fi
|
fi
|
||||||
|
|
||||||
} >> /var/log/wo/install.log 2>&1
|
} >> /var/log/wo/install.log 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -367,91 +367,104 @@ wo_install()
|
|||||||
{
|
{
|
||||||
rm -rf /tmp/easyengine
|
rm -rf /tmp/easyengine
|
||||||
rm -rf /tmp/wordops
|
rm -rf /tmp/wordops
|
||||||
|
|
||||||
[ -z "$wo_branch" ] && {
|
[ -z "$wo_branch" ] && {
|
||||||
wo_branch=master
|
wo_branch=master
|
||||||
}
|
}
|
||||||
|
|
||||||
git clone -b "$wo_branch" https://github.com/WordOps/WordOps.git /tmp/wordops --quiet
|
git clone -b "$wo_branch" https://github.com/WordOps/WordOps.git /tmp/wordops --quiet
|
||||||
|
|
||||||
cd /tmp/wordops || exit 1
|
cd /tmp/wordops || exit 1
|
||||||
} >> /var/log/wo/install.log 2>&1;
|
} >> /var/log/wo/install.log 2>&1;
|
||||||
python3 setup.py install
|
python3 setup.py install
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wo_upgrade_nginx()
|
wo_upgrade_nginx()
|
||||||
{
|
{
|
||||||
# chec if the package nginx-ee is installed
|
|
||||||
CHECK_NGINX_EE=$(dpkg --list | grep nginx-ee)
|
{
|
||||||
CHECK_NGINX_VERSION=$(/usr/sbin/nginx -v 2>&1 | awk -F "/" '{print $2}' | grep 1.15)
|
# create backup directory
|
||||||
if [ -n "$CHECK_NGINX_EE" ]; then
|
mkdir -p /var/lib/wo/backup
|
||||||
{
|
|
||||||
# add new Nginx repository
|
# backup all sites available
|
||||||
if [ "$wo_linux_distro" = "Ubuntu" ]; then
|
/usr/bin/rsync -az /etc/nginx/ /var/lib/wo/backup/nginx/
|
||||||
echo "deb http://download.opensuse.org/repositories/home:/virtubox:/WordOps/xUbuntu_${wo_distro_id}/ /" >> /etc/apt/sources.list.d/wo-repo.list
|
|
||||||
wget -qO /tmp/nginx-wo.key "https://download.opensuse.org/repositories/home:virtubox:WordOps/xUbuntu_${wo_distro_id}/Release.key"
|
# chec if the package nginx-ee is installed
|
||||||
|
CHECK_NGINX_EE=$(dpkg --list | grep nginx-ee)
|
||||||
|
CHECK_NGINX_WO=$(dpkg --list | grep nginx-wo)
|
||||||
|
CHECK_PHP72=$(dpkg --list | grep php7.2-fpm)
|
||||||
|
CHECK_PHP73=$(dpkg --list | grep php7.3-fpm)
|
||||||
|
|
||||||
|
# add new Nginx repository
|
||||||
|
if [ "$wo_linux_distro" = "Ubuntu" ]; then
|
||||||
|
echo "deb http://download.opensuse.org/repositories/home:/virtubox:/WordOps/xUbuntu_${wo_distro_id}/ /" >> /etc/apt/sources.list.d/wo-repo.list
|
||||||
|
wget -qO /tmp/nginx-wo.key "https://download.opensuse.org/repositories/home:virtubox:WordOps/xUbuntu_${wo_distro_id}/Release.key"
|
||||||
|
else
|
||||||
|
if [ "$wo_distro_version" == "jessie" ]; then
|
||||||
|
echo "deb http://download.opensuse.org/repositories/home:/virtubox:/WordOps/Debian_8.0/ /" >> /etc/apt/sources.list.d/wo-repo.list
|
||||||
|
wget -qO /tmp/nginx-wo.key https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_8.0/Release.key
|
||||||
else
|
else
|
||||||
if [ "$wo_distro_version" == "jessie" ]; then
|
echo "deb http://download.opensuse.org/repositories/home:/virtubox:/WordOps/Debian_9.0/ /" >> /etc/apt/sources.list.d/wo-repo.list
|
||||||
echo "deb http://download.opensuse.org/repositories/home:/virtubox:/WordOps/Debian_8.0/ /" >> /etc/apt/sources.list.d/wo-repo.list
|
wget -qO /tmp/nginx-wo.key https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_9.0/Release.key
|
||||||
wget -qO /tmp/nginx-wo.key https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_8.0/Release.key
|
|
||||||
else
|
|
||||||
echo "deb http://download.opensuse.org/repositories/home:/virtubox:/WordOps/Debian_9.0/ /" >> /etc/apt/sources.list.d/wo-repo.list
|
|
||||||
wget -qO /tmp/nginx-wo.key https://download.opensuse.org/repositories/home:virtubox:WordOps/Debian_9.0/Release.key
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
# prevent apt preference to block install
|
fi
|
||||||
[ -f /etc/apt/preferences.d/nginx-block ] && {
|
# prevent apt preference to block install
|
||||||
mv /etc/apt/preferences.d/nginx-block "$HOME/nginx-block"
|
[ -f /etc/apt/preferences.d/nginx-block ] && {
|
||||||
}
|
mv /etc/apt/preferences.d/nginx-block "$HOME/nginx-block"
|
||||||
# import the respository key for updates
|
}
|
||||||
apt-key add - < /tmp/nginx-wo.key
|
# import the respository key for updates
|
||||||
rm -f /tmp/nginx-wo.key
|
apt-key add - < /tmp/nginx-wo.key
|
||||||
sudo apt-get update
|
rm -f /tmp/nginx-wo.key
|
||||||
# stop nginx
|
sudo apt-get update
|
||||||
service nginx stop
|
# stop nginx
|
||||||
|
service nginx stop
|
||||||
|
|
||||||
|
if [ -n "$CHECK_NGINX_EE" ]; then
|
||||||
# remove previous package
|
# remove previous package
|
||||||
apt-mark unhold nginx-ee nginx-common nginx-custom
|
apt-mark unhold nginx-ee nginx-common nginx-custom
|
||||||
apt-get -y -qq autoremove nginx-ee nginx-common nginx-custom
|
apt-get -y -qq autoremove nginx-ee nginx-common nginx-custom --purge
|
||||||
# install new nginx package
|
elif [ -n "$CHECK_NGINX_WO" ]; then
|
||||||
if [ -x /usr/local/bin/wo ]; then
|
apt-mark unhold nginx-wo nginx-common nginx-custom
|
||||||
# backup nginx conf
|
apt-get -y -qq autoremove nginx-wo nginx-common nginx-custom --purge
|
||||||
cd /etc || exit 1
|
fi
|
||||||
tar -I pigz -cf backup-nginx.tar.gz nginx
|
# remove previous php-fpm pool configuration
|
||||||
cd || exit 1
|
if [ -n "$CHECK_PHP72" ]; then
|
||||||
rm -f /etc/nginx/conf.d/{upstream.conf,redis.conf,fastcgi.conf}
|
apt-get remove php7.2-fpm -y -qq --purge
|
||||||
rm -f /etc/nginx/common/{php72.conf,php73.conf,wpcommon-php72.conf,wpcommon-php73.conf,locations-php72.conf,locations-php73.conf,redis-php72.conf,redis-php73.conf,wpfc-php72.conf,wpfc-php73.conf,wpsc-php72.conf,wpsc-php73.conf}
|
rm -f /etc/php/7.2/fpm/pool.d/*
|
||||||
rm -f /etc/nginx/*.default
|
fi
|
||||||
/usr/local/bin/wo stack install
|
if [ -n "$CHECK_PHP73" ]; then
|
||||||
else
|
apt-get remove php7.3-fpm -y -qq --purge
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confnew" -y install nginx-custom nginx-wo
|
rm -f /etc/php/7.3/fpm/pool.d/*
|
||||||
fi
|
fi
|
||||||
# set back apt preference
|
|
||||||
[ -f "$HOME/nginx-block" ] && {
|
# install new nginx package
|
||||||
mv "$HOME/nginx-block" /etc/apt/preferences.d/nginx-block
|
if [ -x /usr/local/bin/wo ]; then
|
||||||
}
|
/usr/local/bin/wo stack install --nginx --php --php73
|
||||||
# update nginx headers and ssl_ciphers
|
fi
|
||||||
if [ -f /etc/nginx/nginx.conf ]; then
|
|
||||||
sed -i "s/.*X-Powered-By.*/\tadd_header X-Powered-By \"WordOps $wo_version_new\";/" /etc/nginx/nginx.conf &>> /dev/null
|
# restore sites and configuration
|
||||||
new_ciphers="EECDH+CHACHA20:EECDH+AESGCM:EECDH+AES"
|
/usr/bin/rsync -auz /var/lib/wo/backup/nginx/ /etc/nginx/
|
||||||
sed -i "s/ssl_ciphers\ \(\"\|.\|'\)\(.*\)\(\"\|.\|'\);/ssl_ciphers \"$new_ciphers\";/" /etc/nginx/nginx.conf
|
|
||||||
fi
|
# set back apt preference
|
||||||
# update redis.conf headers
|
[ -f "$HOME/nginx-block" ] && {
|
||||||
if [ -f /etc/nginx/common/redis.conf ]; then
|
mv "$HOME/nginx-block" /etc/apt/preferences.d/nginx-block
|
||||||
sed -i "s/X-Cache /X-SRCache-Fetch-Status /g" /etc/nginx/common/redis.conf &>> /dev/null
|
}
|
||||||
sed -i "s/X-Cache-2 /X-SRCache-Store-Status /g" /etc/nginx/common/redis.conf &>> /dev/null
|
# update redis.conf headers
|
||||||
fi
|
if [ -f /etc/nginx/common/redis.conf ]; then
|
||||||
systemctl enable nginx
|
sed -i "s/X-Cache /X-SRCache-Fetch-Status /g" /etc/nginx/common/redis.conf &>> /dev/null
|
||||||
systemctl restart nginx
|
sed -i "s/X-Cache-2 /X-SRCache-Store-Status /g" /etc/nginx/common/redis.conf &>> /dev/null
|
||||||
} >> /var/log/wo/install.log 2>&1
|
fi
|
||||||
fi
|
systemctl enable nginx
|
||||||
|
systemctl restart nginx
|
||||||
|
} >> /var/log/wo/install.log 2>&1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wo_update_latest()
|
wo_update_latest()
|
||||||
{
|
{
|
||||||
|
|
||||||
if [ -f /etc/nginx/fastcgi_params ]
|
if [ -f /etc/nginx/fastcgi_params ]
|
||||||
then
|
then
|
||||||
grep -q 'HTTP_PROXY' /etc/nginx/fastcgi_params
|
grep -q 'HTTP_PROXY' /etc/nginx/fastcgi_params
|
||||||
@@ -461,7 +474,7 @@ wo_update_latest()
|
|||||||
service nginx restart &>> /dev/null
|
service nginx restart &>> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f /etc/ImageMagick/policy.xml ]
|
if [ -f /etc/ImageMagick/policy.xml ]
|
||||||
then
|
then
|
||||||
if [ ! -f /etc/ImageMagick/patch.txt ]
|
if [ ! -f /etc/ImageMagick/patch.txt ]
|
||||||
@@ -470,40 +483,33 @@ wo_update_latest()
|
|||||||
sed -i '/<policymap>/r /etc/ImageMagick/patch.txt' /etc/ImageMagick/policy.xml
|
sed -i '/<policymap>/r /etc/ImageMagick/patch.txt' /etc/ImageMagick/policy.xml
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Move ~/.my.cnf to /etc/mysql/conf.d/my.cnf
|
# Move ~/.my.cnf to /etc/mysql/conf.d/my.cnf
|
||||||
if [ ! -f /etc/mysql/conf.d/my.cnf ]
|
if [ ! -f /etc/mysql/conf.d/my.cnf ]; then
|
||||||
then
|
|
||||||
# create conf.d folder if not exist
|
# create conf.d folder if not exist
|
||||||
if [ ! -d /etc/mysql/conf.d ]; then
|
[ ! -d /etc/mysql/conf.d ] && {
|
||||||
mkdir -p /etc/mysql/conf.d
|
mkdir -p /etc/mysql/conf.d
|
||||||
chmod 755 /etc/mysql/conf.d
|
chmod 755 /etc/mysql/conf.d
|
||||||
fi
|
}
|
||||||
if [ -d /etc/mysql/conf.d ]
|
if [ -f $HOME/.my.cnf ]; then
|
||||||
then
|
cp ~/.my.cnf /etc/mysql/conf.d/my.cnf &>> /dev/null
|
||||||
if [ -f ~/.my.cnf ]
|
chmod 600 /etc/mysql/conf.d/my.cnf
|
||||||
then
|
|
||||||
cp ~/.my.cnf /etc/mysql/conf.d/my.cnf &>> /dev/null
|
elif [ -f /root/.my.cnf ]; then
|
||||||
chmod 600 /etc/mysql/conf.d/my.cnf
|
cp /root/.my.cnf /etc/mysql/conf.d/my.cnf &>> /dev/null
|
||||||
else
|
chmod 600 /etc/mysql/conf.d/my.cnf
|
||||||
if [ -f /root/.my.cnf ]
|
else
|
||||||
then
|
wo_lib_echo_fail ".my.cnf cannot be located in your current user or root folder..."
|
||||||
cp /root/.my.cnf /etc/mysql/conf.d/my.cnf &>> /dev/null
|
|
||||||
chmod 600 /etc/mysql/conf.d/my.cnf
|
|
||||||
else
|
|
||||||
wo_lib_echo_fail ".my.cnf cannot be located in your current user or root folder..."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fix WordPress example.html issue
|
# Fix WordPress example.html issue
|
||||||
# Ref: http://wptavern.com/xss-vulnerability-in-jetpack-and-the-twenty-fifteen-default-theme-affects-millions-of-wordpress-users
|
# Ref: http://wptavern.com/xss-vulnerability-in-jetpack-and-the-twenty-fifteen-default-theme-affects-millions-of-wordpress-users
|
||||||
dpkg --get-selections | grep -v deinstall | grep nginx &>> /dev/null
|
dpkg --get-selections | grep -v deinstall | grep nginx &>> /dev/null
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
cp /usr/lib/wo/templates/locations.mustache /etc/nginx/common/locations-php72.conf &>> /dev/null
|
cp /usr/lib/wo/templates/locations.mustache /etc/nginx/common/locations-php72.conf &>> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Fix Redis-server security issue
|
# Fix Redis-server security issue
|
||||||
# http://redis.io/topics/security
|
# http://redis.io/topics/security
|
||||||
if [ -f /etc/redis/redis.conf ]; then
|
if [ -f /etc/redis/redis.conf ]; then
|
||||||
@@ -513,7 +519,7 @@ wo_update_latest()
|
|||||||
service redis-server restart &>> /dev/null
|
service redis-server restart &>> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Do git intialisation
|
# Do git intialisation
|
||||||
|
|||||||
@@ -294,14 +294,14 @@ def setupwordpress(self, data):
|
|||||||
if not data['multisite']:
|
if not data['multisite']:
|
||||||
Log.debug(self, "Generating wp-config for WordPress Single site")
|
Log.debug(self, "Generating wp-config for WordPress Single site")
|
||||||
Log.debug(self, "bash -c \"php {0} --allow-root "
|
Log.debug(self, "bash -c \"php {0} --allow-root "
|
||||||
.format(WOVariables.wo_wpcli_path)
|
.format(WOVariables.wo_wpcli_path) +
|
||||||
+ "core config "
|
"core config " +
|
||||||
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
|
"--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
|
||||||
"--dbhost=\'{3}\' "
|
"--dbhost=\'{3}\' "
|
||||||
.format(data['wo_db_name'], wo_wp_prefix,
|
.format(data['wo_db_name'], wo_wp_prefix,
|
||||||
data['wo_db_user'], data['wo_db_host'])
|
data['wo_db_user'], data['wo_db_host']) +
|
||||||
+ "--dbpass=\'{0}\' "
|
"--dbpass=\'{0}\' "
|
||||||
"--extra-php<<PHP \n {1}\nPHP\""
|
"--extra-php<<PHP \n {1}\n {2}\nPHP\""
|
||||||
.format(data['wo_db_pass'],
|
.format(data['wo_db_pass'],
|
||||||
"\ndefine(\'CONCATENATE_SCRIPTS\',"
|
"\ndefine(\'CONCATENATE_SCRIPTS\',"
|
||||||
" false);",
|
" false);",
|
||||||
@@ -337,7 +337,7 @@ def setupwordpress(self, data):
|
|||||||
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
|
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
|
||||||
.format(data['wo_db_name'], wo_wp_prefix, data['wo_db_host'])
|
.format(data['wo_db_name'], wo_wp_prefix, data['wo_db_host'])
|
||||||
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
|
+ "--dbuser=\'{0}\' --dbpass=\'{1}\' "
|
||||||
"--extra-php<<PHP \n {2} {3} \nPHP\""
|
"--extra-php<<PHP \n {2} {3} {4} \nPHP\""
|
||||||
.format(data['wo_db_user'], data['wo_db_pass'],
|
.format(data['wo_db_user'], data['wo_db_pass'],
|
||||||
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
|
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
|
||||||
" true);",
|
" true);",
|
||||||
@@ -1195,7 +1195,6 @@ def doCleanupAction(self, domain='', webroot='', dbname='', dbuser='',
|
|||||||
deleteDB(self, dbname, dbuser, dbhost)
|
deleteDB(self, dbname, dbuser, dbhost)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# setup letsencrypt for domain + www.domain
|
# setup letsencrypt for domain + www.domain
|
||||||
def setupLetsEncrypt(self, wo_domain_name):
|
def setupLetsEncrypt(self, wo_domain_name):
|
||||||
|
|
||||||
|
|||||||
@@ -226,14 +226,6 @@ class WOStackController(CementBaseController):
|
|||||||
(data), 'upstream.mustache', out=wo_nginx)
|
(data), 'upstream.mustache', out=wo_nginx)
|
||||||
wo_nginx.close()
|
wo_nginx.close()
|
||||||
|
|
||||||
Log.debug(self, 'Writting the nginx configuration to '
|
|
||||||
'file /etc/nginx/conf.d/map-wp.conf')
|
|
||||||
wo_nginx = open('/etc/nginx/conf.d/map-wp.conf',
|
|
||||||
encoding='utf-8', mode='w')
|
|
||||||
self.app.render((data), 'map-wp.mustache',
|
|
||||||
out=wo_nginx)
|
|
||||||
wo_nginx.close()
|
|
||||||
|
|
||||||
if not (os.path.isfile('/etc/nginx/conf.d/stub_status.conf')):
|
if not (os.path.isfile('/etc/nginx/conf.d/stub_status.conf')):
|
||||||
data = dict(phpconf=True if
|
data = dict(phpconf=True if
|
||||||
WOAptGet.is_installed(self, 'php7.2-fpm')
|
WOAptGet.is_installed(self, 'php7.2-fpm')
|
||||||
@@ -256,6 +248,16 @@ class WOStackController(CementBaseController):
|
|||||||
out=wo_nginx)
|
out=wo_nginx)
|
||||||
wo_nginx.close()
|
wo_nginx.close()
|
||||||
|
|
||||||
|
Log.debug(self, 'Writting the nginx configuration to '
|
||||||
|
'file /etc/nginx/conf.d/'
|
||||||
|
'map-wp-fastcgi-cache.conf')
|
||||||
|
wo_nginx = open('/etc/nginx/conf.d/'
|
||||||
|
'map-wp-fastcgi-cache.conf',
|
||||||
|
encoding='utf-8', mode='w')
|
||||||
|
self.app.render((data), 'map-wp.mustache',
|
||||||
|
out=wo_nginx)
|
||||||
|
wo_nginx.close()
|
||||||
|
|
||||||
# Setup Nginx common directory
|
# Setup Nginx common directory
|
||||||
if not os.path.exists('/etc/nginx/common'):
|
if not os.path.exists('/etc/nginx/common'):
|
||||||
Log.debug(self, 'Creating directory'
|
Log.debug(self, 'Creating directory'
|
||||||
@@ -486,8 +488,7 @@ class WOStackController(CementBaseController):
|
|||||||
WOGit.add(self,
|
WOGit.add(self,
|
||||||
["/etc/nginx"], msg="Adding Nginx into Git")
|
["/etc/nginx"], msg="Adding Nginx into Git")
|
||||||
WOService.reload_service(self, 'nginx')
|
WOService.reload_service(self, 'nginx')
|
||||||
if (set(["nginx-plus"]).issubset(set(apt_packages)) or
|
if set(["nginx"]).issubset(set(apt_packages)):
|
||||||
set(["nginx"]).issubset(set(apt_packages))):
|
|
||||||
WOShellExec.cmd_exec(self, "sed -i -e 's/^user/#user/'"
|
WOShellExec.cmd_exec(self, "sed -i -e 's/^user/#user/'"
|
||||||
" -e '/^#user/a user"
|
" -e '/^#user/a user"
|
||||||
"\ www-data\;'"
|
"\ www-data\;'"
|
||||||
@@ -501,18 +502,8 @@ class WOStackController(CementBaseController):
|
|||||||
"\ \/etc\/nginx\/sites-enabled"
|
"\ \/etc\/nginx\/sites-enabled"
|
||||||
"\/*;' /etc/nginx/nginx.conf")
|
"\/*;' /etc/nginx/nginx.conf")
|
||||||
|
|
||||||
# WordOpsconfig for NGINX plus
|
print("HTTP Auth User Name: WordOps" +
|
||||||
data['version'] = WOVariables.wo_version
|
"\nHTTP Auth Password : {0}".format(passwd))
|
||||||
Log.debug(self, 'Writting for nginx plus configuration'
|
|
||||||
' to file /etc/nginx/conf.d/wo-plus.conf')
|
|
||||||
wo_nginx = open('/etc/nginx/conf.d/wo-plus.conf',
|
|
||||||
encoding='utf-8', mode='w')
|
|
||||||
self.app.render((data), 'wo-plus.mustache',
|
|
||||||
out=wo_nginx)
|
|
||||||
wo_nginx.close()
|
|
||||||
|
|
||||||
print("HTTP Auth User Name: WordOps"
|
|
||||||
+ "\nHTTP Auth Password : {0}".format(passwd))
|
|
||||||
WOService.reload_service(self, 'nginx')
|
WOService.reload_service(self, 'nginx')
|
||||||
else:
|
else:
|
||||||
self.msg = (self.msg + ["HTTP Auth User "
|
self.msg = (self.msg + ["HTTP Auth User "
|
||||||
@@ -939,8 +930,11 @@ class WOStackController(CementBaseController):
|
|||||||
"profiler_enable] = off\n")
|
"profiler_enable] = off\n")
|
||||||
|
|
||||||
# Disable xdebug
|
# Disable xdebug
|
||||||
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\' /etc/php/7.3/mods-available/xdebug.ini"):
|
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'"
|
||||||
WOFileUtils.searchreplace(self, "/etc/php/7.3/mods-available/"
|
" /etc/php/7.3/mods-available"
|
||||||
|
"/xdebug.ini"):
|
||||||
|
WOFileUtils.searchreplace(self, "/etc/php/7.3/"
|
||||||
|
"mods-available/"
|
||||||
"xdebug.ini",
|
"xdebug.ini",
|
||||||
"zend_extension",
|
"zend_extension",
|
||||||
";zend_extension")
|
";zend_extension")
|
||||||
|
|||||||
Reference in New Issue
Block a user