## YaST2 System Services (Runlevel) Configuration Tool

### Purpose

- setting default runlevel
- setting which runlevels services run in

### Pre-requisites

System services (runlevel editor) strongly depends on SuSE Linux conventions. Expected `/etc/inittab` format:

- Default runlevel: is read from line `^id:.:initdefault:` where it is supposed that default runlevel is at the place of .
- List of runlevels: It is supposed that runlevels are changed via running script `/etc/init.d/rc`. So to get list of runlevels we search for parameters given to this script, because this script expects runlevel name as an argument. We search for: `/^[^#]..*\/etc\/init\.d\/rc ARGUMENT`.

Current runlevel is read from output of `/sbin/runlevel`.
List of init scripts is obtained from `/etc/init.d/`. Some names are skipped, because they are not init scripts: `core, README, rc, rx, *.rpm*, *.ba*, *~, ...` . For each init script, comment is read and default runlevels and description are taken from it. See LSB for specification of init script comments. Current settings, which mean list of runlevels service is started in is taken from `/etc/init.d/rc?.d` subdirectories. E.g. if there is a script `/etc/init.d/rc5.d/S08network` then it means that service `network` is started in runlevel 5.
Service status is obtained by running `initscript status`.

### Functionality

Now as we have all settings read, we may change them. Changing default runlevel is straightforward. Just pick a new value from combobox. Note that this setting means which runlevel system switches to after boot!!! So this option has no immediate effect.
Detailed service editation enable changing which runlevels service runs in. Some special options are available: FIXME: WILL WE USE START_VARIABLES?

- Reset to default which resets service to state after installation. If service was installed disabled, it will be disabled after this action!
- Reset all services to default does the same for all services.
- Enable the service enables disabled service and lets it run in runlevels default for it. If you want to know which runlevels are default to service, look into its init script (`/etc/init.d/service_name_as_seen_in_runlevel_editor`).

All above settings are saved after button [Finish] is pressed. But following operations happen immediately:

- Start service
- Stop service
- Refresh status

### Saving

Default runlevel is saved to the same place it was read from.
Services are saved using
`/sbin/insserv -r servicename`
`/sbin/insserv servicename,start=list_of_runlevels`