revert pure whitespace chagnes

This commit is contained in:
holger krekel
2026-02-23 02:59:07 +01:00
committed by j4n
parent b30acabcfb
commit 17961e1bf7
9 changed files with 29 additions and 68 deletions

View File

@@ -67,7 +67,7 @@ class AcmetoolDeployer(Deployer):
) )
files.template( files.template(
src=importlib.resources.files(__package__).joinpath("desired.yaml.j2"), src=importlib.resources.files(__package__).joinpath("desired.yaml.j2"),
dest=f"/var/lib/acme/desired/{self.domains[0]}", # 0 is mailhost TLD dest=f"/var/lib/acme/desired/{self.domains[0]}", # 0 is mailhost TLD
user="root", user="root",
group="root", group="root",
mode="644", mode="644",

View File

@@ -93,9 +93,7 @@ def run_cmd(args, out):
strict_tls = args.config.tls_cert_mode == "acme" strict_tls = args.config.tls_cert_mode == "acme"
if not args.dns_check_disabled: if not args.dns_check_disabled:
remote_data = dns.get_initial_remote_data(sshexec, args.config.mail_domain) remote_data = dns.get_initial_remote_data(sshexec, args.config.mail_domain)
if not dns.check_initial_remote_data( if not dns.check_initial_remote_data(remote_data, strict_tls=strict_tls, print=out.red):
remote_data, strict_tls=strict_tls, print=out.red
):
return 1 return 1
env = os.environ.copy() env = os.environ.copy()
@@ -129,11 +127,7 @@ def run_cmd(args, out):
out.red("Website deployment failed.") out.red("Website deployment failed.")
elif retcode == 0: elif retcode == 0:
out.green("Deploy completed, call `cmdeploy dns` next.") out.green("Deploy completed, call `cmdeploy dns` next.")
elif ( elif not args.dns_check_disabled and strict_tls and not remote_data["acme_account_url"]:
not args.dns_check_disabled
and strict_tls
and not remote_data["acme_account_url"]
):
out.red("Deploy completed but letsencrypt not configured") out.red("Deploy completed but letsencrypt not configured")
out.red("Run 'cmdeploy run' again") out.red("Run 'cmdeploy run' again")
retcode = 0 retcode = 0

View File

@@ -579,17 +579,11 @@ def deploy_chatmail(config_path: Path, disable_mail: bool, website_only: bool) -
) )
# Check if mtail_address interface is available (if configured) # Check if mtail_address interface is available (if configured)
if config.mtail_address and config.mtail_address not in ( if config.mtail_address and config.mtail_address not in ('127.0.0.1', '::1', 'localhost'):
"127.0.0.1",
"::1",
"localhost",
):
ipv4_addrs = host.get_fact(hardware.Ipv4Addrs) ipv4_addrs = host.get_fact(hardware.Ipv4Addrs)
all_addresses = [addr for addrs in ipv4_addrs.values() for addr in addrs] all_addresses = [addr for addrs in ipv4_addrs.values() for addr in addrs]
if config.mtail_address not in all_addresses: if config.mtail_address not in all_addresses:
Out().red( Out().red(f"Deploy failed: mtail_address {config.mtail_address} is not available (VPN up?).\n")
f"Deploy failed: mtail_address {config.mtail_address} is not available (VPN up?).\n"
)
exit(1) exit(1)
if not os.environ.get("CHATMAIL_NOPORTCHECK"): if not os.environ.get("CHATMAIL_NOPORTCHECK"):

View File

