Refactor wo update
This commit is contained in:
@@ -23,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
- Added `/var/lib/php/sessions/` to open_basedir to allow php sessions storage
|
- Added `/var/lib/php/sessions/` to open_basedir to allow php sessions storage
|
||||||
- WordOps now check if a repository already exist before trying to adding it again.
|
- WordOps now check if a repository already exist before trying to adding it again.
|
||||||
- Improved SSL certificate error messages by displaying domain IP and server IP
|
- Improved SSL certificate error messages by displaying domain IP and server IP
|
||||||
|
- Version check before updating WordOps with `wo update` is now directly handled by `wo`
|
||||||
|
- Refactored WordOps download function with python3-requests
|
||||||
|
|
||||||
#### Fixed
|
#### Fixed
|
||||||
|
|
||||||
|
|||||||
45
install
45
install
@@ -483,22 +483,22 @@ wo_upgrade_nginx() {
|
|||||||
if [ -n "$CHECK_NGINX_EE" ]; then
|
if [ -n "$CHECK_NGINX_EE" ]; then
|
||||||
if [ -x /usr/local/bin/wo ]; then
|
if [ -x /usr/local/bin/wo ]; then
|
||||||
[ -f /etc/apt/preferences.d/nginx-block ] && { mv /etc/apt/preferences.d/nginx-block /var/lib/wo/tmp/nginx-block; }
|
[ -f /etc/apt/preferences.d/nginx-block ] && { mv /etc/apt/preferences.d/nginx-block /var/lib/wo/tmp/nginx-block; }
|
||||||
# stop nginx
|
# stop nginx
|
||||||
service nginx stop
|
service nginx stop
|
||||||
# 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 autoremove nginx-ee nginx-common nginx-custom --allow-change-held-packages --purge -qq
|
apt-get autoremove nginx-ee nginx-common nginx-custom --allow-change-held-packages --purge -qq
|
||||||
# remove previous php-fpm pool configuration
|
# remove previous php-fpm pool configuration
|
||||||
if [ -n "$CHECK_PHP72" ]; then
|
if [ -n "$CHECK_PHP72" ]; then
|
||||||
apt-get purge php7.2-fpm -y -qq
|
apt-get purge php7.2-fpm -y -qq
|
||||||
rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
|
rm -f /etc/php/7.2/fpm/pool.d/{www.conf,www-two.conf,debug.conf}
|
||||||
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/htpasswd-wo
|
rm -f /etc/nginx/common/acl.conf /etc/nginx/htpasswd-wo
|
||||||
/usr/bin/rsync -au --noatime /var/lib/wo-backup/nginx/ /etc/nginx/
|
/usr/bin/rsync -au --noatime /var/lib/wo-backup/nginx/ /etc/nginx/
|
||||||
/usr/local/bin/wo stack upgrade --nginx --force
|
/usr/local/bin/wo stack upgrade --nginx --force
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -506,9 +506,9 @@ wo_upgrade_nginx() {
|
|||||||
# restore sites and configuration
|
# restore sites and configuration
|
||||||
[ -f /etc/nginx/htpasswd-ee ] && { cp -f /etc/nginx/htpasswd-ee /etc/nginx/htpasswd-wo; }
|
[ -f /etc/nginx/htpasswd-ee ] && { cp -f /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/*
|
||||||
sed -i "s/locations-php71.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
sed -i "s/locations-php71.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
||||||
sed -i "s/locations-php72.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
sed -i "s/locations-php72.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
||||||
sed -i "s/locations-php73.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
sed -i "s/locations-php73.conf/locations-wo.conf/" /etc/nginx/sites-available/*
|
||||||
sed -i "s/htpasswd-ee/htpasswd-wo/" /etc/nginx/common/acl.conf
|
sed -i "s/htpasswd-ee/htpasswd-wo/" /etc/nginx/common/acl.conf
|
||||||
sed -i 's/ssl on;/#ssl on;/' /var/www/*/conf/nginx/ssl.conf
|
sed -i 's/ssl on;/#ssl on;/' /var/www/*/conf/nginx/ssl.conf
|
||||||
@@ -653,14 +653,17 @@ wo_init() {
|
|||||||
if ! command_exists lsb_release; then
|
if ! command_exists lsb_release; then
|
||||||
apt-get install lsb-release -qq
|
apt-get install lsb-release -qq
|
||||||
fi
|
fi
|
||||||
|
if ! command_exists jq; then
|
||||||
|
apt-get install jq -qq
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ "$wo_force_install" = "y" ]; then
|
if [ "$wo_force_install" = "y" ]; then
|
||||||
[ ! -f "$HOME/.gitconfig" ] && { bash -c 'echo -e "[user]\n\tname = $USER\n\temail = root@$HOSTNAME.local" > $HOME/.gitconfig'; }
|
[ ! -f "$HOME/.gitconfig" ] && { bash -c 'echo -e "[user]\n\tname = $USER\n\temail = root@$HOSTNAME.local" > $HOME/.gitconfig'; }
|
||||||
fi
|
fi
|
||||||
if [ -f ./setup.py ]; then
|
if [ -f ./setup.py ]; then
|
||||||
readonly wo_version_new=$(grep "version='" setup.py | awk -F "'" '{print$2}' 2>&1)
|
readonly wo_version_new=$(grep "version='" setup.py | awk -F "'" '{print $2}' 2>&1)
|
||||||
else
|
else
|
||||||
readonly wo_version_new=$(curl -m 5 --retry 3 -sI https://github.com/WordOps/WordOps/releases/latest | grep tag | awk -F "/" '{print $8}' 2>&1)
|
readonly wo_version_new=$(curl -m 5 --retry 3 -sL https://api.github.com/repos/WordOps/WordOps/releases/latest | jq -r '.tag_name' 2>&1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -27,7 +27,7 @@ if os.geteuid() == 0:
|
|||||||
os.makedirs('/var/lib/wo/tmp/')
|
os.makedirs('/var/lib/wo/tmp/')
|
||||||
|
|
||||||
setup(name='wordops',
|
setup(name='wordops',
|
||||||
version='3.9.9.4',
|
version='3.10.0',
|
||||||
description='An essential toolset that eases server administration',
|
description='An essential toolset that eases server administration',
|
||||||
long_description=LONG,
|
long_description=LONG,
|
||||||
long_description_content_type='text/markdown',
|
long_description_content_type='text/markdown',
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import os
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from cement.core.controller import CementBaseController, expose
|
from cement.core.controller import CementBaseController, expose
|
||||||
|
from requests import RequestException, get, json
|
||||||
from wo.core.download import WODownload
|
from wo.core.download import WODownload
|
||||||
from wo.core.logging import Log
|
from wo.core.logging import Log
|
||||||
|
from wo.core.variables import WOVar
|
||||||
|
|
||||||
|
|
||||||
def wo_update_hook(app):
|
def wo_update_hook(app):
|
||||||
@@ -43,6 +44,23 @@ class WOUpdateController(CementBaseController):
|
|||||||
def default(self):
|
def default(self):
|
||||||
pargs = self.app.pargs
|
pargs = self.app.pargs
|
||||||
filename = "woupdate" + time.strftime("%Y%m%d-%H%M%S")
|
filename = "woupdate" + time.strftime("%Y%m%d-%H%M%S")
|
||||||
|
|
||||||
|
wo_current = WOVar.wo_version
|
||||||
|
try:
|
||||||
|
wo_github_latest = get(
|
||||||
|
'https://api.github.com/repos/WordOps/WordOps/releases/latest',
|
||||||
|
timeout=(5, 30)).json()
|
||||||
|
except RequestException:
|
||||||
|
Log.debug(
|
||||||
|
self, "Request to GitHub API failed. "
|
||||||
|
"Switching to Gitea instance")
|
||||||
|
wo_github_latest = get(
|
||||||
|
'https://git.virtubox.net/api/v1/repos/virtubox/WordOps/tags',
|
||||||
|
timeout=(5, 30)).json()
|
||||||
|
wo_latest = wo_github_latest[0]["name"]
|
||||||
|
else:
|
||||||
|
wo_latest = wo_github_latest["tag_name"]
|
||||||
|
|
||||||
install_args = ""
|
install_args = ""
|
||||||
if pargs.mainline or pargs.beta:
|
if pargs.mainline or pargs.beta:
|
||||||
wo_branch = "mainline"
|
wo_branch = "mainline"
|
||||||
@@ -52,6 +70,12 @@ class WOUpdateController(CementBaseController):
|
|||||||
wo_branch = "master"
|
wo_branch = "master"
|
||||||
if pargs.force:
|
if pargs.force:
|
||||||
install_args = install_args + "--force "
|
install_args = install_args + "--force "
|
||||||
|
else:
|
||||||
|
if not pargs.travis:
|
||||||
|
if wo_current == wo_latest:
|
||||||
|
Log.error(
|
||||||
|
self, "WordOps {0} is already installed"
|
||||||
|
.format(wo_latest))
|
||||||
|
|
||||||
if not os.path.isdir('/var/lib/wo/tmp'):
|
if not os.path.isdir('/var/lib/wo/tmp'):
|
||||||
os.makedirs('/var/lib/wo/tmp')
|
os.makedirs('/var/lib/wo/tmp')
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class WODownload():
|
|||||||
os.makedirs(directory)
|
os.makedirs(directory)
|
||||||
Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ')
|
Log.info(self, "Downloading {0:20}".format(pkg_name), end=' ')
|
||||||
with open(filename, "wb") as out_file:
|
with open(filename, "wb") as out_file:
|
||||||
req = get(url, timeout=15)
|
req = get(url, timeout=(5, 30))
|
||||||
if req.encoding is None:
|
if req.encoding is None:
|
||||||
req.encoding = 'utf-8'
|
req.encoding = 'utf-8'
|
||||||
out_file.write(req.content)
|
out_file.write(req.content)
|
||||||
@@ -34,3 +34,4 @@ class WODownload():
|
|||||||
Log.error(self, "Unable to download file, {0}"
|
Log.error(self, "Unable to download file, {0}"
|
||||||
.format(filename))
|
.format(filename))
|
||||||
return False
|
return False
|
||||||
|
return 0
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class WOVar():
|
|||||||
"""Intialization of core variables"""
|
"""Intialization of core variables"""
|
||||||
|
|
||||||
# WordOps version
|
# WordOps version
|
||||||
wo_version = "3.9.9.4"
|
wo_version = "3.10.0"
|
||||||
# WordOps packages versions
|
# WordOps packages versions
|
||||||
wo_wp_cli = "2.3.0"
|
wo_wp_cli = "2.3.0"
|
||||||
wo_adminer = "4.7.3"
|
wo_adminer = "4.7.3"
|
||||||
|
|||||||
Reference in New Issue
Block a user