From fbda0fb53c60068e7822cb9394070479e07d6558 Mon Sep 17 00:00:00 2001 From: missytake Date: Fri, 13 Oct 2023 20:48:36 +0200 Subject: [PATCH] install doveauth system-wide via pip --- .gitignore | 1 + chatmail-pyinfra/src/chatmail/__init__.py | 31 +++++++++++++++-------- scripts/deploy.sh | 5 +++- scripts/init.sh | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 594ea4b..eed7931 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ __pycache__/ # Distribution / packaging .Python build/ +doveauth/dist/ develop-eggs/ dist/ downloads/ diff --git a/chatmail-pyinfra/src/chatmail/__init__.py b/chatmail-pyinfra/src/chatmail/__init__.py index 6e733c8..bb11bc9 100644 --- a/chatmail-pyinfra/src/chatmail/__init__.py +++ b/chatmail-pyinfra/src/chatmail/__init__.py @@ -2,6 +2,7 @@ Chat Mail pyinfra deploy. """ import importlib.resources +import os.path from pyinfra import host, logger from pyinfra.operations import apt, files, server, systemd, python @@ -9,17 +10,25 @@ from pyinfra.facts.files import File from .acmetool import deploy_acmetool -def _install_chatctl() -> None: +def _install_doveauth() -> None: """Setup chatctl.""" - files.put( - src=importlib.resources.files("doveauth") - .joinpath("doveauth.py") - .open("rb"), - dest="/home/vmail/chatctl", - user="vmail", - group="vmail", - mode="755", - ) + doveauth_filename = f'doveauth-0.1.tar.gz' + doveauth_path = importlib.resources.files(__package__).joinpath(f'../../../doveauth/dist/{doveauth_filename}') + remote_path = f"/tmp/{doveauth_filename}" + if os.path.exists(str(doveauth_path)): + files.put( + name="upload local doveauth build", + src=doveauth_path.open("rb"), + dest=remote_path, + ) + apt.packages( + name="apt install python3-pip", + packages="python3-pip", + ) + server.shell( + name="install local doveauth build with pip", + commands=[f"pip install --break-system-packages {remote_path}"] + ) def _configure_opendkim(domain: str, dkim_selector: str) -> bool: @@ -159,7 +168,7 @@ def deploy_chatmail(mail_domain: str, mail_server: str, dkim_selector: str) -> N ], ) - _install_chatctl() + _install_doveauth() dovecot_need_restart = _configure_dovecot(mail_server) postfix_need_restart = _configure_postfix(mail_domain) opendkim_need_restart = _configure_opendkim(mail_domain, dkim_selector) diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 11b4bb6..1f93876 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash : ${CHATMAIL_DOMAIN:=c1.testrun.org} export CHATMAIL_DOMAIN -chatmail-pyinfra/venv/bin/pyinfra --ssh-user root "$CHATMAIL_DOMAIN" deploy.py +cd doveauth +venv/bin/python3 -m build +../chatmail-pyinfra/venv/bin/pyinfra --ssh-user root "$CHATMAIL_DOMAIN" ../deploy.py +rm -r dist/ diff --git a/scripts/init.sh b/scripts/init.sh index 6e20334..466a980 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -4,5 +4,5 @@ chatmail-pyinfra/venv/bin/pip install pyinfra pytest chatmail-pyinfra/venv/bin/pip install -e chatmail-pyinfra chatmail-pyinfra/venv/bin/pip install -e doveauth python3 -m venv doveauth/venv -doveauth/venv/bin/pip install pytest +doveauth/venv/bin/pip install pytest build doveauth/venv/bin/pip install -e doveauth