@@ -42,11 +42,7 @@ class DovecotDeployer(Deployer):
restart = False if self.disable_mail else self.need_restart restart = False if self.disable_mail else self.need_restart
systemd.service( systemd.service(
name=( name="Disable dovecot for now" if self.disable_mail else "Start and enable Dovecot",
"Disable dovecot for now"
if self.disable_mail
else "Start and enable Dovecot"
),
service="dovecot.service", service="dovecot.service",
running=False if self.disable_mail else True, running=False if self.disable_mail else True,
enabled=False if self.disable_mail else True, enabled=False if self.disable_mail else True,

View File

@@ -97,9 +97,7 @@ class PostfixDeployer(Deployer):
server.shell( server.shell(
name="Validate postfix configuration", name="Validate postfix configuration",
# Extract stderr and quit with error if non-zero # Extract stderr and quit with error if non-zero
commands=[ commands=["""bash -c 'w=$(postconf 2>&1 >/dev/null); [[ -z "$w" ]] || { echo "$w"; false; }'"""],
"""bash -c 'w=$(postconf 2>&1 >/dev/null); [[ -z "$w" ]] || { echo "$w"; false; }'"""
],
) )
self.need_restart = need_restart self.need_restart = need_restart
@@ -107,11 +105,9 @@ class PostfixDeployer(Deployer):
restart = False if self.disable_mail else self.need_restart restart = False if self.disable_mail else self.need_restart
systemd.service( systemd.service(
name=( name="disable postfix for now"
"disable postfix for now" if self.disable_mail
if self.disable_mail else "Start and enable Postfix",
else "Start and enable Postfix"
),
service="postfix.service", service="postfix.service",
running=False if self.disable_mail else True, running=False if self.disable_mail else True,
enabled=False if self.disable_mail else True, enabled=False if self.disable_mail else True,

View File

@@ -12,24 +12,13 @@ def openssl_selfsigned_args(domain, cert_path, key_path, days=36500):
``www.<domain>`` and ``mta-sts.<domain>``. ``www.<domain>`` and ``mta-sts.<domain>``.
""" """
return [ return [
"openssl", "openssl", "req", "-x509",
"req", "-newkey", "ec", "-pkeyopt", "ec_paramgen_curve:P-256",
"-x509", "-noenc", "-days", str(days),
"-newkey", "-keyout", str(key_path),
"ec", "-out", str(cert_path),
"-pkeyopt", "-subj", f"/CN={domain}",
"ec_paramgen_curve:P-256", "-addext", "extendedKeyUsage=serverAuth,clientAuth",
"-noenc",
"-days",
str(days),
"-keyout",
str(key_path),
"-out",
str(cert_path),
"-subj",
f"/CN={domain}",
"-addext",
"extendedKeyUsage=serverAuth,clientAuth",
"-addext", "-addext",
f"subjectAltName=DNS:{domain},DNS:www.{domain},DNS:mta-sts.{domain}", f"subjectAltName=DNS:{domain},DNS:www.{domain},DNS:mta-sts.{domain}",
] ]
@@ -51,9 +40,7 @@ class SelfSignedTlsDeployer(Deployer):
def configure(self): def configure(self):
args = openssl_selfsigned_args( args = openssl_selfsigned_args(
self.mail_domain, self.mail_domain, self.cert_path, self.key_path,
self.cert_path,
self.key_path,
) )
cmd = shlex.join(args) cmd = shlex.join(args)
server.shell( server.shell(

View File

@@ -30,15 +30,12 @@ def test_newemail_configure(maildomain, rpc, chatmail_config):
# set_config_from_qr, so fetch credentials via requests instead # set_config_from_qr, so fetch credentials via requests instead
res = requests.post(f"https://{maildomain}/new", verify=False) res = requests.post(f"https://{maildomain}/new", verify=False)
data = res.json() data = res.json()
rpc.add_or_update_transport( rpc.add_or_update_transport(account_id, {
account_id, "addr": data["email"],
{ "password": data["password"],
"addr": data["email"], "imapServer": maildomain,
"password": data["password"], "smtpServer": maildomain,
"imapServer": maildomain, "certificateChecks": "acceptInvalidCertificates",
"smtpServer": maildomain, })
"certificateChecks": "acceptInvalidCertificates",
},
)
else: else:
rpc.add_transport_from_qr(account_id, url) rpc.add_transport_from_qr(account_id, url)

View File

@@ -6,8 +6,8 @@ import imap_tools
import pytest import pytest
import requests import requests
from cmdeploy.cmdeploy import get_sshexec
from cmdeploy.remote import rshell from cmdeploy.remote import rshell
from cmdeploy.cmdeploy import get_sshexec
@pytest.fixture @pytest.fixture

View File

@@ -399,12 +399,9 @@ class Remote:
getjournal = "journalctl -f" if not logcmd else logcmd getjournal = "journalctl -f" if not logcmd else logcmd
print(self.sshdomain) print(self.sshdomain)
match self.sshdomain: match self.sshdomain:
case "@local": case "@local": command = []
command = [] case "localhost": command = []
case "localhost": case _: command = ["ssh", f"root@{self.sshdomain}"]
command = []
case _:
command = ["ssh", f"root@{self.sshdomain}"]
[command.append(arg) for arg in getjournal.split()] [command.append(arg) for arg in getjournal.split()]
self.popen = subprocess.Popen( self.popen = subprocess.Popen(
command, command,