install doveauth system-wide via pip

This commit is contained in:
missytake
2023-10-13 20:48:36 +02:00
parent 01f350fa0b
commit fbda0fb53c
4 changed files with 26 additions and 13 deletions

1
.gitignore vendored
View File

@@ -10,6 +10,7 @@ __pycache__/
# Distribution / packaging # Distribution / packaging
.Python .Python
build/ build/
doveauth/dist/
develop-eggs/ develop-eggs/
dist/ dist/
downloads/ downloads/

View File

@@ -2,6 +2,7 @@
Chat Mail pyinfra deploy. Chat Mail pyinfra deploy.
""" """
import importlib.resources import importlib.resources
import os.path
from pyinfra import host, logger from pyinfra import host, logger
from pyinfra.operations import apt, files, server, systemd, python from pyinfra.operations import apt, files, server, systemd, python
@@ -9,17 +10,25 @@ from pyinfra.facts.files import File
from .acmetool import deploy_acmetool from .acmetool import deploy_acmetool
def _install_chatctl() -> None: def _install_doveauth() -> None:
"""Setup chatctl.""" """Setup chatctl."""
files.put( doveauth_filename = f'doveauth-0.1.tar.gz'
src=importlib.resources.files("doveauth") doveauth_path = importlib.resources.files(__package__).joinpath(f'../../../doveauth/dist/{doveauth_filename}')
.joinpath("doveauth.py") remote_path = f"/tmp/{doveauth_filename}"
.open("rb"), if os.path.exists(str(doveauth_path)):
dest="/home/vmail/chatctl", files.put(
user="vmail", name="upload local doveauth build",
group="vmail", src=doveauth_path.open("rb"),
mode="755", 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: 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) dovecot_need_restart = _configure_dovecot(mail_server)
postfix_need_restart = _configure_postfix(mail_domain) postfix_need_restart = _configure_postfix(mail_domain)
opendkim_need_restart = _configure_opendkim(mail_domain, dkim_selector) opendkim_need_restart = _configure_opendkim(mail_domain, dkim_selector)

View File

@@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
: ${CHATMAIL_DOMAIN:=c1.testrun.org} : ${CHATMAIL_DOMAIN:=c1.testrun.org}
export CHATMAIL_DOMAIN 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/

View File

@@ -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 chatmail-pyinfra
chatmail-pyinfra/venv/bin/pip install -e doveauth chatmail-pyinfra/venv/bin/pip install -e doveauth
python3 -m venv doveauth/venv 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 doveauth/venv/bin/pip install -e doveauth