Add wo site create --alias
This commit is contained in:
@@ -73,6 +73,9 @@ class WOSiteCreateController(CementBaseController):
|
||||
dict(help="create WordPress single/multi site "
|
||||
"with redis cache",
|
||||
action='store_true')),
|
||||
(['--alias'],
|
||||
dict(help="domain name to redirect to",
|
||||
action='store', nargs='?')),
|
||||
(['-le', '--letsencrypt'],
|
||||
dict(help="configure letsencrypt ssl for the site",
|
||||
action='store' or 'store_const',
|
||||
@@ -129,10 +132,17 @@ class WOSiteCreateController(CementBaseController):
|
||||
proxyinfo = proxyinfo.split(':')
|
||||
host = proxyinfo[0].strip()
|
||||
port = '80' if len(proxyinfo) < 2 else proxyinfo[1].strip()
|
||||
elif stype is None and not pargs.proxy:
|
||||
elif stype is None and not pargs.proxy and not pargs.alias:
|
||||
stype, cache = 'html', 'basic'
|
||||
elif stype is None and pargs.alias:
|
||||
stype, cache = 'alias', ''
|
||||
alias_name = pargs.alias.strip()
|
||||
if not alias_name:
|
||||
Log.error(self, "Please provide alias 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")
|
||||
|
||||
if not pargs.site_name:
|
||||
try:
|
||||
@@ -173,6 +183,16 @@ class WOSiteCreateController(CementBaseController):
|
||||
data['port'] = port
|
||||
data['basic'] = True
|
||||
|
||||
if stype == 'alias':
|
||||
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['alias'] = True
|
||||
data['alias_name'] = alias_name
|
||||
data['basic'] = True
|
||||
|
||||
if (pargs.php72 or pargs.php73 or pargs.php74 or
|
||||
pargs.php80 or pargs.php81 or pargs.php82):
|
||||
data = dict(
|
||||
@@ -301,6 +321,27 @@ class WOSiteCreateController(CementBaseController):
|
||||
" http://{0}".format(wo_domain))
|
||||
return
|
||||
|
||||
if 'alias' in data.keys() and data['alias']:
|
||||
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))
|
||||
return
|
||||
|
||||
addNewSite(self, wo_domain, stype, cache, wo_site_webroot,
|
||||
php_version=php_version)
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ server {
|
||||
access_log /var/log/nginx/{{site_name}}.access.log {{^wpredis}}{{^static}}rt_cache{{/static}}{{/wpredis}}{{#wpredis}}rt_cache_redis{{/wpredis}};
|
||||
error_log /var/log/nginx/{{site_name}}.error.log;
|
||||
|
||||
{{#alias}}
|
||||
location / {
|
||||
return 301 https://{{alias_name}}$request_uri;
|
||||
}
|
||||
{{#proxy}}
|
||||
add_header X-Proxy-Cache $upstream_cache_status;
|
||||
location / {
|
||||
@@ -23,7 +27,7 @@ server {
|
||||
proxy_redirect off;
|
||||
include proxy_params;
|
||||
}
|
||||
|
||||
{{#alias}}
|
||||
# Security settings for better privacy
|
||||
# Deny hidden files
|
||||
location ~ /\.(?!well-known\/) {
|
||||
@@ -35,9 +39,11 @@ server {
|
||||
allow all;
|
||||
auth_basic off;
|
||||
}
|
||||
{{/alias}}
|
||||
{{/proxy}}
|
||||
|
||||
{{^proxy}}
|
||||
{{^alias}}
|
||||
root {{webroot}}/htdocs;
|
||||
|
||||
index {{^static}}index.php{{/static}} index.html index.htm;
|
||||
@@ -51,7 +57,7 @@ server {
|
||||
{{^static}}include {{#basic}}common/{{wo_php}}.conf;{{/basic}}{{#wpfc}}common/wpfc-{{wo_php}}.conf;{{/wpfc}}{{#wpsc}}common/wpsc-{{wo_php}}.conf;{{/wpsc}}{{#wpredis}}common/redis-{{wo_php}}.conf;{{/wpredis}}{{#wprocket}}common/wprocket-{{wo_php}}.conf;{{/wprocket}}{{#wpce}}common/wpce-{{wo_php}}.conf;{{/wpce}}
|
||||
{{#wpsubdir}}include common/wpsubdir.conf;{{/wpsubdir}}{{/static}}
|
||||
{{#wp}}include common/wpcommon-{{wo_php}}.conf;{{/wp}}
|
||||
include common/locations-wo.conf;{{/proxy}}
|
||||
include common/locations-wo.conf;{{/proxy}}{{/alias}}
|
||||
include {{webroot}}/conf/nginx/*.conf;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user