From 22c303ed7ca5a76cc679e4931776fa1ccab0d022 Mon Sep 17 00:00:00 2001 From: Alexandre Gauthier Date: Fri, 21 Nov 2025 21:59:04 -0500 Subject: [PATCH 1/2] Fix issues with echobot invite link in cmdeploy The entire stack is setup to support 'localhost' as a value for ssh_host, returning LocalExec when that is the case, but this last step made a new explicit SSHExec connection to config.mail_domain. This changes that to simply use the subprocess module when ssh_host is local. This also fixes the issue where the connection was made to 'config.mail_domain' instead of the supplied ssh_host value, ensuring that remains consistent. Additionally, the entire process will be skipped if --dry-run is used with cmdeploy, allowing a dry-run to complete without error. --- cmdeploy/src/cmdeploy/cmdeploy.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index 6e5f7c7e..d9d6462f 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -109,15 +109,24 @@ def run_cmd(args, out): try: retcode = out.check_call(cmd, env=env) if retcode == 0: - if not args.disable_mail: + if not args.disable_mail and not args.dry_run: print("\nYou can try out the relay by talking to this echo bot: ") - sshexec = SSHExec(args.config.mail_domain, verbose=args.verbose) - print( - sshexec( - call=remote.rshell.shell, - kwargs=dict(command="cat /var/lib/echobot/invite-link.txt"), + echobot_cmd = "cat /var/lib/echobot/invite-link.txt" + if ssh_host in ["localhost", "@local", "@docker"]: + result = ( + subprocess.check_output(echobot_cmd, shell=True) + .decode() + .strip() + ) + print(result) + else: + echo_sshexec = get_sshexec(ssh_host, verbose=args.verbose) + print( + echo_sshexec( + call=remote.rshell.shell, + kwargs=dict(command=echobot_cmd), + ) ) - ) out.green("Deploy completed, call `cmdeploy dns` next.") elif not remote_data["acme_account_url"]: out.red("Deploy completed but letsencrypt not configured") From 296dcad1daafe31d50178bf54792a26d30087289 Mon Sep 17 00:00:00 2001 From: missytake Date: Sat, 6 Dec 2025 19:06:07 +0100 Subject: [PATCH 2/2] echobot: print invite link with python --- CHANGELOG.md | 3 +++ cmdeploy/src/cmdeploy/cmdeploy.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a2f5bb6..1559fff0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ - Organized cmdeploy into install, configure, and activate stages ([#695](https://github.com/chatmail/relay/pull/695)) +- echobot: print invite-link also if it's deployed locally + ([#751](https://github.com/chatmail/relay/pull/751)) + - docs: move readme.md docs to sphinx documentation rendered at https://chatmail.at/doc/relay ([#711](https://github.com/chatmail/relay/pull/711)) diff --git a/cmdeploy/src/cmdeploy/cmdeploy.py b/cmdeploy/src/cmdeploy/cmdeploy.py index d9d6462f..f2596e04 100644 --- a/cmdeploy/src/cmdeploy/cmdeploy.py +++ b/cmdeploy/src/cmdeploy/cmdeploy.py @@ -11,6 +11,7 @@ import shutil import subprocess import sys +import time from pathlib import Path import pyinfra @@ -111,20 +112,18 @@ def run_cmd(args, out): if retcode == 0: if not args.disable_mail and not args.dry_run: print("\nYou can try out the relay by talking to this echo bot: ") - echobot_cmd = "cat /var/lib/echobot/invite-link.txt" + invite_path = Path("/var/lib/echobot/invite-link.txt") if ssh_host in ["localhost", "@local", "@docker"]: - result = ( - subprocess.check_output(echobot_cmd, shell=True) - .decode() - .strip() - ) - print(result) + while not invite_path.exists(): + time.sleep(0.1) + with invite_path.open() as f: + print(f.readline()) else: echo_sshexec = get_sshexec(ssh_host, verbose=args.verbose) print( echo_sshexec( call=remote.rshell.shell, - kwargs=dict(command=echobot_cmd), + kwargs=dict(command=f"cat {invite_path}"), ) ) out.green("Deploy completed, call `cmdeploy dns` next.")