YaST2 Developers Documentation: Unknown YCP Module

Unknown YCP Module

This module has an unstable interface.

Imports

  • FileUtils

Structures

Global Functions

Local Variables

Local Functions

Info:

File: modules/Service.ycp Package: yast2 Summary: Service manipulation Authors: Martin Vidner Petr Blahos Michal Svec Lukas Ocilka Flags: Stable

$Id$

Info:

Structure service

 One service is described by such map: <pre>
  "servicename" : $[
    "defstart" : [ "2", "3", "5", ], // Default-Start comment
    "defstop"  : [ "0", "1", "6", ], // Default-Stop  comment

    "reqstart" : [ "$network", "portmap" ], // Required-Start comment
    "reqstop"  : [ "$network", "portmap" ], // Required-Stop  comment

    "description" : "text...",       // Description comment

    "start" : [ "3", "5", ], // which runlevels service is really started/stopped in
    "stop"  : [ "3", "5", ], // read from /etc/init.d/rc?.d/* links

    "started" : 0, // return from rcservice status (integer)

    "dirty" : false, // was the entry changed?
  ]</pre>
local systemd_dirs -> list <string>

Unit locations for systemd

Info:

Init.d scripts location

local error_msg -> string

After a function returns an error, this holds an error message, including insserv stderr and possibly containing newlines.

Set by checkExists: [Full]Info, Status, Enabled, Adjust, Finetune

local checkExists (string name) -> boolean

Check that a service exists. If not, set error_msg.

Parameters:
name service name without a path, eg. nfsserver
Return value:
Return true if the service exists.
global GetUnitId (string unit) -> string

Get complete systemd unit id

Parameters:
unit
Return value:
(resolved) unit Id
global GetServiceId (string name) -> string

Get the name from a systemd service unit id without the .service suffix

Parameters:
name name or alias of the service
Return value:
(resolved) service name without the .service suffix
global Enabled (string name) -> boolean

Check if service is enabled (in any runlevel)

Forwards to chkconfig -l which decides between init and systemd

Parameters:
name service name
Return value:
true if service is set to run in any runlevel
global Info (string name) -> map

Get service info without peeking if service runs.

Parameters:
name name of the service
Return value:
Service information or empty map ($[])
global Status (string name) -> integer

Get service status.

Parameters:
name name of the service
Return value:
init script exit status or -1 if it does not exist
global FullInfo (string name) -> map

Get service info and find out whether service is running.

Parameters:
name name of the service
Return value:
service map or empty map ($[])
local serviceDisable (string name, boolean force) -> boolean

Disables a given service and records errors. Does not check if it exists.

Parameters:
name service name
force pass "--force" (workaround for #17608, #27370)
Return value:
success state
global Adjust (string name, string action) -> boolean

Adjusts runlevels in which the service runs.

Parameters:
name
action "disable" -- remove links, "enable" -- if there are no links, set default, otherwise do nothing, "default" -- set defaults.
Return value:
success state
global Finetune (string name, list rl) -> boolean

Set service to run in selected runlevels. Obsoleted - enables or disables the given service depending on the list of runlevels to start. If any runlevel is present, service is enabled, otherwise disabled.

Parameters:
name name of service to adjust
rl list of runlevels in which service should start
Return value:
success state
global RunInitScript (string name, string param) -> integer

Run init script.

Parameters:
name init service name
param init script argument
Return value:
exit value
global RunInitScriptWithTimeOut (string name, string param) -> integer

Run init script with a time-out.

Parameters:
name init service name
param init script argument
Return value:
exit value
global RunInitScriptOutput (string name, string param) -> map

Run init script and also return its output (stdout and stderr merged).

Parameters:
name init service name
param init script argument
Return value:
A map of $[ "stdout" : "...", "stderr" : "...", "exit" : int]
global Enable (string service) -> boolean

Enable service

Parameters:
service service to be enabled
Return value:
true if operation is successful
global Disable (string service) -> boolean

Disable service

Parameters:
service service to be disabled
Return value:
true if operation is successful
global Start (string service) -> boolean

Start service

Parameters:
service service to be started
Return value:
true if operation is successful
global Restart (string service) -> boolean

Restart service

Parameters:
service service to be restarted
Return value:
true if operation is successful
global Reload (string service) -> boolean

Reload service

Parameters:
service service to be reloaded
Return value:
true if operation is successful
global Stop (string service) -> boolean

Stop service

Parameters:
service service to be stopped
Return value:
true if operation is successful
global Error () -> string

Error Message

Return value:
error message from the last operation
global EnabledServices (integer runlevel) -> list<string>

Get list of enabled services in a runlevel

Parameters:
runlevel requested runlevel number (0-6, -1 = Single)
Return value:
enabled services
global Find (list <string> services) -> string

Return the first of the list of services which is available (has init script) or "" if none is.

Parameters:
services
Return value:
the first found service