From eee21764e16dfd791829947a2c30d421fd01ea60 Mon Sep 17 00:00:00 2001 From: Usman Nasir Date: Mon, 9 May 2022 15:32:44 +0500 Subject: [PATCH] bug fix: email configurations reset --- plogical/mailUtilities.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/plogical/mailUtilities.py b/plogical/mailUtilities.py index cf83aaf63..fae518b87 100755 --- a/plogical/mailUtilities.py +++ b/plogical/mailUtilities.py @@ -1039,21 +1039,21 @@ class MailServerManagerUtils(multi.Thread): def centos_lib_dir_to_ubuntu(self, filename, old, new): try: - command = "sed -i 's|%s|%s|g' %s" % (old, new, filename) - ProcessUtilities.executioner(command, None, True) + #command = "sed -i 's|%s|%s|g' %s" % (old, new, filename) + #ProcessUtilities.executioner(command, None, True) - # fd = open(filename, 'r') - # lines = fd.readlines() - # fd.close() - # fd = open(filename, 'w') - # centos_prefix = old - # ubuntu_prefix = new - # for line in lines: - # index = line.find(centos_prefix) - # if index != -1: - # line = line[:index] + ubuntu_prefix + line[index + len(centos_prefix):] - # fd.write(line) - # fd.close() + fd = open(filename, 'r') + lines = fd.readlines() + fd.close() + fd = open(filename, 'w') + centos_prefix = old + ubuntu_prefix = new + for line in lines: + index = line.find(centos_prefix) + if index != -1: + line = line[:index] + ubuntu_prefix + line[index + len(centos_prefix):] + fd.write(line) + fd.close() except BaseException as msg: logging.CyberCPLogFileWriter.statusWriter(self.extraArgs['tempStatusPath'], '%s [centos_lib_dir_to_ubuntu][404]' % (str(msg)), 10) @@ -1105,7 +1105,7 @@ class MailServerManagerUtils(multi.Thread): ProcessUtilities.executioner(command) # Cleanup config files for ubuntu - if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu: + if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu or ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu20: self.centos_lib_dir_to_ubuntu("/usr/local/CyberCP/install/email-configs-one/master.cf", "/usr/libexec/", "/usr/lib/") self.centos_lib_dir_to_ubuntu("/usr/local/CyberCP/install/email-configs-one/main.cf",