update migration script

This commit is contained in:
VirtuBox
2019-03-20 21:59:56 +01:00
parent 8618b32f29
commit 644d86b33b
3 changed files with 159 additions and 160 deletions

182
install
View File

@@ -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
@@ -29,7 +29,7 @@ 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()
@@ -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,10 +116,10 @@ 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}
@@ -134,10 +134,10 @@ 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
@@ -383,70 +383,83 @@ wo_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)
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 # 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()
@@ -472,28 +485,21 @@ wo_update_latest()
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

View File

@@ -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):

View File

@@ -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")