Fix site url change to https

This commit is contained in:
VirtuBox
2019-07-27 21:53:52 +02:00
parent 2ae88ed7b0
commit e6a4611ee6
5 changed files with 30 additions and 20 deletions

View File

@@ -12,13 +12,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- MySQL configuration tuning - MySQL configuration tuning
- Cronjob to optimize MySQL databases weekly - Cronjob to optimize MySQL databases weekly
- wo-kernel systemd service to apply kernel tweaks on server startup - WO-kernel systemd service to automatically apply kernel tweaks on server startup
#### Changed #### Changed
- `wo maintenance` refactored - `wo maintenance` refactored
- Improved debug log - Improved debug log
- Updated Nginx configuration process to not overwrite files with custom data (htpasswd-wo, acl.conf etc..) - Updated Nginx configuration process to not overwrite files with custom data (htpasswd-wo, acl.conf etc..)
- Adminer updated to v4.7.2
- eXtplorer updated to v2.1.13
- Removed WordOps version from the Nginx header X-Powered-By to avoid possible security issues
#### Fixed #### Fixed

View File

@@ -1,19 +1,19 @@
.TH wo 8 "WordOps (wo) version: 3.3.8" "Sep 10,2015" "WordOps" .TH wo 8 "WordOps (wo) version: 3.9.6.3" "Jul 26,2019" "WordOps"
.SH NAME .SH NAME
.B WordOps (wo) .B WordOps (wo)
\- Manage Nginx Based Websites. \- Manage Nginx Based Websites.
.SH SYNOPSIS .SH SYNOPSIS
wo [ --version | --help | info | stack | site | debug | update | clean | import_slow_log | log | secure | sync | maintenance ] wo [ --version | --help | info | stack | site | debug | update | clean | import_slow_log | log | secure | sync | maintenance ]
.TP .TP
wo stack [ install | remove | purge | migrate | upgrade] [ --web | --all | --nginx | --php | --php73 | --mysql | --admin | --adminer | --redis | --phpmyadmin | --phpredisadmin | --wpcli | --utils | --dashboard | --netdata ] wo stack [ install | remove | purge | migrate | upgrade] [ --web | --all | --nginx | --php | --php73 | --mysql | --admin | --adminer | --redis | --phpmyadmin | --phpredisadmin | --wpcli | --utils | --dashboard | --netdata | --fail2ban | --proftpd ]
.TP .TP
wo stack [ status | start | stop | reload | restart ] [--all | --nginx | --php | --php73 |--mysql | --web | --redis] wo stack [ status | start | stop | reload | restart ] [--all | --nginx | --php | --php73 |--mysql | --web | --redis | --netdata | --fail2ban | --proftpd]
.TP .TP
wo site [ list | info | show | enable | disable | edit | cd | show ] [ example.com ] wo site [ list | info | show | enable | disable | edit | cd | show ] [ example.com ]
.TP .TP
wo site create example.com [ --html | --php | --php73 | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis | --letsencrypt/-le/--letsencrypt=subdomain/wildcard][--dns=dns_cf/dns_do]] wo site create example.com [ --html | --php | --php73 | --mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis | --letsencrypt/-le/--letsencrypt=subdomain/wildcard][--dns/--dns=dns_cf/dns_do]]
.TP .TP
wo site update example.com [ --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis ] [--password] [-le/--letsencrypt=on/off/subdomain/renew/wildcard] [--dns=dns_cf/dns_do]] wo site update example.com [ --php | --php73 |--mysql] [[--wp | --wpsubdir | --wpsubdomain ] [--wpsc | --wpfc | --wpredis ] [--password] [-le/--letsencrypt/--letsencrypt=on/off/subdomain/renew/wildcard/clean/purge] [--dns/--dns=dns_cf/dns_do]]
.TP .TP
wo site delete example.com [--db | --files | --all | --no-prompt | --force/-f ] wo site delete example.com [--db | --files | --all | --no-prompt | --force/-f ]
.TP .TP
@@ -46,19 +46,19 @@ Display WordOps (wo) help.
.TP .TP
.B stack .B stack
.TP .TP
.B install [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard ] .B install [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard | --fail2ban | --proftpd ]
.br .br
Install Nginx PHP5 MySQL Postfix stack Packages if not used with Install Nginx PHP5 MySQL Postfix stack Packages if not used with
.br .br
any options.Installs specific package if used with option. any options.Installs specific package if used with option.
.TP .TP
.B remove [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard ] .B remove [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard | --fail2ban | --proftpd ]
.br .br
Remove Nginx PHP5 MySQL Postfix stack Packages if not used with Remove Nginx PHP5 MySQL Postfix stack Packages if not used with
.br .br
any options. Remove specific package if used with option. any options. Remove specific package if used with option.
.TP .TP
.B purge [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard ] .B purge [ --all | --web | --nginx | --php | --php73 |--mysql | --redis | --adminer | --phpmyadmin | --phpredismyadmin | --wpcli | --utils | --netdata | --dashboard | --fail2ban | --proftpd ]
.br .br
Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any Purge Nginx PHP5 MySQL Postfix stack Packages if not used with any
.br .br
@@ -165,7 +165,7 @@ Update security settings.
.TP .TP
.B clean [ --fastcgi | --opcache | --redis | --all ] .B clean [ --fastcgi | --opcache | --redis | --all ]
.br .br
Clean NGINX fastCGI cache, Opcache, memcached, Redis cache. Clean NGINX fastCGI cache, Opcache, Redis cache.
.br .br
Clean NGINX fastCGI cache if no option specified. Clean NGINX fastCGI cache if no option specified.
.SH ARGUMENTS .SH ARGUMENTS
@@ -312,3 +312,6 @@ Report bugs at <http://github.com/WordOps/WordOps/issues/>
.B Rajdeep Sharma .B Rajdeep Sharma
.I \<rajdeep.sharma@rtcamp.com\> .I \<rajdeep.sharma@rtcamp.com\>
.br .br
.B Thomas SUCHON
.I \<thomas@virtubox.net\>
.br

