Skip to content

Commit

Permalink
streamline CLI flow during letsencrypt-not-yet set phase
Browse files Browse the repository at this point in the history
  • Loading branch information
hpk42 committed Jul 8, 2024
1 parent 0aff743 commit 0653292
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions cmdeploy/src/cmdeploy/cmdeploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run_cmd_options(parser):

def run_cmd(args, out):
"""Deploy chatmail services on the remote server."""
show_dns(args, out)
retcode, remote_data = show_dns(args, out)

env = os.environ.copy()
env["CHATMAIL_INI"] = args.inipath
Expand All @@ -62,7 +62,13 @@ def run_cmd(args, out):
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploy_path}"

out.check_call(cmd, env=env)
print("Deploy completed, call `cmdeploy dns` next.")
if retcode == 0:
out.green("Deploy completed, call `cmdeploy test` next.")
elif not remote_data["acme_account_url"]:
out.red("Deploy completed but needs rerun (letsencrypt not configured)")
else:
out.red("Deploy failed")
return retcode


def dns_cmd_options(parser):
Expand All @@ -75,7 +81,8 @@ def dns_cmd_options(parser):

def dns_cmd(args, out):
"""Check DNS entries and optionally generate dns zone file."""
return show_dns(args, out)
retcode, remote_data = show_dns(args, out)
return retcode


def status_cmd(args, out):
Expand Down
6 changes: 3 additions & 3 deletions cmdeploy/src/cmdeploy/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

def show_dns(args, out) -> int:
"""Check existing DNS records, optionally write them to zone file
and return exit code 0 for success, non-zero otherwise."""
print("Checking your DKIM keys and DNS entries...")
and return (exitcode, remote_data) tuple."""
print("Checking DNS entries ...")
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
mail_domain = args.config.mail_domain

Expand Down Expand Up @@ -60,4 +60,4 @@ def show_dns(args, out) -> int:
"You can do so at your hosting provider (maybe this isn't your DNS provider)."
)

return exit_code
return exit_code, remote_data

0 comments on commit 0653292

Please sign in to comment.