retain current content

This commit is contained in:
usman@cyberpersons.com
2023-03-13 11:13:06 +05:00
parent 33fb617417
commit 82b1acd49d

View File

@@ -70,16 +70,27 @@ class CPBackupsV2:
command = f'mkdir -p {self.LocalRclonePath}' command = f'mkdir -p {self.LocalRclonePath}'
ProcessUtilities.executioner(command, self.website.externalApp) ProcessUtilities.executioner(command, self.website.externalApp)
command = f'cat {self.ConfigFilePath}'
CurrentContent = ProcessUtilities.outputExecutioner(command)
if CurrentContent.find('No such file or directory'):
CurrentContent = ''
CurrentContent =
if type == CPBackupsV2.SFTP: if type == CPBackupsV2.SFTP:
## config = {"name":, "host":, "user":, "port":, "path":, "password":,} ## config = {"name":, "host":, "user":, "port":, "path":, "password":,}
command = f'rclone obscure {config["password"]}' command = f'rclone obscure {config["password"]}'
ObsecurePassword = ProcessUtilities.outputExecutioner(command).rstrip('\n') ObsecurePassword = ProcessUtilities.outputExecutioner(command).rstrip('\n')
content = f'''[{config["name"]}] content = f'''{CurrentContent}
[{config["name"]}]
type = sftp type = sftp
host = {config["host"]} host = {config["host"]}
user = {config["user"]} user = {config["user"]}
pass = {ObsecurePassword} pass = {ObsecurePassword}
''' '''
command = f"echo '{content}' > {self.ConfigFilePath}" command = f"echo '{content}' > {self.ConfigFilePath}"