update migration script
This commit is contained in:
182
install
182
install
@@ -10,7 +10,7 @@
|
||||
# Version 3.9.4 - 2019-03-15
|
||||
# -------------------------------------------------------------------------
|
||||
readonly wo_version_old="2.2.3"
|
||||
readonly wo_version_new="3.9.4.1"
|
||||
readonly wo_version_new="3.9.4.2"
|
||||
# CONTENTS
|
||||
# ---
|
||||
# 1. VARIABLES AND DECLARATIONS
|
||||
@@ -29,7 +29,7 @@ TPUT_ECHO=$(tput setaf 4)
|
||||
|
||||
wo_lib_echo () {
|
||||
|
||||
echo "${*}${TPUT_RESET}"
|
||||
echo "${TPUT_ECHO}${*}${TPUT_RESET}"
|
||||
}
|
||||
|
||||
wo_lib_echo_info()
|
||||
@@ -71,7 +71,7 @@ echo ""
|
||||
# 1- Update the apt sewers with fresh 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
|
||||
@@ -91,7 +91,7 @@ readonly wo_linux_distro=$(lsb_release -is)
|
||||
readonly wo_distro_version=$(lsb_release -sc)
|
||||
readonly wo_distro_id=$(lsb_release -rs)
|
||||
|
||||
if [ -x /usr/loca/bin/ee ]; then
|
||||
if [ -x /usr/local/bin/ee ]; then
|
||||
migration=1
|
||||
else
|
||||
migration=0
|
||||
@@ -116,10 +116,10 @@ fi
|
||||
###
|
||||
# 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..."
|
||||
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}
|
||||
|
||||
@@ -134,10 +134,10 @@ wo_install_dep()
|
||||
|
||||
{
|
||||
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
|
||||
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
|
||||
|
||||
locale-gen en
|
||||
@@ -383,70 +383,83 @@ wo_install()
|
||||
|
||||
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)
|
||||
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
|
||||
|
||||
{
|
||||
# create backup directory
|
||||
mkdir -p /var/lib/wo/backup
|
||||
|
||||
# backup all sites available
|
||||
/usr/bin/rsync -az /etc/nginx/ /var/lib/wo/backup/nginx/
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
if [ -n "$CHECK_NGINX_EE" ]; then
|
||||
# remove previous package
|
||||
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
|
||||
# backup nginx conf
|
||||
cd /etc || exit 1
|
||||
tar -I pigz -cf backup-nginx.tar.gz nginx
|
||||
cd || exit 1
|
||||
rm -f /etc/nginx/conf.d/{upstream.conf,redis.conf,fastcgi.conf}
|
||||
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/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
|
||||
apt-get -y -qq autoremove nginx-ee nginx-common nginx-custom --purge
|
||||
elif [ -n "$CHECK_NGINX_WO" ]; then
|
||||
apt-mark unhold nginx-wo nginx-common nginx-custom
|
||||
apt-get -y -qq autoremove nginx-wo nginx-common nginx-custom --purge
|
||||
fi
|
||||
# remove previous php-fpm pool configuration
|
||||
if [ -n "$CHECK_PHP72" ]; then
|
||||
apt-get remove php7.2-fpm -y -qq --purge
|
||||
rm -f /etc/php/7.2/fpm/pool.d/*
|
||||
fi
|
||||
if [ -n "$CHECK_PHP73" ]; then
|
||||
apt-get remove php7.3-fpm -y -qq --purge
|
||||
rm -f /etc/php/7.3/fpm/pool.d/*
|
||||
fi
|
||||
|
||||
# install new nginx package
|
||||
if [ -x /usr/local/bin/wo ]; then
|
||||
/usr/local/bin/wo stack install --nginx --php --php73
|
||||
fi
|
||||
|
||||
# restore sites and configuration
|
||||
/usr/bin/rsync -auz /var/lib/wo/backup/nginx/ /etc/nginx/
|
||||
|
||||
# set back apt preference
|
||||
[ -f "$HOME/nginx-block" ] && {
|
||||
mv "$HOME/nginx-block" /etc/apt/preferences.d/nginx-block
|
||||
}
|
||||
# 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
|
||||
|
||||
}
|
||||
|
||||
wo_update_latest()
|
||||
@@ -472,28 +485,21 @@ wo_update_latest()
|
||||
fi
|
||||
|
||||
# Move ~/.my.cnf to /etc/mysql/conf.d/my.cnf
|
||||
if [ ! -f /etc/mysql/conf.d/my.cnf ]
|
||||
then
|
||||
if [ ! -f /etc/mysql/conf.d/my.cnf ]; then
|
||||
# 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
|
||||
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
|
||||
}
|
||||
if [ -f $HOME/.my.cnf ]; then
|
||||
cp ~/.my.cnf /etc/mysql/conf.d/my.cnf &>> /dev/null
|
||||
chmod 600 /etc/mysql/conf.d/my.cnf
|
||||
|
||||
elif [ -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
|
||||
|
||||
|
||||
@@ -294,14 +294,14 @@ def setupwordpress(self, data):
|
||||
if not data['multisite']:
|
||||
Log.debug(self, "Generating wp-config for WordPress Single site")
|
||||
Log.debug(self, "bash -c \"php {0} --allow-root "
|
||||
.format(WOVariables.wo_wpcli_path)
|
||||
+ "core config "
|
||||
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
|
||||
.format(WOVariables.wo_wpcli_path) +
|
||||
"core config " +
|
||||
"--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
|
||||
"--dbhost=\'{3}\' "
|
||||
.format(data['wo_db_name'], wo_wp_prefix,
|
||||
data['wo_db_user'], data['wo_db_host'])
|
||||
+ "--dbpass=\'{0}\' "
|
||||
"--extra-php<<PHP \n {1}\nPHP\""
|
||||
data['wo_db_user'], data['wo_db_host']) +
|
||||
"--dbpass=\'{0}\' "
|
||||
"--extra-php<<PHP \n {1}\n {2}\nPHP\""
|
||||
.format(data['wo_db_pass'],
|
||||
"\ndefine(\'CONCATENATE_SCRIPTS\',"
|
||||
" false);",
|
||||
@@ -337,7 +337,7 @@ def setupwordpress(self, data):
|
||||
+ "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
|
||||
.format(data['wo_db_name'], wo_wp_prefix, data['wo_db_host'])
|
||||
+ "--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'],
|
||||
"\ndefine(\'WPMU_ACCEL_REDIRECT\',"
|
||||
" true);",
|
||||
@@ -1195,7 +1195,6 @@ def doCleanupAction(self, domain='', webroot='', dbname='', dbuser='',
|
||||
deleteDB(self, dbname, dbuser, dbhost)
|
||||
|
||||
|
||||
|
||||
# setup letsencrypt for domain + www.domain
|
||||
def setupLetsEncrypt(self, wo_domain_name):
|
||||
|
||||
|
||||
@@ -226,14 +226,6 @@ class WOStackController(CementBaseController):
|
||||
(data), 'upstream.mustache', out=wo_nginx)
|
||||
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')):
|
||||
data = dict(phpconf=True if
|
||||
WOAptGet.is_installed(self, 'php7.2-fpm')
|
||||
@@ -256,6 +248,16 @@ class WOStackController(CementBaseController):
|
||||
out=wo_nginx)
|
||||
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
|
||||
if not os.path.exists('/etc/nginx/common'):
|
||||
Log.debug(self, 'Creating directory'
|
||||
@@ -486,8 +488,7 @@ class WOStackController(CementBaseController):
|
||||
WOGit.add(self,
|
||||
["/etc/nginx"], msg="Adding Nginx into Git")
|
||||
WOService.reload_service(self, 'nginx')
|
||||
if (set(["nginx-plus"]).issubset(set(apt_packages)) or
|
||||
set(["nginx"]).issubset(set(apt_packages))):
|
||||
if set(["nginx"]).issubset(set(apt_packages)):
|
||||
WOShellExec.cmd_exec(self, "sed -i -e 's/^user/#user/'"
|
||||
" -e '/^#user/a user"
|
||||
"\ www-data\;'"
|
||||
@@ -501,18 +502,8 @@ class WOStackController(CementBaseController):
|
||||
"\ \/etc\/nginx\/sites-enabled"
|
||||
"\/*;' /etc/nginx/nginx.conf")
|
||||
|
||||
# WordOpsconfig for NGINX plus
|
||||
data['version'] = WOVariables.wo_version
|
||||
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))
|
||||
print("HTTP Auth User Name: WordOps" +
|
||||
"\nHTTP Auth Password : {0}".format(passwd))
|
||||
WOService.reload_service(self, 'nginx')
|
||||
else:
|
||||
self.msg = (self.msg + ["HTTP Auth User "
|
||||
@@ -939,8 +930,11 @@ class WOStackController(CementBaseController):
|
||||
"profiler_enable] = off\n")
|
||||
|
||||
# Disable xdebug
|
||||
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\' /etc/php/7.3/mods-available/xdebug.ini"):
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.3/mods-available/"
|
||||
if not WOShellExec.cmd_exec(self, "grep -q \';zend_extension\'"
|
||||
" /etc/php/7.3/mods-available"
|
||||
"/xdebug.ini"):
|
||||
WOFileUtils.searchreplace(self, "/etc/php/7.3/"
|
||||
"mods-available/"
|
||||
"xdebug.ini",
|
||||
"zend_extension",
|
||||
";zend_extension")
|
||||
|
||||
Reference in New Issue
Block a user