Ubuntu, steuere den Init-Start

5243
Xolve

Ubuntu verwendet anstelle von Sysvinit Upstart. Es gibt jedoch immer noch Runlevels und die Links darin.

Ich habe tor installiert und es hat sich zum Start des Betriebssystems hinzugefügt. Jetzt möchte ich es entfernen, und die beliebtesten Optionen sind, die Verknüpfungen zum Starten und Stoppen des Dienstes von Runlevels zu entfernen oder das Skript /etc/init.d/ nicht ausführbar zu machen. Dies ist in Ordnung, aber dies wird problematisch, falls ich mich noch einmal auf die Startliste setzen möchte. Wie würde ich wissen, um die richtigen Sequenzen in die richtigen Runlevel-Verzeichnisse zu legen.

Gibt es eine vollständige Anleitung? Was sind die Regeln dafür? Irgendwelche Werkzeuge, um die Init zu verwalten?

Bitte erzähle

3
Warum nicht einfach selbst entfernen? Bobby vor 13 Jahren 0

3 Antworten auf die Frage

8
quack quixote

SysVinit works like this. Initialization scripts for each package are located in /etc/init.d. Links to those scripts are located in /etc/rcS.d and /etc/rc[0-6].d. These links start with either S (start) or K (kill) and a 2-digit number.

  • When the system boots and the SysVinit process starts, it looks in /etc/rcS.d and executes scripts starting with S, ordered by the number. (I believe it passes the "start" argument to the scripts, but I'm not sure.)

  • After all /etc/rcS.d scripts are processed, the system begins moving into a certain runlevel. In Ubuntu, booting to the normal desktop, the default runlevel is 2. So SysVinit looks in /etc/rc2.d and

    1. stops all services with links starting with K, ordered by the number; and
    2. starts all services with links starting with S, ordered by the number.

    If you've booted into Ubuntu's recovery mode instead, you'll be booting into runlevel 1. After all services are started, the system runlevel is officially set.

  • Finally, the system runs the /etc/rc.local script.

If you switch runlevels later, SysVinit runs the same basic process: it doesn't check /etc/rcS.d, but goes straight to processing the links in /etc/rcN.d (where N is whatever runlevel is being entered).


You could also write an Upstart script. I've written about Upstart previously, so check there for more details. Upstart scripts are kept in /etc/init; to write them, look over existing scripts to get a feel for how it works, and read the init(5) manpage.

1
Shiki

I know only update-rc.d as a tool. The manual page gives a good explanation how to use it and it's not too hard to learn.


Thanks to Quack who told me about chkconfig. Check his post here.

Dies ist das "richtige Werkzeug", um die Links * / etc / rc \ * .d * automatisch zu ändern. quack quixote vor 13 Jahren 0
Siehe [meine Antwort hier] (http://superuser.com/questions/59410/change-cpufreq-in-runlevel-1/59459#59459) für eine schnelle Einführung in die Verwendung von update-rc.d. quack quixote vor 13 Jahren 0
Oh, warum editierst du nicht einfach meine Antwort? Fühlen Sie sich frei, es zu verbessern, wenn Sie können (oder schreiben Sie ein neues, wenn es total fubar ist .. :)) Shiki vor 13 Jahren 0
Um Ihre How-to-Use-Update-rc.d-Antwort zu erweitern, würde ich aus der Antwort, auf die ich verlinkt habe, ausschneiden. Deshalb habe ich einen Kommentar-Link gepostet. (Ich schrieb einen separaten Ansatz und stieß auf diesen Link.) quack quixote vor 13 Jahren 0
Oh okay ... sehen Sie jetzt Ihre Antwort. Meine bald zu löschen, denke ich. :) Shiki vor 13 Jahren 0
0
Tobu

Here is the update-rc.d man page. Basically, removing the rc.d links won't work as they will be restored on upgrade. The correct way is:

sudo update-rc.d tor disable 

Which renames S (start) links in /etc/rc?.d to K (stop) links. This would also work:

sudo rename 's:/S:/K:g' /etc/rc?.d/S*tor