Use the --force option for every question.

fix #12
This commit is contained in:
Antoine Nguyen
2016-06-07 10:05:16 +02:00
parent eb780d3f58
commit b20400fd98
3 changed files with 16 additions and 13 deletions

View File

@@ -61,15 +61,16 @@ class Modoboa(base.Installer):
"""Deploy Modoboa.""" """Deploy Modoboa."""
target = os.path.join(self.home_dir, "instance") target = os.path.join(self.home_dir, "instance")
if os.path.exists(target): if os.path.exists(target):
utils.printcolor( if not self.config.getboolean("general", "force"):
"Target directory for Modoboa deployment ({}) already exists." utils.printcolor(
" If you choose to continue, it will be removed.".format( "Target directory for Modoboa deployment ({}) already "
target), "exists. If you choose to continue, it will be removed."
utils.YELLOW .format(target),
) utils.YELLOW
answer = utils.user_input("Do you confirm? (Y/n) ") )
if answer.lower().startswith("n"): answer = utils.user_input("Do you confirm? (Y/n) ")
return if answer.lower().startswith("n"):
return
shutil.rmtree(target) shutil.rmtree(target)
prefix = ". {}; ".format( prefix = ". {}; ".format(

View File

@@ -29,10 +29,11 @@ class SelfSignedCertificate(CertificateBackend):
def create(self): def create(self):
"""Create a certificate.""" """Create a certificate."""
if os.path.exists(self.config.get("general", "tls_key_file")): if os.path.exists(self.config.get("general", "tls_key_file")):
answer = utils.user_input( if not self.config.getboolean("general", "force"):
"Overwrite the existing SSL certificate? (y/N) ") answer = utils.user_input(
if not answer.lower().startswith("y"): "Overwrite the existing SSL certificate? (y/N) ")
return if not answer.lower().startswith("y"):
return
utils.printcolor( utils.printcolor(
"Generating new self-signed certificate", utils.YELLOW) "Generating new self-signed certificate", utils.YELLOW)
utils.exec_cmd( utils.exec_cmd(

1
run.py
View File

@@ -50,6 +50,7 @@ def main():
answer = utils.user_input("Do you confirm? (Y/n) ") answer = utils.user_input("Do you confirm? (Y/n) ")
if answer.lower().startswith("n"): if answer.lower().startswith("n"):
return return
config.set("general", "force", str(args.force))
utils.printcolor( utils.printcolor(
"The process can be long, feel free to take a coffee " "The process can be long, feel free to take a coffee "
"and come back later ;)", utils.BLUE) "and come back later ;)", utils.BLUE)