|
2 | 2 | Chat Mail pyinfra deploy. |
3 | 3 | """ |
4 | 4 |
|
| 5 | +import os |
5 | 6 | import shutil |
6 | 7 | import subprocess |
7 | 8 | import sys |
|
26 | 27 | activate_remote_units, |
27 | 28 | configure_remote_units, |
28 | 29 | get_resource, |
| 30 | + has_systemd, |
29 | 31 | ) |
30 | 32 | from .dovecot.deployer import DovecotDeployer |
31 | 33 | from .filtermail.deployer import FiltermailDeployer |
@@ -66,6 +68,8 @@ def _build_chatmaild(dist_dir) -> None: |
66 | 68 |
|
67 | 69 |
|
68 | 70 | def remove_legacy_artifacts(): |
| 71 | + if not has_systemd(): |
| 72 | + return |
69 | 73 | # disable legacy doveauth-dictproxy.service |
70 | 74 | if host.get_fact(SystemdEnabled).get("doveauth-dictproxy.service"): |
71 | 75 | systemd.service( |
@@ -300,7 +304,7 @@ def install(self): |
300 | 304 | present=False, |
301 | 305 | ) |
302 | 306 | # remove echobot if it is still running |
303 | | - if host.get_fact(SystemdEnabled).get("echobot.service"): |
| 307 | + if has_systemd() and host.get_fact(SystemdEnabled).get("echobot.service"): |
304 | 308 | systemd.service( |
305 | 309 | name="Disable echobot.service", |
306 | 310 | service="echobot.service", |
@@ -567,37 +571,38 @@ def deploy_chatmail(config_path: Path, disable_mail: bool, website_only: bool) - |
567 | 571 | Out().red(f"Deploy failed: mtail_address {config.mtail_address} is not available (VPN up?).\n") |
568 | 572 | exit(1) |
569 | 573 |
|
570 | | - port_services = [ |
571 | | - (["master", "smtpd"], 25), |
572 | | - ("unbound", 53), |
573 | | - ] |
574 | | - if config.tls_cert_mode == "acme": |
575 | | - port_services.append(("acmetool", 80)) |
576 | | - port_services += [ |
577 | | - (["imap-login", "dovecot"], 143), |
578 | | - ("nginx", 443), |
579 | | - (["master", "smtpd"], 465), |
580 | | - (["master", "smtpd"], 587), |
581 | | - (["imap-login", "dovecot"], 993), |
582 | | - ("iroh-relay", 3340), |
583 | | - ("mtail", 3903), |
584 | | - ("stats", 3904), |
585 | | - ("nginx", 8443), |
586 | | - (["master", "smtpd"], config.postfix_reinject_port), |
587 | | - (["master", "smtpd"], config.postfix_reinject_port_incoming), |
588 | | - ("filtermail", config.filtermail_smtp_port), |
589 | | - ("filtermail", config.filtermail_smtp_port_incoming), |
590 | | - ] |
591 | | - for service, port in port_services: |
592 | | - print(f"Checking if port {port} is available for {service}...") |
593 | | - running_service = host.get_fact(Port, port=port) |
594 | | - services = [service] if isinstance(service, str) else service |
595 | | - if running_service: |
596 | | - if running_service not in services: |
597 | | - Out().red( |
598 | | - f"Deploy failed: port {port} is occupied by: {running_service}" |
599 | | - ) |
600 | | - exit(1) |
| 574 | + if not os.environ.get("CHATMAIL_NOPORTCHECK"): |
| 575 | + port_services = [ |
| 576 | + (["master", "smtpd"], 25), |
| 577 | + ("unbound", 53), |
| 578 | + ] |
| 579 | + if config.tls_cert_mode == "acme": |
| 580 | + port_services.append(("acmetool", 80)) |
| 581 | + port_services += [ |
| 582 | + (["imap-login", "dovecot"], 143), |
| 583 | + ("nginx", 443), |
| 584 | + (["master", "smtpd"], 465), |
| 585 | + (["master", "smtpd"], 587), |
| 586 | + (["imap-login", "dovecot"], 993), |
| 587 | + ("iroh-relay", 3340), |
| 588 | + ("mtail", 3903), |
| 589 | + ("stats", 3904), |
| 590 | + ("nginx", 8443), |
| 591 | + (["master", "smtpd"], config.postfix_reinject_port), |
| 592 | + (["master", "smtpd"], config.postfix_reinject_port_incoming), |
| 593 | + ("filtermail", config.filtermail_smtp_port), |
| 594 | + ("filtermail", config.filtermail_smtp_port_incoming), |
| 595 | + ] |
| 596 | + for service, port in port_services: |
| 597 | + print(f"Checking if port {port} is available for {service}...") |
| 598 | + running_service = host.get_fact(Port, port=port) |
| 599 | + services = [service] if isinstance(service, str) else service |
| 600 | + if running_service: |
| 601 | + if running_service not in services: |
| 602 | + Out().red( |
| 603 | + f"Deploy failed: port {port} is occupied by: {running_service}" |
| 604 | + ) |
| 605 | + exit(1) |
601 | 606 |
|
602 | 607 | tls_domains = [mail_domain, f"mta-sts.{mail_domain}", f"www.{mail_domain}"] |
603 | 608 |
|
|
0 commit comments