View File

@@ -760,7 +760,6 @@ class WOSiteCreateController(CementBaseController):
if self.app.pargs.hsts: if self.app.pargs.hsts:
setupHsts(self, wo_domain) setupHsts(self, wo_domain)
if not WOService.reload_service(self, 'nginx'): if not WOService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. " Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command") "check issues with `nginx -t` command")
@@ -1320,7 +1319,6 @@ class WOSiteUpdateController(CementBaseController):
if not WOService.reload_service(self, 'nginx'): if not WOService.reload_service(self, 'nginx'):
Log.error(self, "service nginx reload failed. " Log.error(self, "service nginx reload failed. "
"check issues with `nginx -t` command") "check issues with `nginx -t` command")
site_url_https(self, wo_domain, wo_site_webroot)
Log.info(self, "Congratulations! Successfully " Log.info(self, "Congratulations! Successfully "
"Configured SSl for Site " "Configured SSl for Site "
" https://{0}".format(wo_domain)) " https://{0}".format(wo_domain))
@@ -1333,6 +1331,9 @@ class WOSiteUpdateController(CementBaseController):
Log.warn( Log.warn(
self, "Your cert already EXPIRED ! " self, "Your cert already EXPIRED ! "
".PLEASE renew soon . ") ".PLEASE renew soon . ")
# change site url to https
if data['wp'] is True:
site_url_https(self, data)
elif data['letsencrypt'] is False: elif data['letsencrypt'] is False:
if self.app.pargs.letsencrypt == "off": if self.app.pargs.letsencrypt == "off":

View File

@@ -676,26 +676,28 @@ def installwp_plugin(self, plugin_name, data):
return 1 return 1
def site_url_https(self, site_webroot='', wo_domain=''): def site_url_https(self, data):
wo_site_webroot = data['webroot']
wo_domain_name = data['site_name']
Log.info(self, "Checking if site url already use https, please wait...") Log.info(self, "Checking if site url already use https, please wait...")
WOFileUtils.chdir(self, '{0}/htdocs/'.format(site_webroot)) WOFileUtils.chdir(self, '{0}/htdocs/'.format(wo_site_webroot))
test_site_url = WOShellExec.cmd_exec(self, "php {0} option get siteurl " test_site_url = WOShellExec.cmd_exec(self, "php {0} option get siteurl "
.format(WOVariables.wo_wpcli_path) + .format(WOVariables.wo_wpcli_path) +
"--allow-root --quiet").split(":") "--allow-root --quiet").split("://")
if not test_site_url[0] == "https": if not test_site_url[0] == "https":
try: try:
WOShellExec.cmd_exec(self, "php {0} option update siteurl " WOShellExec.cmd_exec(self, "php {0} option update siteurl "
"\"https://{1}\" --allow-root".format( "\"https://{1}\" --allow-root".format(
WOVariables.wo_wpcli_path, wo_domain)) WOVariables.wo_wpcli_path, wo_domain_name))
WOShellExec.cmd_exec(self, "php {0} option update home " WOShellExec.cmd_exec(self, "php {0} option update home "
"\"https://{1}\" --allow-root".format( "\"https://{1}\" --allow-root".format(
WOVariables.wo_wpcli_path, wo_domain)) WOVariables.wo_wpcli_path, wo_domain_name))
except CommandExecutionError as e: except CommandExecutionError as e:
Log.debug(self, "{0}".format(e)) Log.debug(self, "{0}".format(e))
raise SiteError("plugin activation failed") raise SiteError("plugin activation failed")
Log.info( Log.info(
self, "Site address updated " self, "Site address updated "
"successfully to https://{0}".format(wo_domain)) "successfully to https://{0}".format(wo_domain_name))
else: else:
Log.info( Log.info(
self, "Site address was already using https") self, "Site address was already using https")

View File

@@ -10,11 +10,12 @@ class WOVariables():
"""Intialization of core variables""" """Intialization of core variables"""
# WordOps version # WordOps version
wo_version = "3.9.6.2" wo_version = "3.9.6.3"
# WordOps packages versions # WordOps packages versions
wo_wp_cli = "2.2.0" wo_wp_cli = "2.2.0"
wo_adminer = "4.7.1" wo_adminer = "4.7.2"
wo_phpmyadmin = "4.9.0.1" wo_phpmyadmin = "4.9.0.1"
wo_extplorer = "2.1.13"
# Get WPCLI path # Get WPCLI path
wo_wpcli_path = '/usr/local/bin/wp' wo_wpcli_path = '/usr/local/bin/wp'