liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

rc.init (2000B)


      1 #!/bin/sh
      2 
      3 rl="$1"
      4 shift
      5 
      6 ### argv now contains the arguments of the kernel command line that are
      7 ### not of the form key=value. (The key=value arguments were stored by
      8 ### s6-linux-init into an envdir, if instructed so via the -s option.)
      9 ### Normally this argv remains unused because programs that need the
     10 ### kernel command line usually read it later on from /proc/cmdline -
     11 ### but just in case, it's available here.
     12 
     13 
     14 ### 1. Early preparation
     15 ### This is done only once at boot time.
     16 ### Ideally, this phase should just initialize the service manager.
     17 
     18 mount -t proc none /proc
     19 mount -t sysfs none /sys
     20 mount -t tmpfs none /tmp
     21 # s6-linux-init mounts /dev before this script is called
     22 mkdir /dev/pts
     23 mount -t devpts none /dev/pts
     24 
     25 if test -c /dev/pmsg0 ; then
     26     mount -t pstore none /sys/fs/pstore
     27     (cat /sys/fs/pstore/* && rm  /sys/fs/pstore/*) > /run/log/previous-boot
     28 fi
     29 
     30 mkdir -m 0751 -p /run/services/outputs
     31 chgrp system /run/services/outputs
     32 
     33 if test -d /persist; then
     34     mkdir -m 0751  -p /persist/services/state
     35     (cd /run/services && ln -s ../../persist/services/state .)
     36 else
     37     mkdir -m 0751 -p /run/services/state
     38 fi
     39 
     40 ### If your services are managed by s6-rc:
     41 ### (replace /run/service with your scandir)
     42 s6-rc-init -d -c /etc/s6-rc/compiled /run/service
     43 
     44 
     45 ### 2. Starting the wanted set of services
     46 ### This is also called every time you change runlevels with telinit.
     47 ### (edit the location to suit your installation)
     48 ### By default, $rl is the string "default", unless you changed it
     49 ### via the -D option to s6-linux-init-maker.
     50 ### Numeric arguments from 1 to 5 on the kernel command line will
     51 ### override the default.
     52 
     53 exec /etc/s6-linux-init/current/scripts/runlevel "$rl"
     54 
     55 
     56 ### If this script is run in a container, then 1. and 2. above do not
     57 ### apply and you should just call your CMD, if any, or let your
     58 ### services run.
     59 ### Something like this:
     60 
     61 # if test -z "$*" ; then return 0 ; fi
     62 # $@
     63 # echo $? > /run/s6-linux-init-container-results/exitcode
     64 # halt