[services-openrc] Restrict actions

- Document the functions some more
 - Only "state" (i.e. action) "add" and "del" make sense,
   avoid calling rc-update for other keys (e.g. typo's).
   This matches the documentation, although there might be
   other actions that make sense (see also services-systemd,
   with its enable, disable and mask actions).
This commit is contained in:
Adriaan de Groot 2018-06-27 09:21:31 -04:00
parent b1881d1cd2
commit cd640bda9f

View File

@ -28,7 +28,10 @@ from os.path import exists, join
class OpenrcController: class OpenrcController:
"""This is the openrc service controller """
This is the openrc service controller.
All of its state comes from global storage and the job
configuration at initialization time.
""" """
def __init__(self): def __init__(self):
@ -38,7 +41,10 @@ class OpenrcController:
self.runlevelsDir = libcalamares.job.configuration['runlevelsDir'] self.runlevelsDir = libcalamares.job.configuration['runlevelsDir']
def update(self, state): def update(self, state):
"""call rc-update for each service listed """
Call rc-update for each service listed
in services for the given @p state. rc-update
is called with @p state as the command as well.
""" """
for svc in self.services[state]: for svc in self.services[state]:
@ -52,11 +58,12 @@ class OpenrcController:
"""Run the controller """Run the controller
""" """
for state in self.services.keys(): for state in ("add", "del"):
self.update(state) self.update(state)
def run(): def run():
"""Setup services """
Setup services
""" """
return OpenrcController().run() return OpenrcController().run()