Changes between Version 3 and Version 4 of runit/replaceinit


Ignore:
Timestamp:
Dec 21, 2007 8:50:50 PM (5 years ago)
Author:
jrollins
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • runit/replaceinit

    v3 v4  
    88}}} 
    99 
    10 The runit-run program is the one that actually replaces /sbin/init with /sbin/runit-init: 
     10== init == 
     11 
     12The runit-run installs the init replacement program, [http://smarden.org/runit/runit-init.8.html runit-int]: 
    1113{{{ 
    1214proton:~ 0# ls -al /sbin/init* 
     
    1517proton:~ 0#  
    1618}}} 
    17 runit-init is what will now start on boot and handle starting services.  It also emulates many of the commands that could be passed to init.  The configuration directory for runit-init is /etc/runit: 
     19runit-int operation is very simple: 
     20 * if it is started by root as process number one, then it just replaces itself with the [http://smarden.org/runit/runit.8.html runit] program. 
     21 * if not called by root, then it is called by "init 0", in which case it halts the system, or "init 6", in which case it restarts the system. 
     22 
     23== runit == 
     24 
     25The [http://smarden.org/runit/runit.8.html runit] program executes three stages in succession: 
     26 * /etc/runit/1 - system one-time tasks, roughly equivalent to /etc/rcS.d (in fact it actually calls /etc/init.d/rcS, which in fact does this) 
     27 * /etc/runit/2 - which returns when the system is to be shutdown 
     28 * /etc/runit/3 - which shutdown the system 
     29 
     30=== runit runlevels === 
     31 
     32runit has [http://smarden.org/runit/runlevels.html runlevels] that are defined in /etc/runit/runsvdir: 
    1833{{{ 
    19 proton:~ 0# ls -al /etc/runit/ 
    20 total 10 
    21 drwxr-xr-x  3 root root 1024 2007-12-21 18:41 . 
    22 drwxr-xr-x 51 root root 4096 2007-12-21 18:41 .. 
    23 -rwxr-xr-x  1 root root  188 2006-11-04 14:33 1 
    24 -rwxr-xr-x  1 root root  576 2006-11-04 14:33 2 
    25 -rwxr-xr-x  1 root root  239 2006-11-04 14:33 3 
    26 -rwxr-xr-x  1 root root  209 2006-11-04 14:33 ctrlaltdel 
    27 drwxr-xr-x  4 root root 1024 2007-12-21 18:40 runsvdir 
    2834proton:~ 0# ls -al /etc/runit/runsvdir/ 
    2935total 4 
     
    3541proton:~ 0# 
    3642}}} 
     43Each of these are runit service directories that define the services that are to be started at the various runlevels.  /var/service is a link to /etc/runit/runsvdir/current: 
     44{{{ 
     45proton:~ 0# ls -al /var/service 
     46lrwxrwxrwx 1 root root 27 2007-12-21 18:41 /var/service -> /etc/runit/runsvdir/current 
     47proton:~ 0# 
     48}}} 
    3749 
    38 The main service directory is /var/service (which is a link to /etc/runit/runsvdir/current, which is a link to either /etc/runit/runsvdir/default or /etc/runit/runsvdir/single, for default or single user mode, i think): 
     50== services == 
     51 
     52These are the default services setup for runlevel "default" by default: 
    3953{{{ 
    40 proton:~ 0# ls -al /var/service/ 
     54proton:~ 0# ls -al /etc/runit/runsvdir/default/ 
    4155total 2 
    4256drwxr-xr-x 2 root root 1024 2007-12-21 18:41 . 
     
    5165proton:~ 0#  
    5266}}} 
    53  
    5467These service directories start the gettys, and the main system log daemons.  The next thing to do make service directories for the rest of the services that we want handled by runit.  This is where runit-services comes in.  runit-services provides service directories for a bunch of standard services, all located in /etc/sv: 
    5568{{{ 
     
    6982proton:~ 0# mv /etc/init.d/cron /etc/init.d/cron.distrib 
    7083proton:~ 0# ln -s /usr/bin/sv /etc/init.d/cron 
    71 proton:~ 0# ln -s /etc/sv/cron /var/service/ 
     84proton:~ 0# ln -s /etc/sv/cron /etc/runit/runsvdir/default/ 
    7285proton:~ 0# sv status cron 
    7386run: cron: (pid 2033) 2s 
     
    8497proton:~ 0# ln -s /etc/sv/ssh/ 
    8598log/       run        supervise   
    86 proton:~ 0# ln -s /etc/sv/ssh /var/service 
     99proton:~ 0# ln -s /etc/sv/ssh /etc/runit/runsvdir/default/ 
    87100proton:~ 0# sv status ssh 
    88101run: ssh: (pid 2059) 2s; run: log: (pid 2057) 2s 
    89102proton:~ 0#  
    90103}}} 
    91  
    92104An important one to me, which does not have an included service dir, is a serial console.  So I went ahead and wrote one: 
    93105{{{ 
     
    107119proton:~ 0#  
    108120}}} 
     121Once the service directory was ready, I commented out the serial getty line ("TO:...") in /etc/inittab, told the current running init to reload the inittab, and then linked in the new service: 
     122{{{ 
     123proton:~ 0# /sbin/init.sysv q 
     124proton:~ 0# ln -s /etc/sv/getty-S0 /etc/runit/runsvdir/default/ 
     125proton:~ 0# ln -s /etc/sv/getty-S0 /etc/runit/runsvdir/single/ 
     126proton:~ 0#  
     127}}} 
     128Notice I want it started in both "single" and "default" runlevels.  The serial console started up no problem. 
    109129 
    110  
     130== reboot! == 
    111131 
    112132Finally, reboot your system: