Merge pull request #633 from WordOps/updating-configuration

Fix reported issues
This commit is contained in:
VirtuBox
2024-04-21 19:43:46 +02:00
committed by GitHub
7 changed files with 77 additions and 43 deletions

View File

@@ -757,7 +757,7 @@ def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
def setwebrootpermissions(self, webroot): def setwebrootpermissions(self, webroot):
Log.debug(self, "Setting up permissions") Log.debug(self, "Setting up permissions")
try: try:
WOFileUtils.findBrokenSymlink(self, '/var/www/') WOFileUtils.findBrokenSymlink(self, f'{webroot}')
WOFileUtils.chown(self, webroot, WOVar.wo_php_user, WOFileUtils.chown(self, webroot, WOVar.wo_php_user,
WOVar.wo_php_user, recursive=True) WOVar.wo_php_user, recursive=True)
except Exception as e: except Exception as e:

View File

@@ -66,7 +66,7 @@ class WOSiteUpdateController(CementBaseController):
action='store', nargs='?')), action='store', nargs='?')),
(['--subsiteof'], (['--subsiteof'],
dict(help="create a subsite of a multisite install", dict(help="create a subsite of a multisite install",
action='store', nargs='?')), action='store', nargs='?')),
(['-le', '--letsencrypt'], (['-le', '--letsencrypt'],
dict(help="configure letsencrypt ssl for the site", dict(help="configure letsencrypt ssl for the site",
action='store' or 'store_const', action='store' or 'store_const',
@@ -327,7 +327,7 @@ class WOSiteUpdateController(CementBaseController):
data["wpce"] = parent_site_info.cache_type == 'wpce' data["wpce"] = parent_site_info.cache_type == 'wpce'
data["wpredis"] = parent_site_info.cache_type == 'wpredis' data["wpredis"] = parent_site_info.cache_type == 'wpredis'
data["wpsubdir"] = parent_site_info.site_type == 'wpsubdir' data["wpsubdir"] = parent_site_info.site_type == 'wpsubdir'
data["wo_php"] = ("php" + parent_site_info.php_version).replace(".", "") data["wo_php"] = ("php" + parent_site_info.php_version).replace(".", "")
data['subsite'] = True data['subsite'] = True
data['subsiteof_name'] = subsiteof_name data['subsiteof_name'] = subsiteof_name
data['subsiteof_webroot'] = parent_site_info.site_path data['subsiteof_webroot'] = parent_site_info.site_path
@@ -722,15 +722,20 @@ class WOSiteUpdateController(CementBaseController):
'hsts.conf.disabled' 'hsts.conf.disabled'
.format(wo_site_webroot)) .format(wo_site_webroot))
# find all broken symlinks # find all broken symlinks
sympath = "/var/www" sympath = (f'{wo_site_webroot}/conf')
WOFileUtils.findBrokenSymlink(self, sympath) WOFileUtils.findBrokenSymlink(self, sympath)
elif (pargs.letsencrypt == "clean" or elif (pargs.letsencrypt == "clean" or
pargs.letsencrypt == "purge"): pargs.letsencrypt == "purge"):
WOAcme.removeconf(self, wo_domain) WOAcme.removeconf(self, wo_domain)
# find all broken symlinks # find all broken symlinks
sympath = "/var/www" allsites = getAllsites(self)
WOFileUtils.findBrokenSymlink(self, sympath) for site in allsites:
if not site:
pass
sympath = "{0}/conf".format(site.site_path)
WOFileUtils.findBrokenSymlink(self, sympath)
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")

View File

@@ -22,6 +22,7 @@ from wo.core.template import WOTemplate
from wo.core.variables import WOVar from wo.core.variables import WOVar
from wo.core.stackconf import WOConf from wo.core.stackconf import WOConf
from wo.core.download import WODownload from wo.core.download import WODownload
from wo.core.checkfqdn import WOFqdn
def pre_pref(self, apt_packages): def pre_pref(self, apt_packages):
@@ -404,7 +405,9 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"/var/www/22222/cert/22222.key;\n" "/var/www/22222/cert/22222.key;\n"
"ssl_stapling off;\n") "ssl_stapling off;\n")
server_ip = requests.get('http://v4.wordops.eu') server_ip = WOFqdn.get_server_ip(self)
if server_ip is None:
server_ip = WOVar.wo_fqdn
if set(["nginx"]).issubset(set(apt_packages)): if set(["nginx"]).issubset(set(apt_packages)):
print("WordOps backend configuration was successful\n" print("WordOps backend configuration was successful\n"
@@ -418,11 +421,8 @@ def post_pref(self, apt_packages, packages, upgrade=False):
"Name: WordOps"] + "Name: WordOps"] +
["HTTP Auth Password : {0}" ["HTTP Auth Password : {0}"
.format(passwd)]) .format(passwd)])
self.msg = (self.msg + ["WordOps backend is available " self.msg = (self.msg + [f'WordOps backend is available on https://{server_ip}:22222]) '
"on https://{0}:22222 " 'or https://{WOVar.wo_fqdn}:22222'])
"or https://{1}:22222"
.format(server_ip.text,
WOVar.wo_fqdn)])
data = dict(release=WOVar.wo_version) data = dict(release=WOVar.wo_version)
WOTemplate.deploy(self, '/opt/cf-update.sh', WOTemplate.deploy(self, '/opt/cf-update.sh',

View File

@@ -1,5 +1,6 @@
# NGINX Tweaks - WordOps {{release}} # NGINX Tweaks - WordOps {{release}}
directio 4m; # Enables the use of the O_DIRECT flag t can be useful for serving large files
directio 4m;
directio_alignment 512; directio_alignment 512;
large_client_header_buffers 8 64k; large_client_header_buffers 8 64k;

View File

@@ -9,6 +9,7 @@ from wo.core.logging import Log
from wo.core.shellexec import WOShellExec, CommandExecutionError from wo.core.shellexec import WOShellExec, CommandExecutionError
from wo.core.variables import WOVar from wo.core.variables import WOVar
from wo.core.template import WOTemplate from wo.core.template import WOTemplate
from wo.core.checkfqdn import WOFqdn
class WOAcme: class WOAcme:
@@ -181,10 +182,10 @@ class WOAcme:
def check_dns(self, acme_domains): def check_dns(self, acme_domains):
"""Check if a list of domains point to the server IP""" """Check if a list of domains point to the server IP"""
server_ip = requests.get('https://v4.wordops.eu/').text server_ip = WOFqdn.get_server_ip(self)
for domain in acme_domains: for domain in acme_domains:
domain_ip = requests.get('http://v4.wordops.eu/dns/{0}/' domain_ip = WOFqdn.get_domain_ip(self, domain)
.format(domain)).text
if (not domain_ip == server_ip): if (not domain_ip == server_ip):
Log.warn( Log.warn(
self, "{0}".format(domain) + self, "{0}".format(domain) +
@@ -252,8 +253,7 @@ class WOAcme:
for dir in acmedir: for dir in acmedir:
if os.path.exists('{0}'.format(dir)): if os.path.exists('{0}'.format(dir)):
WOFileUtils.rm(self, '{0}'.format(dir)) WOFileUtils.rm(self, '{0}'.format(dir))
# find all broken symlinks
WOFileUtils.findBrokenSymlink(self, "/var/www")
else: else:
if os.path.islink("{0}".format(sslconf)): if os.path.islink("{0}".format(sslconf)):
WOFileUtils.remove_symlink(self, "{0}".format(sslconf)) WOFileUtils.remove_symlink(self, "{0}".format(sslconf))

View File

@@ -4,33 +4,61 @@ from wo.core.shellexec import WOShellExec
from wo.core.variables import WOVar from wo.core.variables import WOVar
def check_fqdn(self, wo_host): class WOFqdn:
"""FQDN check with WordOps, for mail server hostname must be FQDN""" """IP and FQDN tools for WordOps"""
# wo_host=os.popen("hostname -f | tr -d '\n'").read()
if '.' in wo_host: def check_fqdn(self, wo_host):
WOVar.wo_fqdn = wo_host """FQDN check with WordOps, for mail server hostname must be FQDN"""
with open('/etc/hostname', encoding='utf-8', mode='w') as hostfile: # wo_host=os.popen("hostname -f | tr -d '\n'").read()
hostfile.write(wo_host) if '.' in wo_host:
WOVar.wo_fqdn = wo_host
with open('/etc/hostname', encoding='utf-8', mode='w') as hostfile:
hostfile.write(wo_host)
WOShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts"
.format(wo_host))
if WOVar.wo_distro == 'debian':
WOShellExec.cmd_exec(self, "/etc/init.d/hostname.sh start")
else:
WOShellExec.cmd_exec(self, "service hostname restart")
WOShellExec.cmd_exec(self, "sed -i \"1i\\127.0.0.1 {0}\" /etc/hosts"
.format(wo_host))
if WOVar.wo_distro == 'debian':
WOShellExec.cmd_exec(self, "/etc/init.d/hostname.sh start")
else: else:
WOShellExec.cmd_exec(self, "service hostname restart") wo_host = input("Enter hostname [fqdn]:")
WOFqdn.check_fqdn(self, wo_host)
else: def check_fqdn_ip(self):
wo_host = input("Enter hostname [fqdn]:") """Check if server hostname resolved server IP"""
check_fqdn(self, wo_host) try:
x = requests.get('http://v4.wordops.eu')
ip = (x.text).strip()
wo_fqdn = WOVar.wo_fqdn
y = requests.get('http://v4.wordops.eu/dns/{0}/'.format(wo_fqdn))
ip_fqdn = (y.text).strip()
def check_fqdn_ip(self): return bool(ip == ip_fqdn)
"""Check if server hostname resolved server IP""" except requests.exceptions.RequestException as e:
x = requests.get('http://v4.wordops.eu') print("Error occurred during request:", e)
ip = (x.text).strip() return False
wo_fqdn = WOVar.wo_fqdn def get_server_ip(self):
y = requests.get('http://v4.wordops.eu/dns/{0}/'.format(wo_fqdn)) """Get the server externet IP"""
ip_fqdn = (y.text).strip() try:
x = requests.get('http://v4.wordops.eu')
ip = (x.text).strip()
return bool(ip == ip_fqdn) return ip
except requests.exceptions.RequestException as e:
print("Error occurred during request:", e)
return None
def get_domain_ip(self, wo_domain):
"""Get the server externet IP"""
try:
y = requests.get('http://v4.wordops.eu/dns/{0}/'.format(wo_domain))
domain_ip = (y.text).strip()
return domain_ip
except requests.exceptions.RequestException as e:
print("Error occurred during request:", e)
return None

View File

@@ -17,11 +17,11 @@ class WOVar():
# WordOps version # WordOps version
wo_version = "3.19.1" wo_version = "3.19.1"
# WordOps packages versions # WordOps packages versions
wo_wp_cli = "2.9.0" wo_wp_cli = "2.10.0"
wo_adminer = "4.8.1" wo_adminer = "4.8.1"
wo_phpmyadmin = "5.2.0" wo_phpmyadmin = "5.2.0"
wo_extplorer = "2.1.15" wo_extplorer = "2.1.15"
wo_dashboard = "1.2" wo_dashboard = "1.3"
# Get WPCLI path # Get WPCLI path
wo_wpcli_path = '/usr/local/bin/wp' wo_wpcli_path = '/usr/local/bin/wp'