[services-openrc] Make list of services more flexible

- Allow just a name entry, instead of requiring an object
   entry; this makes "foo" equal to { name: "foo", runlevel: "default" }
   and simplifies more for the straightfoward case of #974.
This commit is contained in:
Adriaan de Groot 2018-06-27 10:28:32 -04:00
parent b02ee3cd8d
commit 72c0d1a101
2 changed files with 10 additions and 2 deletions

View File

@ -53,8 +53,12 @@ class OpenrcController:
"""
for svc in self.services.get(state, []):
name = svc["name"]
runlevel = svc.get("runlevel", "default")
if isinstance(svc, str):
name = svc
runlevel = "default"
else:
name = svc["name"]
runlevel = svc.get("runlevel", "default")
service_path = self.root + self.initdDir + "/" + name
runlevel_path = self.root + self.runlevelsDir + "/" + runlevel

View File

@ -20,11 +20,14 @@ runlevelsDir: /etc/runlevels
# - name: the service name
# - runlevel: can hold any runlevel present on the target system;
# if no runlevel is provided, "default" is assumed.
# an entry may also be a single string, which is interpreted
# as the name field (runlevel "default" is assumed then).
#
# # Example services and disable settings:
# # - add foo1 to default
# # - add foo2 to nonetwork
# # - remove foo3 from default
# # - remove foo4 from default
# services:
# - name: foo1
# - name: foo2
@ -32,6 +35,7 @@ runlevelsDir: /etc/runlevels
# disable:
# - name: foo3
# runlevel: default
# - foo4
services: []
disable: []