feature: add option to switch to master again

This commit is contained in:
Usman Nasir
2021-04-18 01:31:05 +05:00
parent 64ca25336e
commit 4923f060fd
4 changed files with 59 additions and 2 deletions

View File

@@ -357,7 +357,7 @@ password=%s""" % (rootdbpassword, rootdbpassword)
self.PostStatus('Data and SSL certificates currently synced.')
except BaseException as msg:
self.PostStatus('Failed to create pending vhosts, error %s [404].' % (str(msg)))
self.PostStatus('Failed to sync data, error %s [404].' % (str(msg)))
def PingNow(self):
try:
@@ -423,6 +423,25 @@ password=%s""" % (rootdbpassword, rootdbpassword)
except BaseException as msg:
logging.writeToFile('%s. [31:404]' % (str(msg)))
def SyncToMaster(self):
try:
self.PostStatus('Syncing data from home directory to Main server..')
command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /home root@%s:/" % (self.config['masterServerSSHPort'], self.config['masterServerIP'])
ProcessUtilities.normalExecutioner(command)
self.PostStatus('Syncing SSL certificates to Main server..')
command = "rsync -avzp -e 'ssh -o StrictHostKeyChecking=no -p %s -i /root/.ssh/cyberpanel' /etc/letsencrypt root@%s:/etc" % (
self.config['masterServerSSHPort'], self.config['masterServerIP'])
ProcessUtilities.normalExecutioner(command)
self.PostStatus('Data back to main.')
except BaseException as msg:
self.PostStatus('Failed to sync data, error %s [404].' % (str(msg)))
def main():
parser = argparse.ArgumentParser(description='CyberPanel Installer')
@@ -453,6 +472,8 @@ def main():
uc.UptimeMonitor()
elif args.function == 'Uptime':
uc.Uptime()
elif args.function == 'SyncToMaster':
uc.SyncToMaster()
if __name__ == "__main__":