Add wo stack upgrade --ngxblocker
This commit is contained in:
@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
- Redis 5.0.6 package backported to Debian 8/9/10
|
- Redis 5.0.6 package backported to Debian 8/9/10
|
||||||
- Custom motd to display a message if a new WordOps release is available
|
- Custom motd to display a message if a new WordOps release is available
|
||||||
- Run `mysql_upgrade` during MySQL upgrade with `wo stack upgrade` to perform migration if needed
|
- Run `mysql_upgrade` during MySQL upgrade with `wo stack upgrade` to perform migration if needed
|
||||||
|
- `wo stack upgrade --ngxblocker` to update ngxblocker blocklist
|
||||||
|
|
||||||
#### Changed
|
#### Changed
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
- MySQL backup path changed to `/var/lib/wo-backup/mysql`
|
- MySQL backup path changed to `/var/lib/wo-backup/mysql`
|
||||||
- Do not check anymore if stack are installed with apt in `wo service` but only if there is a systemd service
|
- Do not check anymore if stack are installed with apt in `wo service` but only if there is a systemd service
|
||||||
- Refactored `--letsencrypt=renew`. Require the flag `--force` if certificate expiration is more than 45 days
|
- Refactored `--letsencrypt=renew`. Require the flag `--force` if certificate expiration is more than 45 days
|
||||||
|
- Improve netdata stack upgrade with install from source detection and updater fallback
|
||||||
|
|
||||||
#### Fixed
|
#### Fixed
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ if [ -z "$1" ]; then
|
|||||||
echo -e "${CGREEN}#############################################${CEND}"
|
echo -e "${CGREEN}#############################################${CEND}"
|
||||||
echo -e ' wo stack upgrade '
|
echo -e ' wo stack upgrade '
|
||||||
echo -e "${CGREEN}#############################################${CEND}"
|
echo -e "${CGREEN}#############################################${CEND}"
|
||||||
stack_upgrade='nginx php php73 mysql redis netdata dashboard phpmyadmin composer'
|
stack_upgrade='nginx php php73 mysql redis netdata dashboard phpmyadmin composer ngxblocker'
|
||||||
for stack in $stack_upgrade; do
|
for stack in $stack_upgrade; do
|
||||||
echo -ne " Upgrading $stack [..]\r"
|
echo -ne " Upgrading $stack [..]\r"
|
||||||
if {
|
if {
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
dict(help='Upgrade Composer', action='store_true')),
|
dict(help='Upgrade Composer', action='store_true')),
|
||||||
(['--phpmyadmin'],
|
(['--phpmyadmin'],
|
||||||
dict(help='Upgrade phpMyAdmin', action='store_true')),
|
dict(help='Upgrade phpMyAdmin', action='store_true')),
|
||||||
|
(['--ngxblocker'],
|
||||||
|
dict(help='Upgrade phpMyAdmin', action='store_true')),
|
||||||
(['--no-prompt'],
|
(['--no-prompt'],
|
||||||
dict(help="Upgrade Packages without any prompt",
|
dict(help="Upgrade Packages without any prompt",
|
||||||
action='store_true')),
|
action='store_true')),
|
||||||
@@ -70,24 +72,29 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
(not pargs.phpmyadmin) and (not pargs.dashboard) and
|
(not pargs.phpmyadmin) and (not pargs.dashboard) and
|
||||||
(not pargs.redis)):
|
(not pargs.redis)):
|
||||||
pargs.web = True
|
pargs.web = True
|
||||||
|
pargs.admin = True
|
||||||
|
|
||||||
if pargs.all:
|
if pargs.all:
|
||||||
pargs.web = True
|
pargs.web = True
|
||||||
pargs.netdata = True
|
pargs.admin = True
|
||||||
pargs.composer = True
|
|
||||||
pargs.dashboard = True
|
|
||||||
pargs.phpmyadmin = True
|
|
||||||
pargs.redis = True
|
pargs.redis = True
|
||||||
pargs.wpcli = True
|
|
||||||
pargs.php73 = True
|
pargs.php73 = True
|
||||||
|
pargs.ngxblocker = True
|
||||||
|
|
||||||
if pargs.web:
|
if pargs.web:
|
||||||
if WOAptGet.is_installed(self, 'nginx-custom'):
|
pargs.nginx = True
|
||||||
pargs.nginx = True
|
|
||||||
pargs.php = True
|
pargs.php = True
|
||||||
pargs.mysql = True
|
pargs.mysql = True
|
||||||
pargs.wpcli = True
|
pargs.wpcli = True
|
||||||
|
|
||||||
|
if pargs.admin:
|
||||||
|
pargs.netdata = True
|
||||||
|
pargs.composer = True
|
||||||
|
pargs.dashboard = True
|
||||||
|
pargs.phpmyadmin = True
|
||||||
|
pargs.wpcli = True
|
||||||
|
|
||||||
|
# nginx
|
||||||
if pargs.nginx:
|
if pargs.nginx:
|
||||||
if WOAptGet.is_installed(self, 'nginx-custom'):
|
if WOAptGet.is_installed(self, 'nginx-custom'):
|
||||||
apt_packages = apt_packages + WOVar.wo_nginx
|
apt_packages = apt_packages + WOVar.wo_nginx
|
||||||
@@ -98,6 +105,7 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "Nginx Stable is not already installed")
|
Log.info(self, "Nginx Stable is not already installed")
|
||||||
|
|
||||||
|
# php 7.2
|
||||||
if pargs.php:
|
if pargs.php:
|
||||||
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
if WOAptGet.is_installed(self, 'php7.2-fpm'):
|
||||||
apt_packages = apt_packages + WOVar.wo_php + \
|
apt_packages = apt_packages + WOVar.wo_php + \
|
||||||
@@ -105,6 +113,7 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "PHP 7.2 is not installed")
|
Log.info(self, "PHP 7.2 is not installed")
|
||||||
|
|
||||||
|
# php 7.3
|
||||||
if pargs.php73:
|
if pargs.php73:
|
||||||
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
if WOAptGet.is_installed(self, 'php7.3-fpm'):
|
||||||
apt_packages = apt_packages + WOVar.wo_php73 + \
|
apt_packages = apt_packages + WOVar.wo_php73 + \
|
||||||
@@ -112,18 +121,21 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "PHP 7.3 is not installed")
|
Log.info(self, "PHP 7.3 is not installed")
|
||||||
|
|
||||||
|
# mysql
|
||||||
if pargs.mysql:
|
if pargs.mysql:
|
||||||
if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
|
if WOShellExec.cmd_exec(self, 'mysqladmin ping'):
|
||||||
apt_packages = apt_packages + ['mariadb-server']
|
apt_packages = apt_packages + ['mariadb-server']
|
||||||
else:
|
else:
|
||||||
Log.info(self, "MariaDB is not installed")
|
Log.info(self, "MariaDB is not installed")
|
||||||
|
|
||||||
|
# redis
|
||||||
if pargs.redis:
|
if pargs.redis:
|
||||||
if WOAptGet.is_installed(self, 'redis-server'):
|
if WOAptGet.is_installed(self, 'redis-server'):
|
||||||
apt_packages = apt_packages + ['redis-server']
|
apt_packages = apt_packages + ['redis-server']
|
||||||
else:
|
else:
|
||||||
Log.info(self, "Redis is not installed")
|
Log.info(self, "Redis is not installed")
|
||||||
|
|
||||||
|
# wp-cli
|
||||||
if pargs.wpcli:
|
if pargs.wpcli:
|
||||||
if os.path.isfile('/usr/local/bin/wp'):
|
if os.path.isfile('/usr/local/bin/wp'):
|
||||||
packages = packages + [[
|
packages = packages + [[
|
||||||
@@ -135,37 +147,48 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "WPCLI is not installed with WordOps")
|
Log.info(self, "WPCLI is not installed with WordOps")
|
||||||
|
|
||||||
|
# netdata
|
||||||
if pargs.netdata:
|
if pargs.netdata:
|
||||||
if (os.path.isdir('/opt/netdata') or
|
# detect static binaries install
|
||||||
os.path.isdir('/etc/netdata')):
|
if os.path.isdir('/opt/netdata'):
|
||||||
packages = packages + [['https://my-netdata.io/'
|
packages = packages + [[
|
||||||
'kickstart-static64.sh',
|
'https://my-netdata.io/kickstart-static64.sh',
|
||||||
'/var/lib/wo/tmp/kickstart.sh',
|
'/var/lib/wo/tmp/kickstart.sh', 'Netdata']]
|
||||||
'Netdata']]
|
# detect install from source
|
||||||
|
elif os.path.isdir('/etc/netdata'):
|
||||||
|
packages = packages + [[
|
||||||
|
'https://my-netdata.io/kickstart.sh',
|
||||||
|
'/var/lib/wo/tmp/kickstart.sh', 'Netdata']]
|
||||||
|
else:
|
||||||
|
Log.info(self, 'Netdata us not installed')
|
||||||
|
|
||||||
|
# wordops dashboard
|
||||||
if pargs.dashboard:
|
if pargs.dashboard:
|
||||||
if (os.path.isfile('/var/www/22222/htdocs/index.php') or
|
if (os.path.isfile('/var/www/22222/htdocs/index.php') or
|
||||||
os.path.isfile('/var/www/22222/htdocs/index.html')):
|
os.path.isfile('/var/www/22222/htdocs/index.html')):
|
||||||
packages = packages + \
|
packages = packages + [[
|
||||||
[["https://github.com/WordOps/wordops-dashboard/"
|
"https://github.com/WordOps/wordops-dashboard/"
|
||||||
"releases/download/v{0}/wordops-dashboard.tar.gz"
|
"releases/download/v{0}/wordops-dashboard.tar.gz"
|
||||||
.format(WOVar.wo_dashboard),
|
.format(WOVar.wo_dashboard),
|
||||||
"/var/lib/wo/tmp/wo-dashboard.tar.gz",
|
"/var/lib/wo/tmp/wo-dashboard.tar.gz",
|
||||||
"WordOps Dashboard"]]
|
"WordOps Dashboard"]]
|
||||||
|
else:
|
||||||
|
Log.info(self, 'WordOps dashboard is not installed')
|
||||||
|
|
||||||
|
# phpmyadmin
|
||||||
if pargs.phpmyadmin:
|
if pargs.phpmyadmin:
|
||||||
if os.path.isdir('/var/www/22222/htdocs/db/pma'):
|
if os.path.isdir('/var/www/22222/htdocs/db/pma'):
|
||||||
packages = packages + \
|
packages = packages + [[
|
||||||
[["https://files.phpmyadmin.net"
|
"https://files.phpmyadmin.net"
|
||||||
"/phpMyAdmin/{0}/"
|
"/phpMyAdmin/{0}/phpMyAdmin-{0}-"
|
||||||
"phpMyAdmin-{0}-"
|
"all-languages.tar.gz"
|
||||||
"all-languages"
|
.format(WOVar.wo_phpmyadmin),
|
||||||
".tar.gz".format(WOVar.wo_phpmyadmin),
|
"/var/lib/wo/tmp/pma.tar.gz",
|
||||||
"/var/lib/wo/tmp/pma.tar.gz",
|
"PHPMyAdmin"]]
|
||||||
"PHPMyAdmin"]]
|
|
||||||
else:
|
else:
|
||||||
Log.info(self, "phpMyAdmin isn't installed")
|
Log.info(self, "phpMyAdmin isn't installed")
|
||||||
|
|
||||||
|
# composer
|
||||||
if pargs.composer:
|
if pargs.composer:
|
||||||
if os.path.isfile('/usr/local/bin/composer'):
|
if os.path.isfile('/usr/local/bin/composer'):
|
||||||
packages = packages + [[
|
packages = packages + [[
|
||||||
@@ -175,6 +198,18 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
else:
|
else:
|
||||||
Log.info(self, "Composer isn't installed")
|
Log.info(self, "Composer isn't installed")
|
||||||
|
|
||||||
|
# ngxblocker
|
||||||
|
if pargs.ngxblocker:
|
||||||
|
if os.path.exists('/usr/local/sbin/update-ngxblocker'):
|
||||||
|
packages = packages + [[
|
||||||
|
'https://raw.githubusercontent.com/mitchellkrogza/'
|
||||||
|
'nginx-ultimate-bad-bot-blocker/master/update-ngxblocker',
|
||||||
|
'/usr/local/sbin/update-ngxblocker',
|
||||||
|
'ngxblocker'
|
||||||
|
]]
|
||||||
|
else:
|
||||||
|
Log.info(self, "ngxblocker is not installed")
|
||||||
|
|
||||||
if ((not (apt_packages)) and (not(packages))):
|
if ((not (apt_packages)) and (not(packages))):
|
||||||
self.app.args.print_help()
|
self.app.args.print_help()
|
||||||
else:
|
else:
|
||||||
@@ -198,7 +233,6 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
# apt-get update
|
# apt-get update
|
||||||
WOAptGet.update(self)
|
WOAptGet.update(self)
|
||||||
Log.valide(self, "Updating APT packages")
|
Log.valide(self, "Updating APT packages")
|
||||||
Log.wait(self, "Upgrading APT Packages")
|
|
||||||
|
|
||||||
# additional pre_pref
|
# additional pre_pref
|
||||||
if "nginx-custom" in apt_packages:
|
if "nginx-custom" in apt_packages:
|
||||||
@@ -215,7 +249,6 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
post_pref(self, WOVar.wo_nginx, [], True)
|
post_pref(self, WOVar.wo_nginx, [], True)
|
||||||
# upgrade packages
|
# upgrade packages
|
||||||
WOAptGet.install(self, apt_packages)
|
WOAptGet.install(self, apt_packages)
|
||||||
Log.valide(self, "Upgrading APT Packages")
|
|
||||||
Log.wait(self, "Configuring APT Packages")
|
Log.wait(self, "Configuring APT Packages")
|
||||||
post_pref(self, apt_packages, [], True)
|
post_pref(self, apt_packages, [], True)
|
||||||
if "mariadb-server" in apt_packages:
|
if "mariadb-server" in apt_packages:
|
||||||
@@ -230,6 +263,9 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
if pargs.netdata:
|
if pargs.netdata:
|
||||||
WOFileUtils.rm(self, '/var/lib/wo/tmp/kickstart.sh')
|
WOFileUtils.rm(self, '/var/lib/wo/tmp/kickstart.sh')
|
||||||
|
|
||||||
|
if pargs.ngxblocker:
|
||||||
|
WOFileUtils.rm(self, '/usr/local/sbin/update-ngxblocker')
|
||||||
|
|
||||||
if pargs.dashboard:
|
if pargs.dashboard:
|
||||||
if os.path.isfile('/var/www/22222/htdocs/index.php'):
|
if os.path.isfile('/var/www/22222/htdocs/index.php'):
|
||||||
WOFileUtils.rm(self, '/var/www/22222/htdocs/index.php')
|
WOFileUtils.rm(self, '/var/www/22222/htdocs/index.php')
|
||||||
@@ -243,18 +279,38 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
if pargs.wpcli:
|
if pargs.wpcli:
|
||||||
WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775)
|
WOFileUtils.chmod(self, "/usr/local/bin/wp", 0o775)
|
||||||
|
|
||||||
|
if pargs.ngxblocker:
|
||||||
|
WOFileUtils.chmod(
|
||||||
|
self, '/usr/local/sbin/update-ngxblocker', 0o700)
|
||||||
|
WOShellExec.chmod(
|
||||||
|
self, '/usr/local/sbin/update-ngxblocker -nq'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Netdata
|
||||||
if pargs.netdata:
|
if pargs.netdata:
|
||||||
Log.wait(self, "Upgrading Netdata")
|
Log.wait(self, "Upgrading Netdata")
|
||||||
|
# detect static binaries install
|
||||||
if os.path.isdir('/opt/netdata'):
|
if os.path.isdir('/opt/netdata'):
|
||||||
WOShellExec.cmd_exec(
|
if os.path.exists(
|
||||||
self, "bash /opt/netdata/usr/"
|
'/opt/netdata/usr/libexec/'
|
||||||
"libexec/netdata/netdata-"
|
'netdata/netdata-updater.sh'):
|
||||||
"updater.sh")
|
WOShellExec.cmd_exec(
|
||||||
|
self, "bash /opt/netdata/usr/"
|
||||||
|
"libexec/netdata/netdata-"
|
||||||
|
"updater.sh")
|
||||||
|
else:
|
||||||
|
WOShellExec.cmd_exec(
|
||||||
|
self, "bash /var/lib/wo/tmp/kickstart.sh")
|
||||||
|
# detect install from source
|
||||||
elif os.path.isdir('/etc/netdata'):
|
elif os.path.isdir('/etc/netdata'):
|
||||||
WOShellExec.cmd_exec(
|
if os.path.exists(
|
||||||
self, "bash /usr/"
|
'/usr/libexec/netdata/netdata-updater.sh'):
|
||||||
"libexec/netdata/netdata-"
|
WOShellExec.cmd_exec(
|
||||||
"updater.sh")
|
self,
|
||||||
|
'bash /usr/libexec/netdata/netdata-updater.sh')
|
||||||
|
else:
|
||||||
|
WOShellExec.cmd_exec(
|
||||||
|
self, "bash /var/lib/wo/tmp/kickstart.sh")
|
||||||
Log.valide(self, "Upgrading Netdata")
|
Log.valide(self, "Upgrading Netdata")
|
||||||
|
|
||||||
if pargs.dashboard:
|
if pargs.dashboard:
|
||||||
@@ -269,10 +325,12 @@ class WOStackUpgradeController(CementBaseController):
|
|||||||
|
|
||||||
if pargs.composer:
|
if pargs.composer:
|
||||||
Log.wait(self, "Upgrading Composer")
|
Log.wait(self, "Upgrading Composer")
|
||||||
WOShellExec.cmd_exec(
|
if WOShellExec.cmd_exec(
|
||||||
self, "php -q /var/lib/wo"
|
self, '/usr/bin/php -v'):
|
||||||
"/tmp/composer-install "
|
WOShellExec.cmd_exec(
|
||||||
"--install-dir=/var/lib/wo/tmp/")
|
self, "php -q /var/lib/wo"
|
||||||
|
"/tmp/composer-install "
|
||||||
|
"--install-dir=/var/lib/wo/tmp/")
|
||||||
shutil.copyfile('/var/lib/wo/tmp/composer.phar',
|
shutil.copyfile('/var/lib/wo/tmp/composer.phar',
|
||||||
'/usr/local/bin/composer')
|
'/usr/local/bin/composer')
|
||||||
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
|
WOFileUtils.chmod(self, "/usr/local/bin/composer", 0o775)
|
||||||
|
|||||||
Reference in New Issue
Block a user