cvs commit: hints/ATTACHMENTS/build-with-runit build-with-runit-scripts.txt

tushar at linuxfromscratch.org tushar at linuxfromscratch.org
Thu Apr 1 07:32:05 PST 2004


tushar      04/04/01 08:32:05

  Added:       .        build-with-runit.txt
               ATTACHMENTS/build-with-runit build-with-runit-scripts.txt
  Log:
  Added: build-with-runit.txt
  
  Revision  Changes    Path
  1.1                  hints/build-with-runit.txt
  
  Index: build-with-runit.txt
  ===================================================================
  AUTHOR: Richard A Downing FBCS CITP (geek109 at hotmail dot com)
  
  DATE: 2004-03-29
  
  LICENSE: Creative Commons Attribution-NonCommercial-ShareAlike License
  http://creativecommons.org/licenses/by-nc-sa/1.0/
  
  
  SYNOPSIS: How to replace SysVinit with runit when you build LFS.
  
  PRIMARY URI:
  http://wiki.linuxfromscratch.org/index.php?pagename=Building%20LFS%20with%20Runit
  
  DESCRIPTION:
  
  The LFS book installs SysVinit and a set of bootscripts. Together
  these provide the mechanism for starting processes that run under the
  Linux Kernel, and every process is a child of 'init', process
  one. Other schemes exist, notably the BSD-init scripts, but these are
  just an alternative set of scripts. This hint uses runit
  http://smarden.org/runit/ by Gerrit Pape, a completely different
  scheme that replaces init, and all its paraphernalia (with its own
  paraphernalia). Runit is derived from the ideas of DJ Bernstein, but
  the applications can easily be installed in FHS conformant places.
  
  
  PREREQUISITES: None. This hint should apply to all versions of LFS.
  
  HINT:
  
  Introduction
  ------------
  
  There is a hint at http://109bean.org.uk/betterboot that explains how
  to modify an existing LFS system to use runit. Those pages contain a
  lot of explanatory text that is not repeated here. If you want
  explanation, go and read that.
  
  
  This hint will just show the minimal steps to build a fresh LFS system
  using the book as modified by these instructions.
  
  
      Note: If you are reading this as a text document, you might find
      it better to look at the wiki version, which is maintained
      on-line. http://wiki.linuxfromscratch.org
  
  
  Obtaining Sources and Scripts
  -----------------------------
  
  Download the latest version of Gerrit Pape's packages from his website:
  
  http://smarden.org/runit/runit-1.0.1.tar.gz
  
  http://smarden.org/socklog/socklog-1.4.2.tar.gz
  
  http://smarden.org/ipsvd/ipsvd-0.8.2.tar.gz
  
  Note: There may be later versions - the ones above are the ones that
  have been tested with these instructions
  
  Follow the LFS book up to SysVInit
  ----------------------------------
  
  Carefully follow the LFS book through all its chapters until you get
  to the page concerning SysVInit. Now follow these instructions:
  
  Building and installing runit
  -----------------------------
  
  A word of warning, runit is designed to be unpacked into a directory,
  /package, which is neither LFS nor FHS conformant. These instructions
  therefore build an LFS and FHS conformant version.
  
  
  Unpack the runit tarball, it will unpack as admin/runit-1.0.1.
  
  cd admin/runit-1.0.1
  package/compile
  cd command
  install runit runit-init /sbin
  install runsvdir runsvchdir runsv runsvstat runsvctrl  /usr/sbin
  install svlogd svwaitdown svwaitup chpst utmpset /usr/sbin
  cp ../man/* /usr/share/man/man8
  ln -s /sbin/runit-init /sbin/init
  
  Install runit's bootscripts
  ---------------------------
  
  These scripts tell runit how to boot your system, how to run the
  initial tty terminals, and how to shut down the system (including
  forcing a shutdown with ctrl-alt-del). They depend on the
  LFS-bootscripts that you will install in chapter 7 of the LFS book.
  
  Obtain the scripts from the LFS Hints webpage's attachments link.
  http://www.linuxfromscratch.org/hints/downloads/attachments/
  
  Continue from the LFS book
  --------------------------
  
  Now continue from the LFS book starting with the section after SysVInit.
  
  The section How does the booting process with these scripts work? is
  not relevant, and can be skipped.
  
  Finally, you will want to understand what you have built, so visit the
  runit webpages at http://smarden.org/runit.
  
  You will also want to know how to build BLFS packages with runit
  support, if so, visit the author's runit pages at
  http://109bean.org.uk/betterboot.
  
  
  ACKNOWLEDGEMENTS:
  
  This hint started life on the LFS wiki (and the best version is still
  maintained there).  Kind people make improvements to it there, so far
  these are: Uli Fahrenberg, Anderson Lizardo.
  
  CHANGELOG:
  
      [2004-03-25]
  	*  Wrote the first draft on the wiki.
      [2004-03-29]
  	*  Issued 1st Text version for the Hints project.
  
  
  
  
  1.1                  hints/ATTACHMENTS/build-with-runit/build-with-runit-scripts.txt
  
  Index: build-with-runit-scripts.txt
  ===================================================================
  #!/bin/bash
  
  #-----------------------------------------------------------------
  # Submitted BY: Richard Downing <geek109 at hotmail dot com>
  #
  # Date: 2004-03-29
  #
  # Initial Package Version: applies to the Building LFS with runit
  #			    version of 2004-03-29.
  #
  # Upstream Status: Not applicable.
  #
  # Origin: Richard Downing.
  #
  # Description:  Execute to create required runit scripts. See Hint.
  #
  #------------------------------------------------------------------
  # 
  #
  
  mkdir /etc/runit
  
  cat > /etc/runit/1 << "EOF"
  #!/bin/sh
  # System one time tasks
  # The Stage 1 script for runit.
  
  PATH=/sbin:/bin:/usr/sbin:/usr/bin
  
  # mount the swap partition
  /etc/rc.d/init.d/swap start
  
  # mount the /proc pseudo-partition
  /etc/rc.d/init.d/mountproc start
  
  # run the fsck checks
  /etc/rc.d/init.d/checkfs start
  
  # remount root rw,
  # and mount all other non-proc auto partitions
  /etc/rc.d/init.d/mountfs start
  
  # clean up after the last boot session by
  # removing stale /var/run and /var/lock files
  # and setting up utmp etc.
  /etc/rc.d/init.d/cleanfs
  
  # Initialise the random number generator
  /etc/rc.d/init.d/random start
  
  # Set the system clock from the rtc
  /etc/rc.d/init.d/setclock start
  
  # Load the keymap file
  /etc/rc.d/init.d/loadkeys
  
  # Bring up the local loopback network
  /etc/rc.d/init.d/localnet start
  
  # Bring up the NICs and network
  # and set up the default gateway
  /etc/rc.d/init.d/network start
  
  touch /etc/runit/stopit
  chmod 0 /etc/runit/stopit
  EOF
  
  chmod +x /etc/runit/1
  
  
  cat > /etc/runit/2 << "EOF"
  #!/bin/sh
  
  PATH=/bin:/sbin:/usr/bin:/usr/sbin
  
  exec env - PATH=$PATH \
  runsvdir /var/service 'log: ............................................................
  ........................................................................................
  ........................................................................................
  ........................................................................................
  .......................................................................'
  EOF
  
  chmod +x /etc/runit/2
  
  
  cat > /etc/runit/3 << "EOF"
  #!/bin/sh
  exec 2>&1
  
  PATH=/sbin:/bin:/usr/sbin:/usr/bin
  
  LAST=0
  test -x /etc/runit/reboot && LAST=6
  
  echo 'Waiting for getties to stop...'
  svwaitdown -xk -t10 /var/service/getty-*
  
  echo 'Waiting for services to stop...'
  svwaitdown -xk -t30 /var/service/*
  
  # save the random number generator seed
  /etc/rc.d/init.d/random stop
  
  # turn swapping off
  /etc/rc.d/init.d/swap stop
  
  # Bring down the network
  # and remove the default gateway
  /etc/rc.d/init.d/network stop
  
  # Bring down the localnet
  /etc/rc.d/init.d/localnet stop
  
  EOF
  
  chmod +x /etc/runit/3
  
  cat > /etc/runit/ctrlaltdel << "EOF"
  #!/bin/sh
  
  PATH=/bin:/usr/bin
  MSG="System is going down in 14 seconds..."
  
  # echo 'disabled.' ; exit
  touch /etc/runit/stopit
  chmod 100 /etc/runit/stopit && echo "$MSG" | wall
  /bin/sleep 14
  EOF
  
  chmod +x /etc/runit/ctrlaltdel
  
  for N in 1 2 3 4 5 6
  do
  mkdir -p /etc/runit/getty-$N
  cat > /etc/runit/getty-$N/run << "EOF"
  #!/bin/sh
  exec /sbin/agetty 38400 tty$N linux
  EOF
  cat > /etc/runit/getty-$N/finish << "EOF"
  #!/bin/sh
  exec utmpset -w tty$N
  EOF
  
  chmod +x /etc/runit/getty-$N/*
  mkdir -p /var/service
  ln -s /etc/runit/getty-$N /var/service
  done
  
  
  



More information about the hints mailing list