diff --git a/stages/org.osbuild.systemd.unit.create b/stages/org.osbuild.systemd.unit.create index 3329da6e..38e7e18f 100755 --- a/stages/org.osbuild.systemd.unit.create +++ b/stages/org.osbuild.systemd.unit.create @@ -23,6 +23,9 @@ def main(tree, options): for option, value in opts.items(): if isinstance(value, list): for v in value: + if option == "Environment": + # Option value becomes "KEY=VALUE" (quoted) + v = '"' + v["key"] + "=" + str(v["value"]) + '"' config.set(section, str(option) + "=" + str(v)) else: config.set(section, option, str(value)) diff --git a/stages/org.osbuild.systemd.unit.create.meta.json b/stages/org.osbuild.systemd.unit.create.meta.json index adb652ac..d64d01ec 100644 --- a/stages/org.osbuild.systemd.unit.create.meta.json +++ b/stages/org.osbuild.systemd.unit.create.meta.json @@ -24,6 +24,8 @@ " - 'ExecStartPre' - [string]", " - 'ExecStopPost' - [string]", " - 'ExecStart' - [string]", + " - 'Environment' - [object]", + " - 'EnvironmentFile' - [string]", " - 'Install' section", " - 'WantedBy' - [string]", " - 'RequiredBy' - [string]" @@ -142,6 +144,31 @@ "items": { "type": "string" } + }, + "Environment": { + "type": "array", + "description": "Sets environment variables for executed process.", + "items": { + "type": "object", + "description": "Sets environment variables for executed process.", + "additionalProperties": false, + "properties": { + "key": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*" + }, + "value": { + "type": "string" + } + } + } + }, + "EnvironmentFile": { + "type": "array", + "description": "Path to file that contains environment variables to set for the process.", + "items": { + "type": "string" + } } } },