From 20d513f224bd2bd31858143bac1ccc4c22f71c4d Mon Sep 17 00:00:00 2001 From: David Edwards Date: Fri, 8 Dec 2023 15:06:30 -0700 Subject: [PATCH] stubbed out subsite --- config/bash_completion.d/wo_auto.rc | 4 +-- wo/cli/plugins/site_create.py | 40 +++++++++++++++++++++++++++++ wo/cli/plugins/site_functions.py | 2 +- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/config/bash_completion.d/wo_auto.rc b/config/bash_completion.d/wo_auto.rc index 6272fc0..53a4441 100644 --- a/config/bash_completion.d/wo_auto.rc +++ b/config/bash_completion.d/wo_auto.rc @@ -159,13 +159,13 @@ _wo_complete() "create") COMPREPLY=( $(compgen \ - -W "--user --pass --email --html --php --php72 --php73 --php74 --php80 --php81 --php82 --php83 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --proxy= --alias --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" \ + -W "--user --pass --email --html --php --php72 --php73 --php74 --php80 --php81 --php82 --php83 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --proxy= --alias --subsite --wpredis --wprocket --wpce -le --letsencrypt --letsencrypt=wildcard -le=wildcard --dns --dns=dns_cf --dns=dns_dgon" \ -- $cur) ) ;; "update") COMPREPLY=( $(compgen \ - -W "--password --php --php72 --php73 --php74 --php80 --php81 --php82 --php83 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce --alias -le -le=off --letsencrypt --letsencrypt=off --letsencrypt=clean -le=wildcard -le=clean --dns --dns=dns_cf --dns=dns_dgon --ngxblocker --ngxblocker=off" \ + -W "--password --php --php72 --php73 --php74 --php80 --php81 --php82 --php83 --mysql --wp --wpsubdir --wpsubdomain --wpfc --wpsc --wpredis --wprocket --wpce --alias --subsite -le -le=off --letsencrypt --letsencrypt=off --letsencrypt=clean -le=wildcard -le=clean --dns --dns=dns_cf --dns=dns_dgon --ngxblocker --ngxblocker=off" \ -- $cur) ) ;; "delete") diff --git a/wo/cli/plugins/site_create.py b/wo/cli/plugins/site_create.py index 71ac773..8a922cf 100644 --- a/wo/cli/plugins/site_create.py +++ b/wo/cli/plugins/site_create.py @@ -64,6 +64,9 @@ class WOSiteCreateController(CementBaseController): (['--alias'], dict(help="domain name to redirect to", action='store', nargs='?')), + (['--subsite'], + dict(help="parent multi-site name", + action='store', nargs='?')), (['-le', '--letsencrypt'], dict(help="configure letsencrypt ssl for the site", action='store' or 'store_const', @@ -131,10 +134,17 @@ class WOSiteCreateController(CementBaseController): alias_name = pargs.alias.strip() if not alias_name: Log.error(self, "Please provide alias name") + elif stype is None and pargs.subsite: + stype, cache = 'subsite', '' + subsite_name = pargs.subsite.strip() + if not subsite_name: + Log.error(self, "Please provide multisite parent name") elif stype and pargs.proxy: Log.error(self, "proxy should not be used with other site types") elif stype and pargs.alias: Log.error(self, "alias should not be used with other site types") + elif stype and pargs.subsite: + Log.error(self, "subsite should not be used with other site types") if not pargs.site_name: try: @@ -185,6 +195,16 @@ class WOSiteCreateController(CementBaseController): data['alias_name'] = alias_name data['basic'] = True + if stype == 'subsite': + data = dict( + site_name=wo_domain, www_domain=wo_www_domain, + static=True, basic=False, wp=False, + wpfc=False, wpsc=False, wprocket=False, wpce=False, + multisite=False, wpsubdir=False, webroot=wo_site_webroot) + data['subsite'] = True + data['subsite_name'] = subsite_name + data['basic'] = True + if (pargs.php72 or pargs.php73 or pargs.php74 or pargs.php80 or pargs.php81 or pargs.php82 or pargs.php83): data = dict( @@ -332,6 +352,26 @@ class WOSiteCreateController(CementBaseController): Log.info(self, "Successfully created site" " http://{0}".format(wo_domain)) + elif 'subsite' in data.keys() and data['subsite']: + addNewSite(self, wo_domain, stype, cache, wo_site_webroot) + # Service Nginx Reload + if not WOService.reload_service(self, 'nginx'): + Log.info(self, Log.FAIL + + "There was a serious error encountered...") + Log.info(self, Log.FAIL + "Cleaning up afterwards...") + doCleanupAction(self, domain=wo_domain) + deleteSiteInfo(self, wo_domain) + Log.error(self, "service nginx reload failed. " + "check issues with `nginx -t` command") + Log.error(self, "Check the log for details: " + "`tail /var/log/wo/wordops.log` " + "and please try again") + if wo_auth and len(wo_auth): + for msg in wo_auth: + Log.info(self, Log.ENDC + msg, log=False) + Log.info(self, "Successfully created site" + " http://{0}".format(wo_domain)) + else: addNewSite(self, wo_domain, stype, cache, wo_site_webroot, php_version=php_version) diff --git a/wo/cli/plugins/site_functions.py b/wo/cli/plugins/site_functions.py index ecb18d7..a32977f 100644 --- a/wo/cli/plugins/site_functions.py +++ b/wo/cli/plugins/site_functions.py @@ -836,7 +836,7 @@ def site_package_check(self, stype): stack.app = self.app pargs = self.app.pargs if stype in ['html', 'proxy', 'php', 'php72', 'mysql', 'wp', 'wpsubdir', - 'wpsubdomain', 'php73', 'php74', 'php80', 'php81', 'php82', 'php83', 'alias']: + 'wpsubdomain', 'php73', 'php74', 'php80', 'php81', 'php82', 'php83', 'alias', 'subsite']: Log.debug(self, "Setting apt_packages variable for Nginx") # Check if server has nginx-custom package