liminix

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

rc.init (2016B)


      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 /etc/sysctl.sh
     31 
     32 mkdir -m 0751 -p /run/services/outputs
     33 chgrp system /run/services/outputs
     34 
     35 if test -d /persist; then
     36     mkdir -m 0751  -p /persist/services/state
     37     (cd /run/services && ln -s ../../persist/services/state .)
     38 else
     39     mkdir -m 0751 -p /run/services/state
     40 fi
     41 
     42 ### If your services are managed by s6-rc:
     43 ### (replace /run/service with your scandir)
     44 s6-rc-init -d -c /etc/s6-rc/compiled /run/service
     45 
     46 
     47 ### 2. Starting the wanted set of services
     48 ### This is also called every time you change runlevels with telinit.
     49 ### (edit the location to suit your installation)
     50 ### By default, $rl is the string "default", unless you changed it
     51 ### via the -D option to s6-linux-init-maker.
     52 ### Numeric arguments from 1 to 5 on the kernel command line will
     53 ### override the default.
     54 
     55 exec /etc/s6-linux-init/current/scripts/runlevel "$rl"
     56 
     57 
     58 ### If this script is run in a container, then 1. and 2. above do not
     59 ### apply and you should just call your CMD, if any, or let your
     60 ### services run.
     61 ### Something like this:
     62 
     63 # if test -z "$*" ; then return 0 ; fi
     64 # $@
     65 # echo $? > /run/s6-linux-init-container-results/exitcode
     66 # halt