Add warning if instance has already been deployed.

This commit is contained in:
Antoine Nguyen
2016-03-04 13:57:39 +01:00
parent 60b2615e82
commit 7eb937aeff

View File

@@ -2,6 +2,7 @@
import os
import pwd
import shutil
import stat
from .. import python
@@ -46,6 +47,19 @@ class Modoboa(base.Installer):
def _deploy_instance(self):
"""Deploy Modoboa."""
target = os.path.join(self.home_dir, "instance")
if os.path.exists(target):
utils.printcolor(
"Target directory for Modoboa deployment ({}) already exists."
" If you choose to continue, it will be removed.".format(
target),
utils.YELLOW
)
answer = utils.user_input("Do you confirm? (Y/n) ")
if answer.lower().startswith("n"):
return
shutil.rmtree(target)
prefix = ". {}; ".format(
os.path.join(self.venv_path, "bin", "activate"))
args = [
@@ -66,7 +80,6 @@ class Modoboa(base.Installer):
self.config.get("amavis", "dbname")
)
]
utils.exec_cmd(
"bash -c '{} modoboa-admin.py deploy instance {}'".format(
prefix, " ".join(args)),