chore: un-hardcode executable paths in some systemd service files

makes it consistent with the other services.
This commit is contained in:
holger krekel
2026-08-25 17:30:32 +02:00
parent 2af8d0e7b5
commit 1f0ddb7e5b
11 changed files with 43 additions and 18 deletions
+9 -3
View File
@@ -4,6 +4,8 @@ from ..basedeploy import Deployer
class AcmetoolDeployer(Deployer): class AcmetoolDeployer(Deployer):
bin_path = "/usr/bin/acmetool"
def __init__(self, email, domains): def __init__(self, email, domains):
self.domains = domains self.domains = domains
self.email = email self.email = email
@@ -41,8 +43,12 @@ class AcmetoolDeployer(Deployer):
domains=self.domains, domains=self.domains,
) )
self.ensure_systemd_unit("acmetool/acmetool-redirector.service") self.ensure_systemd_unit(
self.ensure_systemd_unit("acmetool/acmetool-reconcile.service") "acmetool/acmetool-redirector.service.j2", bin_path=self.bin_path
)
self.ensure_systemd_unit(
"acmetool/acmetool-reconcile.service.j2", bin_path=self.bin_path
)
self.ensure_systemd_unit("acmetool/acmetool-reconcile.timer") self.ensure_systemd_unit("acmetool/acmetool-reconcile.timer")
def activate(self): def activate(self):
@@ -52,5 +58,5 @@ class AcmetoolDeployer(Deployer):
server.shell( server.shell(
name=f"Reconcile certificates for: {', '.join(self.domains)}", name=f"Reconcile certificates for: {', '.join(self.domains)}",
commands=["acmetool --batch --xlog.severity=debug reconcile"], commands=[f"{self.bin_path} --batch --xlog.severity=debug reconcile"],
) )
@@ -4,5 +4,5 @@ After=network.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=/usr/bin/acmetool --batch reconcile ExecStart={{ bin_path }} --batch reconcile
@@ -3,7 +3,7 @@ Description=acmetool HTTP redirector
[Service] [Service]
Type=notify Type=notify
ExecStart=/usr/bin/acmetool redirector --service.uid=daemon --bind=127.0.0.1:402 ExecStart={{ bin_path }} redirector --service.uid=daemon --bind=127.0.0.1:402
Restart=always Restart=always
RestartSec=30 RestartSec=30
+2 -1
View File
@@ -51,7 +51,7 @@ def get_resource(arg, pkg=__package__):
return importlib.resources.files(pkg).joinpath(arg) return importlib.resources.files(pkg).joinpath(arg)
def configure_remote_units(deployer, mail_domain, units) -> None: def configure_remote_units(deployer, mail_domain, units, **kwargs) -> None:
remote_base_dir = "/usr/local/lib/chatmaild" remote_base_dir = "/usr/local/lib/chatmaild"
remote_venv_dir = f"{remote_base_dir}/venv" remote_venv_dir = f"{remote_base_dir}/venv"
remote_chatmail_inipath = f"{remote_base_dir}/chatmail.ini" remote_chatmail_inipath = f"{remote_base_dir}/chatmail.ini"
@@ -63,6 +63,7 @@ def configure_remote_units(deployer, mail_domain, units) -> None:
config_path=remote_chatmail_inipath, config_path=remote_chatmail_inipath,
remote_venv_dir=remote_venv_dir, remote_venv_dir=remote_venv_dir,
mail_domain=mail_domain, mail_domain=mail_domain,
**kwargs,
) )
basename = fn if "." in fn else f"{fn}.service" basename = fn if "." in fn else f"{fn}.service"
+16 -5
View File
@@ -301,6 +301,8 @@ def check_config(config):
class TurnDeployer(Deployer): class TurnDeployer(Deployer):
bin_path = "/usr/local/bin/chatmail-turn"
def __init__(self, mail_domain): def __init__(self, mail_domain):
self.mail_domain = mail_domain self.mail_domain = mail_domain
self.units = ["turnserver"] self.units = ["turnserver"]
@@ -316,16 +318,21 @@ class TurnDeployer(Deployer):
"0fb3e792419494e21ecad536464929dba706bb2c88884ed8f1788141d26fc756", "0fb3e792419494e21ecad536464929dba706bb2c88884ed8f1788141d26fc756",
), ),
}[host.get_fact(facts.server.Arch)] }[host.get_fact(facts.server.Arch)]
self.download_executable(url, "/usr/local/bin/chatmail-turn", sha256sum) self.download_executable(url, self.bin_path, sha256sum)
def configure(self): def configure(self):
configure_remote_units(self, self.mail_domain, self.units) configure_remote_units(
self, self.mail_domain, self.units, bin_path=self.bin_path
)
def activate(self): def activate(self):
activate_remote_units(self, self.units) activate_remote_units(self, self.units)
class IrohDeployer(Deployer): class IrohDeployer(Deployer):
bin_path = "/usr/local/bin/iroh-relay"
config_path = "/etc/iroh-relay.toml"
def __init__(self, enable_iroh_relay): def __init__(self, enable_iroh_relay):
self.enable_iroh_relay = enable_iroh_relay self.enable_iroh_relay = enable_iroh_relay
@@ -342,14 +349,18 @@ class IrohDeployer(Deployer):
}[host.get_fact(facts.server.Arch)] }[host.get_fact(facts.server.Arch)]
self.download_executable( self.download_executable(
url, url,
"/usr/local/bin/iroh-relay", self.bin_path,
sha256sum, sha256sum,
extract="gunzip | tar -xf - ./iroh-relay -O", extract="gunzip | tar -xf - ./iroh-relay -O",
) )
def configure(self): def configure(self):
self.ensure_systemd_unit("iroh-relay.service") self.ensure_systemd_unit(
self.put_file("iroh-relay.toml", "/etc/iroh-relay.toml") "iroh-relay.service.j2",
bin_path=self.bin_path,
config_path=self.config_path,
)
self.put_file("iroh-relay.toml", self.config_path)
def activate(self): def activate(self):
self.ensure_service( self.ensure_service(
@@ -2,7 +2,7 @@
Description=Iroh relay Description=Iroh relay
[Service] [Service]
ExecStart=/usr/local/bin/iroh-relay --config-path /etc/iroh-relay.toml ExecStart={{ bin_path }} --config-path {{ config_path }}
Restart=on-failure Restart=on-failure
RestartSec=5s RestartSec=5s
User=iroh User=iroh
+9 -2
View File
@@ -5,6 +5,9 @@ from cmdeploy.basedeploy import Deployer
class MtailDeployer(Deployer): class MtailDeployer(Deployer):
bin_path = "/usr/local/bin/mtail"
progs_dir = "/etc/mtail"
def __init__(self, mtail_address): def __init__(self, mtail_address):
self.mtail_address = mtail_address self.mtail_address = mtail_address
@@ -24,7 +27,7 @@ class MtailDeployer(Deployer):
}[host.get_fact(facts.server.Arch)] }[host.get_fact(facts.server.Arch)]
self.download_executable( self.download_executable(
url, url,
"/usr/local/bin/mtail", self.bin_path,
sha256sum, sha256sum,
extract="gunzip | tar -xf - mtail -O", extract="gunzip | tar -xf - mtail -O",
) )
@@ -36,8 +39,12 @@ class MtailDeployer(Deployer):
"mtail/mtail.service.j2", "mtail/mtail.service.j2",
address=self.mtail_address or "127.0.0.1", address=self.mtail_address or "127.0.0.1",
port=3903, port=3903,
bin_path=self.bin_path,
progs_dir=self.progs_dir,
)
self.put_file(
"mtail/delivered_mail.mtail", f"{self.progs_dir}/delivered_mail.mtail"
) )
self.put_file("mtail/delivered_mail.mtail", "/etc/mtail/delivered_mail.mtail")
def activate(self): def activate(self):
active = bool(self.mtail_address) active = bool(self.mtail_address)
+1 -1
View File
@@ -5,7 +5,7 @@ Wants=network-online.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/bin/sh -c "journalctl -f -o short-iso -n 0 | /usr/local/bin/mtail --address={{ address }} --port={{ port }} --progs /etc/mtail --logtostderr --logs -" ExecStart=/bin/sh -c "journalctl -f -o short-iso -n 0 | {{ bin_path }} --address={{ address }} --port={{ port }} --progs {{ progs_dir }} --logtostderr --logs -"
Restart=on-failure Restart=on-failure
RestartSec=2s RestartSec=2s
@@ -5,5 +5,5 @@ After=network.target
[Service] [Service]
Type=oneshot Type=oneshot
User=vmail User=vmail
ExecStart=/usr/local/lib/chatmaild/venv/bin/chatmail-expire /usr/local/lib/chatmaild/chatmail.ini -v --remove ExecStart={execpath} {config_path} -v --remove
@@ -5,5 +5,5 @@ After=network.target
[Service] [Service]
Type=oneshot Type=oneshot
User=vmail User=vmail
ExecStart=/usr/local/lib/chatmaild/venv/bin/chatmail-fsreport /usr/local/lib/chatmaild/chatmail.ini ExecStart={execpath} {config_path}
@@ -5,7 +5,7 @@ After=network.target
[Service] [Service]
Type=simple Type=simple
Restart=always Restart=always
ExecStart=/usr/local/bin/chatmail-turn --realm {mail_domain} --socket /run/chatmail-turn/turn.socket ExecStart={bin_path} --realm {mail_domain} --socket /run/chatmail-turn/turn.socket
# Create /run/chatmail-turn # Create /run/chatmail-turn
RuntimeDirectory=chatmail-turn RuntimeDirectory=chatmail-turn