stages/systemd: ability to mask services

Add the ability to mask services, which is done e.g. when building
installers. See systemctl(1) for more information about masked
services.
Modify the existing stage test to include a test for it.
This commit is contained in:
Christian Kellner 2020-06-11 12:46:01 +02:00
parent 3d13c825c0
commit 7ac8f41798
3 changed files with 13 additions and 0 deletions

View file

@ -31,6 +31,11 @@ SCHEMA = """
"items": { "type": "string" },
"description": "Array of systemd unit names to be enabled"
},
"masked_services": {
"type": "array",
"items": { "type": "string" },
"description": "Array of systemd unit names to be masked"
},
"default_target": {
"type": "string",
"description": "The default target to boot into"
@ -41,6 +46,7 @@ SCHEMA = """
def main(tree, options):
enabled_services = options["enabled_services"]
disabled_services = options.get("disabled_services", [])
masked_services = options.get("masked_services", [])
default_target = options.get("default_target")
for service in enabled_services:
@ -49,6 +55,9 @@ def main(tree, options):
for service in disabled_services:
subprocess.run(["systemctl", "--root", tree, "disable", service], check=True)
for service in masked_services:
subprocess.run(["systemctl", "--root", tree, "mask", service], check=True)
if default_target:
subprocess.run(["systemctl", "--root", tree, "set-default", default_target], check=True)

View file

@ -826,6 +826,9 @@
"enabled_services": [
"nftables"
],
"masked_services": [
"ldconfig"
],
"disabled_services": [
"sshd"
]

View file

@ -1,5 +1,6 @@
{
"added_files": [
"/etc/systemd/system/ldconfig.service",
"/etc/systemd/system/multi-user.target.wants/nftables.service"
],
"deleted_files": [