# Which init scripts go in which runlevels?

## dcljr

I've had my Gentoo system for almost a year now, and I recently had to fix the "Broken runlevel entry" problem that many people have already posted about (just do a quick search for those words if you haven't seen the relevant threads). But after deleting and re-adding the scripts to the (supposedly) appropriate runlevels, I noticed that my domainname script is in both boot and default (it was actually that way before I fixed the problem, too). This seems to be atypical, shall we say, since everyone else's output of rc-update show I've seen in the forums has it only under one or the other. But that's the problem: some people have it in boot, some in default. So how am I supposed to know which runlevel it should be in? More generally, how do I know where any of my init scripts belong? Or even which ones I should or shouldn't be using? Is there an official source for such info? man rc-update didn't seem to help...

- dcljr

Edit: And the Initscripts chapter of the (for me, x86) Handbook, while relevant, is a bit dense and doesn't seem to address my question(s) directly.

----------

## Zepp

Maybe this will shed some light on how the whole system works and what the levels are for

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4

----------

## dcljr

Zepp, you must have been typing your reply just as I was adding the "Edit" to my message above. I did think to look at that exact page after I posted my original message, but it's far too general for what I'm talking about. It doesn't say things like, "The domainname script should be placed in the boot runlevel if <such-and-such-is-true>." Is there any such documentation out there?

- dcljr

----------

## dcljr

Well, looky there...

```
~ # cat /etc/init.d/domainname

#!/sbin/runscript

# Copyright 1999-2006 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

depend() {

        need checkroot hostname

        before bootmisc

}
```

Since I see the bootmisc script in my boot runlevel, I guess that answers one of my questions!

My more general questions still stand, though.

- dcljr

----------

## Zepp

From my understanding for most things it is really up to what you feel is appropriate. Of course certain things have to come before others like mounting file systems and such and dependencies as mention. But beyond that I think you can bring them up in what order you feel is good. I don't think there are anything that says concretely that this initscript must be run at this level, just that in some cases this service may require other services, so you just have to ensure they are run prior to.

----------

## rafo

I think dcljr's comment is quite valid. While it is true that Linux distributions in general, and Gentoo probably more than most, can be set up in a wide variety of ways, it would be useful to have a description of runlevels in a middle-of-the-road Gentoo installation.

This would in no way be meant to stop people from arranging their own runlevels; it would just be a piece of documentation to refer to when in doubt.

One may argue that there is no such as thing as a middle-of-the-road Gentoo installation. Well, then start from a virgin stage3 installation and add a bunch of commonly used daemons in a sensible fashion. If certain daemons could go in different runlevels, then explain the pros and cons.

I was sort of looking for that kind of documentation since I didn't immediately know where to have "domainname" launched. And I ended up in this thread.

----------

## rafo

I just learned that domainname has been dropped from Gentoo altogether. So don't go looking for where it should go like I did   :Wink: 

Shows that if "typical" runlevels are ever documented, that document will cost some maintenance effort too..

----------

## sf_alpha

You can config which runlevel (number) will run as which soft-runlevel (/etc/runlevels/). Look /etc/inittab  :Smile: 

I usualy create new 'maintenance' soft-runlevels with run as runlevel 3 (same as default) but run only 'sshd' and all of 'boot' runlevels

----------

