mirror of
https://github.com/chatmail/relay.git
synced 2026-05-20 12:58:04 +00:00
remove static method and Make Deployer instances not set any default state
This commit is contained in:
@@ -273,11 +273,9 @@ class OpendkimDeployer(Deployer):
|
|||||||
required_users = [("opendkim", None, ["opendkim"])]
|
required_users = [("opendkim", None, ["opendkim"])]
|
||||||
|
|
||||||
def __init__(self, *, mail_domain, **kwargs):
|
def __init__(self, *, mail_domain, **kwargs):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.mail_domain = mail_domain
|
self.mail_domain = mail_domain
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
apt.packages(
|
apt.packages(
|
||||||
name="apt install opendkim opendkim-tools",
|
name="apt install opendkim opendkim-tools",
|
||||||
packages=["opendkim", "opendkim-tools"],
|
packages=["opendkim", "opendkim-tools"],
|
||||||
@@ -299,8 +297,7 @@ class OpendkimDeployer(Deployer):
|
|||||||
|
|
||||||
|
|
||||||
class UnboundDeployer(Deployer):
|
class UnboundDeployer(Deployer):
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
# Run local DNS resolver `unbound`.
|
# Run local DNS resolver `unbound`.
|
||||||
# `resolvconf` takes care of setting up /etc/resolv.conf
|
# `resolvconf` takes care of setting up /etc/resolv.conf
|
||||||
# to use 127.0.0.1 as the resolver.
|
# to use 127.0.0.1 as the resolver.
|
||||||
@@ -424,13 +421,11 @@ class PostfixDeployer(Deployer):
|
|||||||
required_users = [("postfix", None, ["opendkim"]),]
|
required_users = [("postfix", None, ["opendkim"]),]
|
||||||
|
|
||||||
def __init__(self, *, config, disable_mail, **kwargs):
|
def __init__(self, *, config, disable_mail, **kwargs):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.disable_mail = disable_mail
|
self.disable_mail = disable_mail
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
apt.packages(
|
apt.packages(
|
||||||
name="Install Postfix",
|
name="Install Postfix",
|
||||||
packages="postfix",
|
packages="postfix",
|
||||||
@@ -553,14 +548,12 @@ def _configure_dovecot(config: Config, debug: bool = False) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
class DovecotDeployer(Deployer):
|
class DovecotDeployer(Deployer):
|
||||||
def __init__(self, *, config, disable_mail, **kwargs):
|
def __init__(self, *, config, disable_mail):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.disable_mail = disable_mail
|
self.disable_mail = disable_mail
|
||||||
self.units = ["doveauth"]
|
self.units = ["doveauth"]
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
arch = host.get_fact(facts.server.Arch)
|
arch = host.get_fact(facts.server.Arch)
|
||||||
if not "dovecot.service" in host.get_fact(SystemdEnabled):
|
if not "dovecot.service" in host.get_fact(SystemdEnabled):
|
||||||
_install_dovecot_package("core", arch)
|
_install_dovecot_package("core", arch)
|
||||||
@@ -644,12 +637,10 @@ def _configure_nginx(config: Config, debug: bool = False) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
class NginxDeployer(Deployer):
|
class NginxDeployer(Deployer):
|
||||||
def __init__(self, *, config, **kwargs):
|
def __init__(self, *, config):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
#
|
#
|
||||||
# If we allow nginx to start up on install, it will grab port
|
# If we allow nginx to start up on install, it will grab port
|
||||||
# 80, which then will block acmetool from listening on the port.
|
# 80, which then will block acmetool from listening on the port.
|
||||||
@@ -699,12 +690,10 @@ class NginxDeployer(Deployer):
|
|||||||
|
|
||||||
|
|
||||||
class WebsiteDeployer(Deployer):
|
class WebsiteDeployer(Deployer):
|
||||||
def __init__(self, *, config, **kwargs):
|
def __init__(self, *, config):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
files.directory(
|
files.directory(
|
||||||
name="Ensure /var/www exists",
|
name="Ensure /var/www exists",
|
||||||
path="/var/www",
|
path="/var/www",
|
||||||
@@ -732,8 +721,7 @@ class WebsiteDeployer(Deployer):
|
|||||||
|
|
||||||
|
|
||||||
class RspamdDeployer(Deployer):
|
class RspamdDeployer(Deployer):
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
apt.packages(name="Remove rspamd", packages="rspamd", present=False)
|
apt.packages(name="Remove rspamd", packages="rspamd", present=False)
|
||||||
|
|
||||||
|
|
||||||
@@ -753,13 +741,11 @@ def check_config(config):
|
|||||||
|
|
||||||
|
|
||||||
class TurnDeployer(Deployer):
|
class TurnDeployer(Deployer):
|
||||||
def __init__(self, *, mail_domain, **kwargs):
|
def __init__(self, *, mail_domain):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.mail_domain = mail_domain
|
self.mail_domain = mail_domain
|
||||||
self.units = ["turnserver"]
|
self.units = ["turnserver"]
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
(url, sha256sum) = {
|
(url, sha256sum) = {
|
||||||
"x86_64": (
|
"x86_64": (
|
||||||
"https://github.com/chatmail/chatmail-turn/releases/download/v0.3/chatmail-turn-x86_64-linux",
|
"https://github.com/chatmail/chatmail-turn/releases/download/v0.3/chatmail-turn-x86_64-linux",
|
||||||
@@ -789,12 +775,10 @@ class TurnDeployer(Deployer):
|
|||||||
|
|
||||||
|
|
||||||
class MtailDeployer(Deployer):
|
class MtailDeployer(Deployer):
|
||||||
def __init__(self, *, mtail_address, **kwargs):
|
def __init__(self, *, mtail_address):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.mtail_address = mtail_address
|
self.mtail_address = mtail_address
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
# Uninstall mtail package, we are going to install a static binary.
|
# Uninstall mtail package, we are going to install a static binary.
|
||||||
apt.packages(name="Uninstall mtail", packages=["mtail"], present=False)
|
apt.packages(name="Uninstall mtail", packages=["mtail"], present=False)
|
||||||
|
|
||||||
@@ -856,12 +840,10 @@ class MtailDeployer(Deployer):
|
|||||||
|
|
||||||
|
|
||||||
class IrohDeployer(Deployer):
|
class IrohDeployer(Deployer):
|
||||||
def __init__(self, *, enable_iroh_relay, **kwargs):
|
def __init__(self, *, enable_iroh_relay):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.enable_iroh_relay = enable_iroh_relay
|
self.enable_iroh_relay = enable_iroh_relay
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
(url, sha256sum) = {
|
(url, sha256sum) = {
|
||||||
"x86_64": (
|
"x86_64": (
|
||||||
"https://github.com/n0-computer/iroh/releases/download/v0.35.0/iroh-relay-v0.35.0-x86_64-unknown-linux-musl.tar.gz",
|
"https://github.com/n0-computer/iroh/releases/download/v0.35.0/iroh-relay-v0.35.0-x86_64-unknown-linux-musl.tar.gz",
|
||||||
@@ -950,13 +932,11 @@ class EchobotDeployer(Deployer):
|
|||||||
# it needs to base its decision of whether to restart the service on
|
# it needs to base its decision of whether to restart the service on
|
||||||
# whether those two services were restarted.
|
# whether those two services were restarted.
|
||||||
#
|
#
|
||||||
def __init__(self, *, mail_domain, **kwargs):
|
def __init__(self, *, mail_domain):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.mail_domain = mail_domain
|
self.mail_domain = mail_domain
|
||||||
self.units = ["echobot"]
|
self.units = ["echobot"]
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
apt.packages(
|
apt.packages(
|
||||||
# required for setfacl for echobot
|
# required for setfacl for echobot
|
||||||
name="Install acl",
|
name="Install acl",
|
||||||
@@ -971,8 +951,7 @@ class EchobotDeployer(Deployer):
|
|||||||
|
|
||||||
|
|
||||||
class ChatmailVenvDeployer(Deployer):
|
class ChatmailVenvDeployer(Deployer):
|
||||||
def __init__(self, *, config, **kwargs):
|
def __init__(self, *, config):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.config = config
|
self.config = config
|
||||||
self.units = (
|
self.units = (
|
||||||
"filtermail",
|
"filtermail",
|
||||||
@@ -985,8 +964,7 @@ class ChatmailVenvDeployer(Deployer):
|
|||||||
"chatmail-fsreport.timer",
|
"chatmail-fsreport.timer",
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
_install_remote_venv_with_chatmaild()
|
_install_remote_venv_with_chatmaild()
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
@@ -1003,12 +981,10 @@ class ChatmailDeployer(Deployer):
|
|||||||
("echobot", None, None),
|
("echobot", None, None),
|
||||||
("iroh", None, None),
|
("iroh", None, None),
|
||||||
]
|
]
|
||||||
def __init__(self, *, mail_domain, **kwargs):
|
def __init__(self, *, mail_domain):
|
||||||
super().__init__(**kwargs)
|
|
||||||
self.mail_domain = mail_domain
|
self.mail_domain = mail_domain
|
||||||
|
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
# Remove OBS repository key that is no longer used.
|
# Remove OBS repository key that is no longer used.
|
||||||
files.file("/etc/apt/keyrings/obs-home-deltachat.gpg", present=False)
|
files.file("/etc/apt/keyrings/obs-home-deltachat.gpg", present=False)
|
||||||
|
|
||||||
@@ -1049,8 +1025,7 @@ class ChatmailDeployer(Deployer):
|
|||||||
|
|
||||||
|
|
||||||
class FcgiwrapDeployer(Deployer):
|
class FcgiwrapDeployer(Deployer):
|
||||||
@staticmethod
|
def install(self):
|
||||||
def install():
|
|
||||||
apt.packages(
|
apt.packages(
|
||||||
name="Install fcgiwrap",
|
name="Install fcgiwrap",
|
||||||
packages=["fcgiwrap"],
|
packages=["fcgiwrap"],
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ class Deployment:
|
|||||||
system=True,
|
system=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
deployer.need_restart |= bool(deployer.install())
|
ret = bool(deployer.install())
|
||||||
|
if ret:
|
||||||
|
deployer.need_restart = True
|
||||||
|
|
||||||
def configure(self, deployer):
|
def configure(self, deployer):
|
||||||
deployer.configure()
|
deployer.configure()
|
||||||
@@ -45,16 +47,9 @@ class Deployment:
|
|||||||
|
|
||||||
|
|
||||||
class Deployer:
|
class Deployer:
|
||||||
|
need_restart = False
|
||||||
|
|
||||||
def __init__(self):
|
def install(self):
|
||||||
self.need_restart = False
|
|
||||||
|
|
||||||
#
|
|
||||||
# If a subclass overrides this with a method that returns a true
|
|
||||||
# value, self.need_restart will be set when install() is called.
|
|
||||||
#
|
|
||||||
@staticmethod
|
|
||||||
def install():
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user