mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 22:36:12 +01:00
cli utility to convert old alias to new alias
This commit is contained in:
@@ -618,8 +618,11 @@ Automatic backup failed for %s on %s.
|
|||||||
domain, time.strftime("%m.%d.%Y_%H-%M-%S"))).save()
|
domain, time.strftime("%m.%d.%Y_%H-%M-%S"))).save()
|
||||||
|
|
||||||
jobConfig = json.loads(backupjob.config)
|
jobConfig = json.loads(backupjob.config)
|
||||||
if jobConfig['pid']:
|
try:
|
||||||
del jobConfig['pid']
|
if jobConfig['pid']:
|
||||||
|
del jobConfig['pid']
|
||||||
|
except:
|
||||||
|
pass
|
||||||
jobConfig[IncScheduler.currentStatus] = 'Not running'
|
jobConfig[IncScheduler.currentStatus] = 'Not running'
|
||||||
backupjob.config = json.dumps(jobConfig)
|
backupjob.config = json.dumps(jobConfig)
|
||||||
backupjob.save()
|
backupjob.save()
|
||||||
|
|||||||
76
plogical/SwitchOldAliasToNew.py
Normal file
76
plogical/SwitchOldAliasToNew.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import os,sys
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
sys.path.append('/usr/local/CyberCP')
|
||||||
|
import django
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "CyberCP.settings")
|
||||||
|
try:
|
||||||
|
django.setup()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
import subprocess
|
||||||
|
from plogical.CyberCPLogFileWriter import CyberCPLogFileWriter as logging
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SwitchOldAliasToNew:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def Rebuild(self):
|
||||||
|
try:
|
||||||
|
message = 'We will convert old Domain Aliases to new Domain Aliases'
|
||||||
|
logging.writeToFile(message)
|
||||||
|
|
||||||
|
origConf = "/usr/local/lsws/conf/httpd_config.conf"
|
||||||
|
origConfBack = "/usr/local/lsws/conf/httpd_config.conf"
|
||||||
|
|
||||||
|
if not os.path.exists(origConf):
|
||||||
|
shutil.copy(origConf, origConfBack)
|
||||||
|
|
||||||
|
from websiteFunctions.models import aliasDomains
|
||||||
|
from plogical.virtualHostUtilities import virtualHostUtilities
|
||||||
|
from plogical.processUtilities import ProcessUtilities
|
||||||
|
|
||||||
|
for alias in aliasDomains.objects.all():
|
||||||
|
message = f"{alias.aliasDomain} was alias of {alias.master.domain}. Conversions started.."
|
||||||
|
logging.writeToFile(message)
|
||||||
|
|
||||||
|
path = f'/home/{alias.master.domain}/public_html'
|
||||||
|
|
||||||
|
result = virtualHostUtilities.createDomain(alias.master.domain, alias.aliasDomain, alias.master.phpSelection, path, 1, 0,
|
||||||
|
0, 'admin', 0,'/home/cyberpanel/fakePath', 1, 1)
|
||||||
|
|
||||||
|
if os.path.exists(ProcessUtilities.debugPath):
|
||||||
|
logging.writeToFile(str(result))
|
||||||
|
|
||||||
|
data = open(origConf, 'r').readlines()
|
||||||
|
writeToFile = open(origConf, 'w')
|
||||||
|
for line in data:
|
||||||
|
if line.find(alias.master.domain) > -1:
|
||||||
|
line = line.replace(f',{alias.aliasDomain},', '')
|
||||||
|
line = line.replace(f', {alias.aliasDomain}', '')
|
||||||
|
writeToFile.write(line)
|
||||||
|
else:
|
||||||
|
writeToFile.write(line)
|
||||||
|
writeToFile.close()
|
||||||
|
|
||||||
|
message = f"{alias.aliasDomain} is converted to new Domain Aliase."
|
||||||
|
logging.writeToFile(message)
|
||||||
|
|
||||||
|
message = f"Conversion successfully completed."
|
||||||
|
logging.writeToFile(message)
|
||||||
|
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
rbQ = SwitchOldAliasToNew()
|
||||||
|
rbQ.Rebuild()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -1316,7 +1316,7 @@ class virtualHostUtilities:
|
|||||||
|
|
||||||
if vhost.checkIfAliasExists(virtualHostName) == 1:
|
if vhost.checkIfAliasExists(virtualHostName) == 1:
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This domain exists as Alias. [404]')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'This domain exists as Alias. [404]')
|
||||||
return 0, "This domain exists as Alias."
|
#return 0, "This domain exists as Alias."
|
||||||
|
|
||||||
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'DKIM Setup..,30')
|
logging.CyberCPLogFileWriter.statusWriter(tempStatusPath, 'DKIM Setup..,30')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user