Files
WPIQ/install

626 lines
24 KiB
Plaintext
Raw Normal View History

2018-11-13 21:55:59 +01:00
#!/bin/bash
# -------------------------------------------------------------------------
# WordOps install and update script
# -------------------------------------------------------------------------
# Website: https://wordops.org
# GitHub: https://github.com/WordOps/WordOps
# Copyright (c) 2019 - WordOps
# This script is licensed under M.I.T
# -------------------------------------------------------------------------
2019-03-15 19:27:36 +01:00
# Version 3.9.4 - 2019-03-15
# -------------------------------------------------------------------------
2019-03-05 13:19:47 +01:00
readonly wo_version_old="2.2.3"
2019-03-16 09:25:48 +01:00
readonly wo_version_new="3.9.4.1"
# CONTENTS
# ---
# 1. VARIABLES AND DECLARATIONS
# 2. PREPARE FOR INSTALLATION
# 3. INSTALLATION
# 4.
2018-11-30 17:04:15 +01:00
###
# 1 - Set the CLI output colors
###
2018-11-13 21:55:59 +01:00
2019-03-05 13:19:47 +01:00
TPUT_RESET=$(tput sgr0)
TPUT_FAIL=$(tput setaf 1)
2019-03-07 18:02:46 +01:00
TPUT_INFO=$(tput setaf 7)
TPUT_ECHO=$(tput setaf 4)
2019-03-05 13:19:47 +01:00
wo_lib_echo () {
2019-03-07 18:02:46 +01:00
2019-03-07 12:36:32 +01:00
echo "${*}${TPUT_RESET}"
2019-03-05 13:19:47 +01:00
}
wo_lib_echo_info()
2018-11-13 21:55:59 +01:00
{
2019-03-07 18:02:46 +01:00
2019-03-05 13:19:47 +01:00
echo "${TPUT_INFO}${*}${TPUT_RESET}"
2018-11-13 21:55:59 +01:00
}
2018-11-30 17:04:15 +01:00
2019-03-05 13:19:47 +01:00
wo_lib_echo_fail()
2018-11-13 21:55:59 +01:00
{
2019-03-05 13:19:47 +01:00
echo "${TPUT_FAIL}${*}${TPUT_RESET}"
2018-11-13 21:55:59 +01:00
}
2018-11-30 17:04:15 +01:00
2019-03-05 13:19:47 +01:00
###
# 1 - Capture errors
###
wo_lib_error()
2018-11-13 21:55:59 +01:00
{
2019-03-05 13:19:47 +01:00
echo "[ $(date) ] ${TPUT_FAIL}${*}${TPUT_RESET}"
exit "$2"
2018-11-13 21:55:59 +01:00
}
2018-11-30 17:04:15 +01:00
###
# 1 - Check whether the installation is called with elevated rights
###
2018-11-13 21:55:59 +01:00
if [[ $EUID -ne 0 ]]; then
wo_lib_echo_fail "Sudo privilege required..."
2019-03-05 13:19:47 +01:00
wo_lib_echo_fail "Use: wget -qO wo wordops.se/tup && sudo bash wo"
2018-11-13 21:55:59 +01:00
exit 100
fi
2019-03-05 13:19:47 +01:00
echo ""
wo_lib_echo "Welcome to WordOps install script v${wo_version_new}"
echo ""
2018-11-13 21:55:59 +01:00
2018-11-30 17:04:15 +01:00
###
# 1- Update the apt sewers with fresh info
###
wo_lib_echo "Updating apt-get repository info"
2018-11-13 21:55:59 +01:00
apt-get update &>> /dev/null
2018-11-30 17:04:15 +01:00
###
# 1- Check whether lsb_release is installed, and if not, install it
###
if [ -z "$(command -v lsb_release)" ]; then
2018-11-13 21:55:59 +01:00
wo_lib_echo "Installing lsb-release, please wait..."
apt-get -y install lsb-release &>> /dev/null
fi
2018-11-30 17:04:15 +01:00
###
# 1 - Define variables for later use
###
2019-03-05 17:03:23 +01:00
wo_branch="$1"
2018-11-13 21:55:59 +01:00
readonly wo_log_dir=/var/log/wo/
readonly wo_install_log=/var/log/wo/install.log
readonly wo_linux_distro=$(lsb_release -is)
2018-11-13 21:55:59 +01:00
readonly wo_distro_version=$(lsb_release -sc)
readonly wo_distro_id=$(lsb_release -rs)
if [ -x /usr/loca/bin/ee ]; then
migration=1
else
migration=0
fi
2018-11-13 21:55:59 +01:00
2018-11-30 17:04:15 +01:00
###
# 1 - Checking linux distro
###
2018-11-13 21:55:59 +01:00
if [ "$wo_linux_distro" != "Ubuntu" ] && [ "$wo_linux_distro" != "Debian" ]; then
wo_lib_echo_fail "WordOps (wo) only supports Ubuntu and Debian at the moment."
wo_lib_echo_fail "If you are feeling adventurous, you are free to fork WordOps to support"
wo_lib_echo_fail "other Linux distributions and perhaps even Unix deratives."
exit 100
2019-03-05 17:03:23 +01:00
else
check_wo_linux_distro=$(lsb_release -sc | grep -E "trusty|xenial|bionic|jessie|stretch")
if [ -z "$check_wo_linux_distro" ]; then
wo_lib_echo_fail "WordOps (wo) only supports Ubuntu 14.04/16.04/18.04, Debian 8.x and Debian 9.x"
exit 100
fi
2018-11-13 21:55:59 +01:00
fi
2018-11-30 17:04:15 +01:00
###
# 1 - To prevent errors or unexpected behaviour, create the log and ACL it
###
2018-11-13 21:55:59 +01:00
if [ ! -d $wo_log_dir ]; then
2019-03-05 13:19:47 +01:00
2018-11-13 21:55:59 +01:00
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 " $?
2019-03-05 13:19:47 +01:00
2018-11-13 21:55:59 +01:00
touch /var/log/wo/{wordops.log,install.log}
2019-03-05 13:19:47 +01:00
2018-11-13 21:55:59 +01:00
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
2018-11-30 17:04:15 +01:00
###
# 2 - Setup the dependencies for installation
####
2019-03-05 13:19:47 +01:00
wo_install_dep()
2018-11-13 21:55:59 +01:00
{
2019-03-08 00:37:36 +01:00
{
2019-03-05 13:19:47 +01:00
if [ "$wo_linux_distro" == "Ubuntu" ]; then
2019-03-16 10:30:52 +01:00
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
2019-03-05 13:19:47 +01:00
else
2019-03-17 17:38:41 +01:00
wget -qO /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
2019-03-16 10:30:52 +01:00
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
2019-03-05 13:19:47 +01:00
fi
locale-gen en
} >> /var/log/wo/install.log 2>&1
2018-12-05 22:31:27 +01:00
# Support PFS
if [ -f /etc/nginx/nginx.conf ]; then
2019-03-08 00:37:36 +01:00
# Replace previous ciphers
new_ciphers="EECDH+CHACHA20:EECDH+AESGCM:EECDH+AES"
sed -i "s/ssl_ciphers\ \(\"\|.\|'\)\(.*\)\(\"\|.\|'\);/ssl_ciphers \"$new_ciphers\";/" /etc/nginx/nginx.conf
2018-12-05 22:31:27 +01:00
# Change the TLS protocols
2019-03-08 00:37:36 +01:00
sed -i "s/ssl_protocols\ \(.*\);/ssl_protocols TLSv1.2;/" /etc/nginx/nginx.conf
2018-12-05 22:31:27 +01:00
fi
2019-03-05 17:03:23 +01:00
# Let's Encrypt .well-known folder setup
if [ ! -d /var/www/html/.well-known/acme-challenge ]; then
mkdir -p /var/www/html/.well-known/acme-challenge
2019-03-07 18:02:46 +01:00
chown -R www-data:www-data /var/www/html /var/www/html/.well-known
fi
2018-11-13 21:55:59 +01:00
}
2018-11-30 17:04:15 +01:00
###
# 3 - Create/migrate the essentials
###
2019-03-05 13:19:47 +01:00
wo_sync_db()
2018-11-13 21:55:59 +01:00
{
2018-11-30 17:04:15 +01:00
###
# Switching from EE -> WO
###
if [ -f /var/lib/ee/ee.db ]; then
# Create the WordOps folder
mkdir -p /var/lib/wo
2019-03-05 13:19:47 +01:00
2018-11-30 17:04:15 +01:00
# Backup the nginx directory
2018-12-03 20:17:22 +01:00
tar -cvf - /etc/nginx /etc/ee /var/lib/ee | pigz -9 > /var/lib/wo/ee-backup.tgz
2019-03-05 13:19:47 +01:00
2018-11-30 17:04:15 +01:00
# Copy the EasyEngine database
2018-12-03 20:17:22 +01:00
cp /var/lib/ee/ee.db /var/lib/wo/dbase-ee.db
2019-03-05 13:19:47 +01:00
2018-12-03 20:17:22 +01:00
# Set the migration variable for the closing text
migration=1
2019-03-05 13:19:47 +01:00
###
# Clean WO installation
###
elif [ ! -d /var/lib/wo ]; then
2018-12-03 20:17:22 +01:00
# Create the directory holding the WordOps database
2018-11-13 21:55:59 +01:00
mkdir -p /var/lib/wo
2019-03-05 13:19:47 +01:00
2018-12-03 20:17:22 +01:00
# Create an empty database for WordOps
2018-11-13 21:55:59 +01:00
echo "CREATE TABLE sites (
id INTEGER PRIMARY KEY AUTOINCREMENT,
sitename UNIQUE,
site_type CHAR,
cache_type CHAR,
site_path CHAR,
created_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
is_enabled INT,
is_ssl INT,
storage_fs CHAR,
storage_db CHAR,
db_name VARCHAR,
db_user VARCHAR,
db_password VARCHAR,
db_host VARCHAR,
is_hhvm INT INT DEFAULT '0',
php_version VARCHAR
);" | sqlite3 /var/lib/wo/dbase.db
2019-03-05 13:19:47 +01:00
if [ -f /var/lib/wo/dbase-ee.db ]; then
2018-12-03 20:17:22 +01:00
# Copy the main EasyEngine database over since we are migrating
cp /var/lib/wo/dbase-ee.db /var/lib/wo/dbase.db
fi
2019-03-05 13:19:47 +01:00
2018-11-13 21:55:59 +01:00
# Check site is enable/live or disable
cd /etc/nginx/sites-available || exit 1
for site in $(echo \* | grep -v default);
2018-11-13 21:55:59 +01:00
do
2019-03-05 13:19:47 +01:00
if [ -f "/etc/nginx/sites-enabled/$site" ]; then
wo_site_status='1'
else
wo_site_status='0'
fi
2019-03-05 13:19:47 +01:00
# 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)
2019-03-05 13:19:47 +01:00
# Sniff out the vhost type and cache configuration
if [ "$wo_site_current_type" = "HTML" ]; then
wo_site_current="html"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "PHP" ]; then
wo_site_current="php"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "MYSQL" ]; then
wo_site_current="mysql"
wo_site_current_cache="basic"
2019-03-05 13:19:47 +01:00
# Caching types on a single WordPress installation
elif [ "$wo_site_current_type" = "WPSINGLE BASIC" ]; then
wo_site_current="wp"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "WPSINGLE WP SUPER CACHE" ]; then
wo_site_current="wp"
wo_site_current_cache="wpsc"
elif [ "$wo_site_current_type" = "WPSINGLE FAST CGI" ] || [ "$wo_site_current_type" = "WPSINGLE FASTCGI" ]; then
wo_site_current="wp"
wo_site_current_cache="wpfc"
2019-03-05 13:19:47 +01:00
# Caching types on a single, subdirectory WordPress installation
elif [ "$wo_site_current_type" = "WPSUBDIR BASIC" ]; then
wo_site_current="wpsubdir"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "WPSUBDIR WP SUPER CACHE" ]; then
wo_site_current="wpsubdir"
wo_site_current_cache="wpsc"
elif [ "$wo_site_current_type" = "WPSUBDIR FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDIR FASTCGI" ]; then
wo_site_current="wpsubdir"
wo_site_current_cache="wpfc"
2019-03-05 13:19:47 +01:00
# Caching types on a single, subdomain WordPress installation
elif [ "$wo_site_current_type" = "WPSUBDOMAIN BASIC" ]; then
wo_site_current="wpsubdomain"
wo_site_current_cache="basic"
elif [ "$wo_site_current_type" = "WPSUBDOMAIN WP SUPER CACHE" ]; then
wo_site_current="wpsubdomain"
wo_site_current_cache="wpsc"
elif [ "$wo_site_current_type" = "WPSUBDOMAIN FAST CGI" ] || [ "$wo_site_current_type" = "WPSUBDOMAIN FASTCGI" ]; then
wo_site_current="wpsubdomain"
wo_site_current_cache="wpfc"
fi
2019-03-05 13:19:47 +01:00
wo_webroot="/var/www/$site"
2019-03-05 13:19:47 +01:00
# 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)
VALUES (\"$site\", \"$wo_site_current\", \"$wo_site_current_cache\", \"$wo_webroot\", \"$wo_site_status\", 0, 'ext4', 'mysql');" | sqlite3 /var/lib/wo/dbase.db
2018-11-13 21:55:59 +01:00
done
else
2018-11-30 17:04:15 +01:00
wo_php_version="7.2"
2018-11-13 21:55:59 +01:00
wo_lib_echo "Updating WordOps Database"
echo "ALTER TABLE sites ADD COLUMN db_name varchar;" | sqlite3 /var/lib/wo/dbase.db
echo "ALTER TABLE sites ADD COLUMN db_user varchar; " | sqlite3 /var/lib/wo/dbase.db
echo "ALTER TABLE sites ADD COLUMN db_password varchar;" | sqlite3 /var/lib/wo/dbase.db
echo "ALTER TABLE sites ADD COLUMN db_host varchar;" | 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
fi
2019-03-05 13:19:47 +01:00
2018-12-03 22:36:27 +01:00
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
2019-03-05 13:19:47 +01:00
2018-11-13 21:55:59 +01:00
}
# Once again, set the proper ACL on the WordOps configuration directory
2019-03-05 13:19:47 +01:00
secure_wo_db()
2018-11-13 21:55:59 +01:00
{
2019-03-07 18:02:46 +01:00
2018-11-13 21:55:59 +01:00
# The owner is root
chown -R root:root /var/lib/wo/
# Only allow access by root, block others
chmod -R 600 /var/lib/wo/
2019-03-07 18:02:46 +01:00
2018-11-13 21:55:59 +01:00
}
# Update the WP-CLI version
2019-03-05 13:19:47 +01:00
wo_update_wp_cli()
2018-11-13 21:55:59 +01:00
{
2019-03-10 18:45:32 +01:00
{
WP_CLI_PATH=$(command -v wp)
if [ -n "$WP_CLI_PATH" ]; then
rm -rf "$WP_CLI_PATH"
# Update WP-CLI to the most recent version
wget -qO /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x /usr/local/bin/wp
else
wget -qO /usr/local/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x /usr/local/bin/wp
fi
[ ! -h /usr/bin/wp ] && {
ln -s /usr/local/bin/wp /usr/bin/
}
[ ! -f /etc/bash_completion.d/wp-completion.bash ] && {
wget -qO /etc/bash_completion.d/wp-completion.bash https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-completion.bash
}
2019-03-10 18:45:32 +01:00
} >> /var/log/wo/install.log 2>&1
2018-11-13 21:55:59 +01:00
}
wo_install_acme_sh() {
# check if acme.sh is already installed
if [ ! -d /opt/acme.sh ]; then
{
# clone the git repository
git clone https://github.com/Neilpang/acme.sh.git /opt/acme.sh -q
cd /opt/acme.sh || exit 1
# create conf directories
[ ! -d /etc/letsencrypt/config ] && {
mkdir -p /etc/letsencrypt/config
}
[ ! -d /etc/letsencrypt/live ] && {
mkdir -p /etc/letsencrypt/live
}
[ ! -d /etc/letsencrypt/renewal ] && {
mkdir -p /etc/letsencrypt/renewal
}
# install acme.sh
./acme.sh --install \
--home /etc/letsencrypt \
--config-home /etc/letsencrypt/config \
--cert-home /etc/letsencrypt/renewal
# enable auto-upgrade
2019-03-16 10:30:52 +01:00
/etc/letsencrypt/acme.sh --config-home /etc/letsencrypt/config --upgrade --auto-upgrade
# Let's Encrypt .well-known folder setup
if [ ! -d /var/www/html/.well-known/acme-challenge ]; then
mkdir -p /var/www/html/.well-known/acme-challenge
chown -R www-data:www-data /var/www/html /var/www/html/.well-known
fi
2019-03-15 22:54:16 +01:00
} >> /var/log/wo/install.log 2>&1
fi
}
2018-11-13 21:55:59 +01:00
# Now, finally, let's install WordOps
2019-03-05 13:19:47 +01:00
wo_install()
2018-11-13 21:55:59 +01:00
{
2019-03-07 18:02:46 +01:00
{
2019-03-07 13:23:19 +01:00
rm -rf /tmp/easyengine
rm -rf /tmp/wordops
[ -z "$wo_branch" ] && {
wo_branch=master
}
2019-03-07 18:02:46 +01:00
git clone -b "$wo_branch" https://github.com/WordOps/WordOps.git /tmp/wordops --quiet
2019-03-07 13:23:19 +01:00
cd /tmp/wordops || exit 1
2019-03-07 18:02:46 +01:00
} >> /var/log/wo/install.log 2>&1;
python3 setup.py install
}
2019-03-07 18:02:46 +01:00
wo_upgrade_nginx()
{
# chec if the package nginx-ee is installed
CHECK_NGINX_EE=$(dpkg --list | grep nginx-ee)
if [ -n "$CHECK_NGINX_EE" ]; then
{
# 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
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
# prevent apt preference to block install
[ -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
rm -f /tmp/nginx-wo.key
sudo apt-get update
# stop nginx
service nginx stop
# remove previous package
2019-03-15 19:27:36 +01:00
apt-mark unhold nginx-ee nginx-common nginx-custom
apt-get -y -qq autoremove nginx-ee nginx-common nginx-custom
# install new nginx package
if [ -x /usr/local/bin/wo ]; then
rm -f /etc/nginx/conf.d/{upstream.conf,redis.conf,fastcgi.conf}
rm -f /etc/nginx/*.default
/usr/local/bin/wo stack install
else
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confnew" -y install nginx-custom nginx-wo
fi
# set back apt preference
[ -f "$HOME/nginx-block" ] && {
mv "$HOME/nginx-block" /etc/apt/preferences.d/nginx-block
}
# update nginx headers and ssl_ciphers
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
new_ciphers="EECDH+CHACHA20:EECDH+AESGCM:EECDH+AES"
sed -i "s/ssl_ciphers\ \(\"\|.\|'\)\(.*\)\(\"\|.\|'\);/ssl_ciphers \"$new_ciphers\";/" /etc/nginx/nginx.conf
fi
# update redis.conf headers
if [ -f /etc/nginx/common/redis.conf ]; then
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
fi
systemctl enable nginx
systemctl restart nginx
} >> /var/log/wo/install.log 2>&1
fi
2018-11-13 21:55:59 +01:00
}
2019-03-05 13:19:47 +01:00
wo_update_latest()
2018-11-13 21:55:59 +01:00
{
2019-03-05 13:19:47 +01:00
if [ -f /etc/nginx/fastcgi_params ]
then
grep -q 'HTTP_PROXY' /etc/nginx/fastcgi_params
if [[ $? -ne 0 ]]; then
echo "fastcgi_param HTTP_PROXY \"\";" >> /etc/nginx/fastcgi_params
echo "fastcgi_param HTTP_PROXY \"\";" >> /etc/nginx/fastcgi.conf
service nginx restart &>> /dev/null
fi
fi
2019-03-05 13:19:47 +01:00
if [ -f /etc/ImageMagick/policy.xml ]
then
if [ ! -f /etc/ImageMagick/patch.txt ]
then
echo -e "\t<policy domain="coder" rights="none" pattern="EPHEMERAL" />\n\t<policy domain="coder" rights="none" pattern="URL" />\n\t<policy domain="coder" rights="none" pattern="HTTPS" />\n\t<policy domain="coder" rights="none" pattern="MVG" />\n\t<policy domain="coder" rights="none" pattern="MSL" />" >> /etc/ImageMagick/patch.txt
sed -i '/<policymap>/r /etc/ImageMagick/patch.txt' /etc/ImageMagick/policy.xml
fi
2018-11-13 21:55:59 +01:00
fi
2019-03-05 13:19:47 +01:00
2019-03-05 17:03:23 +01:00
# Move ~/.my.cnf to /etc/mysql/conf.d/my.cnf
2018-11-13 21:55:59 +01:00
if [ ! -f /etc/mysql/conf.d/my.cnf ]
then
2019-03-05 17:03:23 +01:00
# create conf.d folder if not exist
2018-11-13 21:55:59 +01:00
if [ ! -d /etc/mysql/conf.d ]; then
mkdir -p /etc/mysql/conf.d
chmod 755 /etc/mysql/conf.d
fi
if [ -d /etc/mysql/conf.d ]
then
if [ -f ~/.my.cnf ]
then
cp ~/.my.cnf /etc/mysql/conf.d/my.cnf &>> /dev/null
chmod 600 /etc/mysql/conf.d/my.cnf
else
if [ -f /root/.my.cnf ]
then
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
2019-03-05 13:19:47 +01:00
2018-11-13 21:55:59 +01:00
# Fix WordPress example.html issue
# 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
if [ $? -eq 0 ]; then
cp /usr/lib/wo/templates/locations.mustache /etc/nginx/common/locations-php72.conf &>> /dev/null
2018-11-13 21:55:59 +01:00
fi
2019-03-05 13:19:47 +01:00
2019-03-05 17:03:23 +01:00
# Fix Redis-server security issue
# http://redis.io/topics/security
if [ -f /etc/redis/redis.conf ]; then
grep -0 -v "#" /etc/redis/redis.conf | grep 'bind' &>> /dev/null
if [ $? -ne 0 ]; then
2018-11-13 21:55:59 +01:00
sed -i '$ a bind 127.0.0.1' /etc/redis/redis.conf &>> /dev/null
service redis-server restart &>> /dev/null
fi
2018-11-13 21:55:59 +01:00
fi
2019-03-05 13:19:47 +01:00
2018-11-13 21:55:59 +01:00
}
# Do git intialisation
2019-03-05 13:19:47 +01:00
wo_git_init()
2018-11-13 21:55:59 +01:00
{
# Nginx under git version control
[ -d /etc/nginx ] && {
cd /etc/nginx || exit 1
2018-11-13 21:55:59 +01:00
if [ ! -d /etc/nginx/.git ]; then
2019-03-07 18:02:46 +01:00
git init
2018-11-13 21:55:59 +01:00
fi
git add -A .
git commit -am "Updated Nginx"
2019-03-07 18:02:46 +01:00
} >> /var/log/wo/install.log 2>&1
2018-12-03 20:17:22 +01:00
# WordOps under git version control
2019-03-07 18:02:46 +01:00
[ -d /etc/wo ] && {
cd /etc/wo || exit 1
[ ! -d /etc/wo/.git ] && {
git init
}
git add -A .
git commit -am "Installed/Updated to WordOps"
2019-03-07 18:02:46 +01:00
} >> /var/log/wo/install.log 2>&1
# PHP under git version control
[ -d /etc/php ] && {
cd /etc/php || exit 1
2018-11-13 21:55:59 +01:00
if [ ! -d /etc/php/.git ]; then
git init
2018-11-13 21:55:59 +01:00
fi
git add -A .
git commit -am "Updated PHP"
2019-03-07 18:02:46 +01:00
} >> /var/log/wo/install.log 2>&1
2018-11-13 21:55:59 +01:00
}
2019-03-05 17:03:23 +01:00
###
# 4 - WO MAIN SETUP
###
# 1 - WO already installed
if [ -x /usr/local/bin/wo ]; then
2019-03-05 13:19:47 +01:00
wo -v 2>&1 | grep $wo_version_new &>> /dev/null
2018-11-13 21:55:59 +01:00
if [[ $? -ne 0 ]];then
read -p "Update WordOps to $wo_version_new (y/n): " wo_ans
if [ "$wo_ans" = "y" ] || [ "$wo_ans" = "Y" ]; then
wo_install_dep | tee -ai $wo_install_log
2019-03-15 19:27:36 +01:00
wo_sync_db >> $wo_install_log 2>&1
secure_wo_db | tee -ai $wo_install_log
2018-11-13 21:55:59 +01:00
wo_install | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log
2018-11-13 21:55:59 +01:00
wo_update_latest | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
2018-11-13 21:55:59 +01:00
wo_git_init | tee -ai $wo_install_log
wo_update_wp_cli | tee -ai $wo_install_log
else
wo_lib_error "Not updating WordOps to $wo_version_new, exit status = " 1
fi
else
wo_lib_error "You already have WordOps $wo_version_new, exit status = " 1
fi
2019-03-05 17:03:23 +01:00
else
# 2 - Migration from EEv3
if [ -x /usr/local/bin/ee ]; then
ee -v 2>&1 | grep $wo_version_new &>> /dev/null
if [[ $? -ne 0 ]];then
read -p "Update WordOps to $wo_version_new (y/n): " wo_ans
if [ "$wo_ans" = "y" ] || [ "$wo_ans" = "Y" ]; then
wo_install_dep | tee -ai $wo_install_log
2019-03-15 19:27:36 +01:00
wo_sync_db >> $wo_install_log 2>&1
secure_wo_db | tee -ai $wo_install_log
2019-03-05 17:03:23 +01:00
wo_install | tee -ai $wo_install_log
wo_upgrade_nginx | tee -ai $wo_install_log
2019-03-05 17:03:23 +01:00
wo_update_latest | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
2019-03-05 17:03:23 +01:00
wo_git_init | tee -ai $wo_install_log
service nginx reload &>> /dev/null
wo_update_wp_cli | tee -ai $wo_install_log
else
wo_lib_error "Not updating WordOps to $wo_version_new, exit status = " 1
fi
else
wo_lib_error "You already have WordOps $wo_version_new, exit status = " 1
fi
else
# 3 - Fresh WO setup
2019-03-08 00:37:36 +01:00
wo_lib_echo "Installing wo dependencies " | tee -ai $wo_install_log
2019-03-05 17:03:23 +01:00
wo_install_dep | tee -ai $wo_install_log
2019-03-08 00:37:36 +01:00
wo_lib_echo "Installing WordOps " | tee -ai $wo_install_log
2019-03-05 17:03:23 +01:00
wo_install | tee -ai $wo_install_log
2019-03-08 00:37:36 +01:00
wo_lib_echo "Running post-install steps " | tee -ai $wo_install_log
2019-03-07 18:02:46 +01:00
secure_wo_db | tee -ai $wo_install_log
2019-03-05 17:03:23 +01:00
wo_git_init | tee -ai $wo_install_log
wo_install_acme_sh | tee -ai $wo_install_log
2019-03-05 17:03:23 +01:00
wo_update_wp_cli | tee -ai $wo_install_log
fi
2018-11-13 21:55:59 +01:00
fi
2018-12-03 20:17:22 +01:00
2019-03-15 19:27:36 +01:00
wo sync | tee -ai $wo_install_log
2018-11-13 21:55:59 +01:00
2018-12-03 20:17:22 +01:00
if [ "$migration" -eq "1" ]; then
echo
wo_lib_echo "The migration from EasyEngine to WordOps was succesfull!"
wo_lib_echo "The EasyEngine backup files can be found in /var/lib/wo/ee-backup.tgz"
echo
wo_lib_echo_info "For autocompletion, run the following command:"
wo_lib_echo_info "source /etc/bash_completion.d/wo_auto.rc"
echo
wo_lib_echo "WordOps (wo) help: https://wordops.org/docs"
else
echo
wo_lib_echo "For WordOps (wo) auto completion, run the following command"
echo
wo_lib_echo_info "source /etc/bash_completion.d/wo_auto.rc"
echo
wo_lib_echo "Yay! WordOps (wo) installed/updated successfully"
wo_lib_echo "WordOps (wo) help: https://wordops.org/docs"
2019-02-21 21:17:54 +01:00
fi