From 7e6dfb7bfd0309bb283befef3d3de9310b4d1d5e Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Mon, 23 Mar 2020 10:48:52 +0500 Subject: [PATCH] feature: redis-mass hosting to take care of www.domain.com' --- plogical/vhost.py | 40 ++++++++++++++++++++++++++++++++++++++++ plogical/vhostConfs.py | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/plogical/vhost.py b/plogical/vhost.py index 2662079eb..cca7a8705 100755 --- a/plogical/vhost.py +++ b/plogical/vhost.py @@ -261,6 +261,9 @@ class vhost: confFile.close() else: + + ## Non-www + currentConf = vhostConfs.lswsRediConfMaster currentConf = currentConf.replace('{virtualHostName}', virtualHostName) @@ -273,6 +276,21 @@ class vhost: command = 'redis-cli set %s' % (currentConf) ProcessUtilities.executioner(command) + ## WWW + + currentConf = vhostConfs.lswsRediConfMasterWWW + + currentConf = currentConf.replace('{virtualHostName}', 'www.%s' % (virtualHostName)) + currentConf = currentConf.replace('{master}', virtualHostName) + currentConf = currentConf.replace('{administratorEmail}', administratorEmail) + currentConf = currentConf.replace('{externalApp}', virtualHostUser) + currentConf = currentConf.replace('{php}', phpVersion.lstrip('PHP ')) + currentConf = currentConf.replace('{uid}', str(pwd.getpwnam(virtualHostUser).pw_uid)) + currentConf = currentConf.replace('{gid}', str(grp.getgrnam(virtualHostUser).gr_gid)) + + command = 'redis-cli set %s' % (currentConf) + ProcessUtilities.executioner(command) + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( @@ -547,6 +565,9 @@ class vhost: command = 'redis-cli delete "vhost:%s"' % (virtualHostName) ProcessUtilities.executioner(command) + command = 'redis-cli delete "vhost:www.%s"' % (virtualHostName) + ProcessUtilities.executioner(command) + @staticmethod def checkIfVirtualHostExists(virtualHostName): if os.path.exists("/home/" + virtualHostName): @@ -902,6 +923,9 @@ class vhost: confFile.close() else: + + ## Non www + currentConf = vhostConfs.lswsRediConfChild currentConf = currentConf.replace('{virtualHostName}', domain) @@ -916,6 +940,22 @@ class vhost: command = 'redis-cli set %s' % (currentConf) ProcessUtilities.executioner(command) + ## www + + currentConf = vhostConfs.lswsRediConfChildWWW + + currentConf = currentConf.replace('{virtualHostName}', 'www.%s' % (domain)) + currentConf = currentConf.replace('{masterDomain}', masterDomain) + currentConf = currentConf.replace('{administratorEmail}', administratorEmail) + currentConf = currentConf.replace('{path}', path) + currentConf = currentConf.replace('{externalApp}', virtualHostUser) + currentConf = currentConf.replace('{php}', phpVersion.lstrip('PHP ')) + currentConf = currentConf.replace('{uid}', str(pwd.getpwnam(virtualHostUser).pw_uid)) + currentConf = currentConf.replace('{gid}', str(grp.getgrnam(virtualHostUser).gr_gid)) + + command = 'redis-cli set %s' % (currentConf) + ProcessUtilities.executioner(command) + except BaseException as msg: logging.CyberCPLogFileWriter.writeToFile( str(msg) + " [IO Error with per host config file [perHostDomainConf]]") diff --git a/plogical/vhostConfs.py b/plogical/vhostConfs.py index 3e19e20e9..97e84d9fa 100755 --- a/plogical/vhostConfs.py +++ b/plogical/vhostConfs.py @@ -374,7 +374,6 @@ pm.max_spare_servers = {pmMaxSpareServers} "gid": {gid}, "phpVersion": {php}, "custom_conf": { - ServerAlias www.{virtualHostName} ServerAdmin {administratorEmail} CustomLog /home/{virtualHostName}/logs/{virtualHostName}.access_log combined @@ -382,6 +381,21 @@ pm.max_spare_servers = {pmMaxSpareServers} } }'""" + lswsRediConfMasterWWW = """"vhost:{virtualHostName}" '{ + "username": "{externalApp}", + "documentRoot": "/home/{master}/public_html", + "vh_root": "/home/{master}", + "uid": {uid}, + "gid": {gid}, + "phpVersion": {php}, + "custom_conf": { + ServerAdmin {administratorEmail} + CustomLog /home/{master}/logs/{master}.access_log combined + + CacheRoot lscache + + } +}'""" lswsRediConfChild = """"vhost:{virtualHostName}" '{ "username": "{externalApp}", @@ -391,7 +405,22 @@ pm.max_spare_servers = {pmMaxSpareServers} "gid": {gid}, "phpVersion": {php}, "custom_conf": { - ServerAlias www.{virtualHostName} + ServerAdmin {administratorEmail} + CustomLog /home/{masterDomain}/logs/{masterDomain}.access_log combined + + CacheRoot /home/{masterDomain}/lscache + + } +}'""" + + lswsRediConfChildWWW = """"vhost:{virtualHostName}" '{ + "username": "{externalApp}", + "documentRoot": "{path}", + "vh_root": "{path}", + "uid": {uid}, + "gid": {gid}, + "phpVersion": {php}, + "custom_conf": { ServerAdmin {administratorEmail} CustomLog /home/{masterDomain}/logs/{masterDomain}.access_log combined