diff --git a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py index ab04f48b..9499d6e8 100644 --- a/deploy-chatmail/src/deploy_chatmail/cmdeploy.py +++ b/deploy-chatmail/src/deploy_chatmail/cmdeploy.py @@ -81,8 +81,17 @@ def get_parser(): add_subcommand(subparsers, test_cmd) + add_subcommand(subparsers, dns_cmd) + return parser +def get_config_or_bailout(inipath): + try: + return read_config(inipath) + except Exception as ex: + out.red(ex) + raise SystemExit(1) + def init_cmd(args, out): """Initialize chatmail config file.""" @@ -96,11 +105,7 @@ def init_cmd(args, out): def run_cmd(args, out): """Deploy chatmail services on the remote server.""" - try: - config = read_config(args.chatmail_ini) - except Exception as ex: - out.red(ex) - raise SystemExit(1) + config = get_config_or_bailout(args.chatmail_ini) popen_args = ["pyinfra"] if args.dry_run: @@ -134,6 +139,41 @@ def test_cmd(args, out): ) +def dns_cmd(args, out): + """generate dns zone file.""" + + config = get_config_or_bailout(args.chatmail_ini) + SSH = f"ssh root@{config.mailname}" + EMAIL = "root@config.mailname" + + def shell_output(arg): + return subprocess.check_output(arg, shell=True) + + ACME_ACCOUNT_URL = shell_output(f"{SSH} -- acmetool account-url") + import pdb ; pdb.set_trace() + """ +set -e +SSH="ssh root@$CHATMAIL_SSH" +EMAIL="root@$CHATMAIL_DOMAIN" +ACME_ACCOUNT_URL="$($SSH -- acmetool account-url)" + +cat <