echobot: print invite link with python

This commit is contained in:
missytake
2025-12-06 19:06:07 +01:00
parent 22c303ed7c
commit 296dcad1da
2 changed files with 10 additions and 8 deletions

View File

@@ -11,6 +11,9 @@
- Organized cmdeploy into install, configure, and activate stages - Organized cmdeploy into install, configure, and activate stages
([#695](https://github.com/chatmail/relay/pull/695)) ([#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 - docs: move readme.md docs to sphinx documentation rendered at https://chatmail.at/doc/relay
([#711](https://github.com/chatmail/relay/pull/711)) ([#711](https://github.com/chatmail/relay/pull/711))

View File

@@ -11,6 +11,7 @@ import pathlib
import shutil import shutil
import subprocess import subprocess
import sys import sys
import time
from pathlib import Path from pathlib import Path
import pyinfra import pyinfra
@@ -111,20 +112,18 @@ def run_cmd(args, out):
if retcode == 0: if retcode == 0:
if not args.disable_mail and not args.dry_run: if not args.disable_mail and not args.dry_run:
print("\nYou can try out the relay by talking to this echo bot: ") 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"]: if ssh_host in ["localhost", "@local", "@docker"]:
result = ( while not invite_path.exists():
subprocess.check_output(echobot_cmd, shell=True) time.sleep(0.1)
.decode() with invite_path.open() as f:
.strip() print(f.readline())
)
print(result)
else: else:
echo_sshexec = get_sshexec(ssh_host, verbose=args.verbose) echo_sshexec = get_sshexec(ssh_host, verbose=args.verbose)
print( print(
echo_sshexec( echo_sshexec(
call=remote.rshell.shell, call=remote.rshell.shell,
kwargs=dict(command=echobot_cmd), kwargs=dict(command=f"cat {invite_path}"),
) )
) )
out.green("Deploy completed, call `cmdeploy dns` next.") out.green("Deploy completed, call `cmdeploy dns` next.")