YaST2 Developers Documentation: yast2



functions
files
intro

yast2

modules/Service.ycp
Service manipulation
Functions for service (init script) handling used by other modules.

Structures

Global Functions

Local Variables

Local Functions

Info:

Structure service

 One service is described by such map: 
  "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?
  ]

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 Never cleared.

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:
does the service exist?

global Info (string name) -> map

Get service info without peeking if service runs.

Parameters:
name name of the service
Return value:
service information or $[]

global Status (string name) -> integer

Get service status. It is output from "service status". It should conform to LSB. 0 means running.

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 finds out whether service is running.

Parameters:
name name of the service
Return value:
service map or $[]

local serviceDisable (string name, boolean force) -> boolean

Call insserv -r and record errors. Does not check if it exists

Parameters:
name service name
force pass "-f" to insserv (workaround for #17608, #27370)
Return value:
success state

global Adjust (string name, string action) -> boolean

Adjust runlevels in which service runs.

Parameters:
name service 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.

Parameters:
name name of service to adjust
rl list of runlevels in which service should start
Return value:
success state

global Enabled (string name) -> boolean

Returns true if any link in /etc/init.d/rc?.d/ exists for this script. If service does not exist, logs an error.

Parameters:
name service name
Return value:
true if service is set to run in any runlevel

global RunInitScript (string name, string param) -> integer

Run init script.

Parameters:
name init service name
param init script argument
Return value:
exit value

global RunInitScriptOutput (string name, string param) -> map

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

Parameters:
name init service name
param init script argument
Return value:
of $[ "stdout" : "...", "stderr" : "...", "exit" : int,]

global Enable (string service) -> boolean

Enable service

Parameters:
service service to be enabled
Return value:
true if success

global Disable (string service) -> boolean

Disable service

Parameters:
service service to be disabled
Return value:
true if success

global Start (string service) -> boolean

Start service

Parameters:
service service to be started
Return value:
true if success

global Restart (string service) -> boolean

Restart service

Parameters:
service service to be restarted
Return value:
true if success

global Reload (string service) -> boolean

Reload service

Parameters:
service service to be reloaded
Return value:
true if success

global Stop (string service) -> boolean

Stop service

Parameters:
service service to be stopped
Return value:
true if success

global Error () -> string

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

Return value:
error message from the last operation

YaST2 Developers Documentation