Files
euri-mklive/euri_mklive/dinit.py
T

96 lines
2.0 KiB
Python
Raw Normal View History

"""Dinit service definitions — real service files, not symlinks."""
SERVICES = {
"connmand": {
"connmand": """\
description = "ConnMan Network Manager Daemon"
requires = network-setup.service
accept-notify = false
service openrc-style {
pid-file = /run/connman/connmand.pid
reader = syslog
command = /usr/sbin/connmand -n
env_file = /etc/conf.d/connmand
}
""",
},
"sddm": {
"sddm": """\
description = "SDDM Display Manager"
requires = background-setup.service
accept-notify = false
service openrc-style {
pid-file = /run/sddm/pid
reader = syslog
command = /usr/bin/sddm
}
""",
},
"ntpd": {
"ntpd": """\
description = "NTP Daemon"
accept-notify = false
service openrc-style {
pid-file = /run/ntpd.pid
reader = syslog
command = /usr/sbin/ntpd -g
}
""",
},
"chrony": {
"chrony": """\
description = "Chrony NTP Daemon"
accept-notify = false
service openrc-style {
pid-file = /run/chrony/chronyd.pid
reader = syslog
command = /usr/sbin/chronyd -d
env_file = /etc/conf.d/chronyd
}
""",
},
"sshd": {
"sshd": """\
description = "OpenSSH Server"
accept-notify = false
service openrc-style {
pid-file = /run/sshd.pid
reader = syslog
command = /usr/sbin/sshd -D
}
""",
},
}
def install_service(rootfs, name: str) -> None:
"""Install a dinit service file into the rootfs."""
if name not in SERVICES:
raise ValueError(f"Unknown dinit service: {name}")
services = SERVICES[name]
for svc_name, content in services.items():
svc_dir = rootfs / f"/etc/dinit.d/{svc_name}"
svc_dir.mkdir(parents=True, exist_ok=True)
(svc_dir / "run").write_text(content)
def install_all(rootfs, services: list[str]) -> None:
"""Install all requested dinit services."""
for svc in services:
try:
install_service(rootfs, svc)
except ValueError as e:
print(f" \033[33m⚠ {e}\033[0m")