From b08f4096533577934b885fa9df41d3881d141612 Mon Sep 17 00:00:00 2001 From: Gerard Beekmans Date: Thu, 15 Feb 2001 15:26:52 +0000 Subject: Initial XML commit git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@174 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter07/bootscripts.xml | 12 ++ chapter07/chapter07.xml | 22 ++ chapter07/chapter7.sgml | 22 -- chapter07/chapter9.xml | 12 ++ chapter07/checkfs.sgml | 116 ----------- chapter07/checkfs.xml | 116 +++++++++++ chapter07/createdirs.sgml | 19 -- chapter07/createdirs.xml | 19 ++ chapter07/ethnet-symperm.xml | 23 +++ chapter07/ethnet.xml | 188 +++++++++++++++++ chapter07/fstab.sgml | 32 --- chapter07/fstab.xml | 32 +++ chapter07/functions.sgml | 451 ----------------------------------------- chapter07/functions.xml | 451 +++++++++++++++++++++++++++++++++++++++++ chapter07/halt.sgml | 27 --- chapter07/halt.xml | 27 +++ chapter07/hosts.xml | 83 ++++++++ chapter07/introduction.sgml | 13 -- chapter07/introduction.xml | 13 ++ chapter07/loadkeys.sgml | 36 ---- chapter07/loadkeys.xml | 36 ++++ chapter07/localnet-symperm.xml | 19 ++ chapter07/localnet.xml | 59 ++++++ chapter07/mountfs.sgml | 110 ---------- chapter07/mountfs.xml | 110 ++++++++++ chapter07/network.xml | 23 +++ chapter07/rc.sgml | 253 ----------------------- chapter07/rc.xml | 253 +++++++++++++++++++++++ chapter07/rcS.sgml | 43 ---- chapter07/rcS.xml | 43 ++++ chapter07/reboot.sgml | 30 --- chapter07/reboot.xml | 30 +++ chapter07/sendsignals.sgml | 44 ---- chapter07/sendsignals.xml | 44 ++++ chapter07/setclock.sgml | 93 --------- chapter07/setclock.xml | 93 +++++++++ chapter07/symperm.sgml | 49 ----- chapter07/symperm.xml | 49 +++++ chapter07/sysklogd.sgml | 67 ------ chapter07/sysklogd.xml | 67 ++++++ chapter07/template.sgml | 60 ------ chapter07/template.xml | 60 ++++++ 42 files changed, 1884 insertions(+), 1465 deletions(-) create mode 100644 chapter07/bootscripts.xml create mode 100644 chapter07/chapter07.xml delete mode 100644 chapter07/chapter7.sgml create mode 100644 chapter07/chapter9.xml delete mode 100644 chapter07/checkfs.sgml create mode 100644 chapter07/checkfs.xml delete mode 100644 chapter07/createdirs.sgml create mode 100644 chapter07/createdirs.xml create mode 100644 chapter07/ethnet-symperm.xml create mode 100644 chapter07/ethnet.xml delete mode 100644 chapter07/fstab.sgml create mode 100644 chapter07/fstab.xml delete mode 100644 chapter07/functions.sgml create mode 100644 chapter07/functions.xml delete mode 100644 chapter07/halt.sgml create mode 100644 chapter07/halt.xml create mode 100644 chapter07/hosts.xml delete mode 100644 chapter07/introduction.sgml create mode 100644 chapter07/introduction.xml delete mode 100644 chapter07/loadkeys.sgml create mode 100644 chapter07/loadkeys.xml create mode 100644 chapter07/localnet-symperm.xml create mode 100644 chapter07/localnet.xml delete mode 100644 chapter07/mountfs.sgml create mode 100644 chapter07/mountfs.xml create mode 100644 chapter07/network.xml delete mode 100644 chapter07/rc.sgml create mode 100644 chapter07/rc.xml delete mode 100644 chapter07/rcS.sgml create mode 100644 chapter07/rcS.xml delete mode 100644 chapter07/reboot.sgml create mode 100644 chapter07/reboot.xml delete mode 100644 chapter07/sendsignals.sgml create mode 100644 chapter07/sendsignals.xml delete mode 100644 chapter07/setclock.sgml create mode 100644 chapter07/setclock.xml delete mode 100644 chapter07/symperm.sgml create mode 100644 chapter07/symperm.xml delete mode 100644 chapter07/sysklogd.sgml create mode 100644 chapter07/sysklogd.xml delete mode 100644 chapter07/template.sgml create mode 100644 chapter07/template.xml (limited to 'chapter07') diff --git a/chapter07/bootscripts.xml b/chapter07/bootscripts.xml new file mode 100644 index 000000000..ac33ca2bc --- /dev/null +++ b/chapter07/bootscripts.xml @@ -0,0 +1,12 @@ + +Creating network boot scripts + +&c9-bs-localnet; +&c9-bs-localnet-symperm; +&c9-bs-hostname; +&c9-bs-hosts; +&c9-bs-ethnet; +&c9-bs-ethnet-symperm; + + + diff --git a/chapter07/chapter07.xml b/chapter07/chapter07.xml new file mode 100644 index 000000000..ab3625579 --- /dev/null +++ b/chapter07/chapter07.xml @@ -0,0 +1,22 @@ + +Creating system boot scripts + +&c7-introduction; +&c7-createdirs; +&c7-rc; +&c7-rcS; +&c7-functions; +&c7-checkfs; +&c7-halt; +&c7-loadkeys; +&c7-mountfs; +&c7-reboot; +&c7-sendsignals; +&c7-setclock; +&c7-sysklogd; +&c7-template; +&c7-symperm; +&c7-fstab; + + + diff --git a/chapter07/chapter7.sgml b/chapter07/chapter7.sgml deleted file mode 100644 index ab3625579..000000000 --- a/chapter07/chapter7.sgml +++ /dev/null @@ -1,22 +0,0 @@ - -Creating system boot scripts - -&c7-introduction; -&c7-createdirs; -&c7-rc; -&c7-rcS; -&c7-functions; -&c7-checkfs; -&c7-halt; -&c7-loadkeys; -&c7-mountfs; -&c7-reboot; -&c7-sendsignals; -&c7-setclock; -&c7-sysklogd; -&c7-template; -&c7-symperm; -&c7-fstab; - - - diff --git a/chapter07/chapter9.xml b/chapter07/chapter9.xml new file mode 100644 index 000000000..5233eeeef --- /dev/null +++ b/chapter07/chapter9.xml @@ -0,0 +1,12 @@ + +Setting up basic networking + +&c9-introduction; +&c9-networksoftware; +&c9-localnet; +&c9-network; +&c9-hosts; +&c9-ethnet; + + + diff --git a/chapter07/checkfs.sgml b/chapter07/checkfs.sgml deleted file mode 100644 index 2350a0056..000000000 --- a/chapter07/checkfs.sgml +++ /dev/null @@ -1,116 +0,0 @@ - -Creating the checkfs script - - -Create a new file /etc/init.d/checkfs containing -the following: - - - - -cat > checkfs << "EOF" -#!/bin/sh -# Begin /etc/init.d/checkfs - -# -# Include the functions declared in the /etc/init.d/functions file -# - -source /etc/init.d/functions - -# -# Activate all the swap partitions declared in the /etc/fstab file -# - -echo -n "Activating swap..." -/sbin/swapon -a -evaluate_retval - -# -# If the /fastboot file exists we don't want to run the partition checks -# - -if [ -f /fastboot ] -then - echo "Fast boot, no file system check" -else - -# -# Mount the root partition read-only (just in case the kernel mounts it -# read-write and we don't want to run fsck on a read-write mounted -# partition). -# - - /bin/mount -n -o remount,ro / - if [ $? = 0 ] - then - -# -# If the /forcefsck file exists we want to force a partition check even -# if the partition was unmounted cleanly the last time -# - - if [ -f /forcefsck ] - then - echo -n "/forcefsck exists, forcing " - echo "file system check" - force="-f" - else - force="" - fi - -# -# Check all the file systems mentioned in /etc/fstab that have the -# fs_passno value set to 1 or 2 (the 6th field. See man fstab for more -# info) -# - - echo "Checking file systems..." - /sbin/fsck $force -a -A -C -T - -# -# If something went wrong during the checks of one of the partitions, -# fsck will exit with a return value greater than 1. If this is -# the case we start sulogin so you can repair the damage manually -# - - if [ $? -gt 1 ] - then - $FAILURE - echo - echo -n "fsck failed. Please repair your file " - echo "systems manually by running /sbin/fsck" - echo "without the -a option" - echo - echo -n "Please note that the root file system " - echo "is currently mounted in read-only mode." - echo - echo -n "I will start sulogin now. When you " - echo "logout I will reboot your system." - echo - $NORMAL - /sbin/sulogin - /sbin/reboot -f - else - print_status success - fi - - else - -# -# If the remount to read-only mode didn't work abort the fsck and print -# an error -# - - echo -n "Cannot check root file system because it " - echo "could not be mounted in read-only mode." - fi -fi - -# End /etc/init.d/checkfs -EOF - - - - - diff --git a/chapter07/checkfs.xml b/chapter07/checkfs.xml new file mode 100644 index 000000000..2350a0056 --- /dev/null +++ b/chapter07/checkfs.xml @@ -0,0 +1,116 @@ + +Creating the checkfs script + + +Create a new file /etc/init.d/checkfs containing +the following: + + + + +cat > checkfs << "EOF" +#!/bin/sh +# Begin /etc/init.d/checkfs + +# +# Include the functions declared in the /etc/init.d/functions file +# + +source /etc/init.d/functions + +# +# Activate all the swap partitions declared in the /etc/fstab file +# + +echo -n "Activating swap..." +/sbin/swapon -a +evaluate_retval + +# +# If the /fastboot file exists we don't want to run the partition checks +# + +if [ -f /fastboot ] +then + echo "Fast boot, no file system check" +else + +# +# Mount the root partition read-only (just in case the kernel mounts it +# read-write and we don't want to run fsck on a read-write mounted +# partition). +# + + /bin/mount -n -o remount,ro / + if [ $? = 0 ] + then + +# +# If the /forcefsck file exists we want to force a partition check even +# if the partition was unmounted cleanly the last time +# + + if [ -f /forcefsck ] + then + echo -n "/forcefsck exists, forcing " + echo "file system check" + force="-f" + else + force="" + fi + +# +# Check all the file systems mentioned in /etc/fstab that have the +# fs_passno value set to 1 or 2 (the 6th field. See man fstab for more +# info) +# + + echo "Checking file systems..." + /sbin/fsck $force -a -A -C -T + +# +# If something went wrong during the checks of one of the partitions, +# fsck will exit with a return value greater than 1. If this is +# the case we start sulogin so you can repair the damage manually +# + + if [ $? -gt 1 ] + then + $FAILURE + echo + echo -n "fsck failed. Please repair your file " + echo "systems manually by running /sbin/fsck" + echo "without the -a option" + echo + echo -n "Please note that the root file system " + echo "is currently mounted in read-only mode." + echo + echo -n "I will start sulogin now. When you " + echo "logout I will reboot your system." + echo + $NORMAL + /sbin/sulogin + /sbin/reboot -f + else + print_status success + fi + + else + +# +# If the remount to read-only mode didn't work abort the fsck and print +# an error +# + + echo -n "Cannot check root file system because it " + echo "could not be mounted in read-only mode." + fi +fi + +# End /etc/init.d/checkfs +EOF + + + + + diff --git a/chapter07/createdirs.sgml b/chapter07/createdirs.sgml deleted file mode 100644 index 0831e7874..000000000 --- a/chapter07/createdirs.sgml +++ /dev/null @@ -1,19 +0,0 @@ - -Creating directories - - -We need to start by creating a few extra directories that are used by -the boot scripts. Create these directories by running: - - -
- - cd /etc && - mkdir sysconfig rc0.d rc1.d rc2.d rc3.d && - mkdir rc4.d rc5.d rc6.d init.d rcS.d && - cd init.d - -
- -
- diff --git a/chapter07/createdirs.xml b/chapter07/createdirs.xml new file mode 100644 index 000000000..0831e7874 --- /dev/null +++ b/chapter07/createdirs.xml @@ -0,0 +1,19 @@ + +Creating directories + + +We need to start by creating a few extra directories that are used by +the boot scripts. Create these directories by running: + + +
+ + cd /etc && + mkdir sysconfig rc0.d rc1.d rc2.d rc3.d && + mkdir rc4.d rc5.d rc6.d init.d rcS.d && + cd init.d + +
+ +
+ diff --git a/chapter07/ethnet-symperm.xml b/chapter07/ethnet-symperm.xml new file mode 100644 index 000000000..ba72ab6e9 --- /dev/null +++ b/chapter07/ethnet-symperm.xml @@ -0,0 +1,23 @@ + +Setting up permissions and symlink + + +Set the proper file permissions and create the necessary symlink by +running the following commands: + + +
+ + cd /etc/init.d && + chmod 754 ethnet && + cd ../rc3.d && + ln -s ../init.d/ethnet S200ethnet && + cd ../rc4.d && + ln -s ../init.d/ethnet S200ethnet && + cd ../rc5.d && + ln -s ../init.d/ethnet S200ethnet + +
+ +
+ diff --git a/chapter07/ethnet.xml b/chapter07/ethnet.xml new file mode 100644 index 000000000..a1630a6cc --- /dev/null +++ b/chapter07/ethnet.xml @@ -0,0 +1,188 @@ + +Creating the /etc/init.d/ethnet script + + +This section only applies if you are going to configure a network card. +If you're not, skip this section. + + + +Create a new file /etc/init.d/ethnet containing the +following: + + + + +cat > /etc/init.d/ethnet << "EOF" +#!/bin/sh +# Begin /etc/init.d/ethnet +# +# Main script by Gerard Beekmans - gerard@linuxfromscratch.org +# GATEWAY check by Jean-François Le Ray - jfleray@club-internet.fr +# + +# +# Include the functions declared in the /etc/init.d/functions file +# and the variables from the /etc/sysconfig/network file. +# + +source /etc/init.d/functions +source /etc/sysconfig/network + +case "$1" in + start) + +# +# Obtain all the network card configuration files +# + + for interface in $(ls /etc/sysconfig/network-scripts/ifcfg* | \ + grep -v ifcfg-lo) + do +# +# Load the variables from that file +# + + source $interface +# +# If the ONBOOT variable is set to yes, process this file and bring the +# interface down. +# + + if [ "$ONBOOT" == yes ] + then + echo -n "Bringing up the $DEVICE interface..." + /sbin/ifconfig $DEVICE $IP broadcast $BROADCAST \ + netmask $NETMASK + evaluate_retval + fi + done + +# +# If the /etc/sysconfig/network file contains a GATEWAY variable, set +# the gateway. + +# + + if [ "$GATEWAY" != "" ]; then + echo -n "Setting up routing for eth0 interface..." + /sbin/route add default gw $GATEWAY metric 1 + evaluate_retval + fi + ;; + + stop) + +# +# Obtain all the network card configuration files +# + + for interface in $(ls /etc/sysconfig/network-scripts/ifcfg* | \ + grep -v ifcfg-lo) + do +# +# Load the variables from that file +# + + source $interface +# +# If the ONBOOT variable is set, process the file and bring the +# interface down +# + + if [ $ONBOOT == yes ] + then + echo -n "Bringing down the $DEVICE interface..." + /sbin/ifconfig $DEVICE down + evaluate_retval + fi + done + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +# End /etc/init.d/ethnet +EOF + + + + +Adding default gateway to /etc/sysconfig/network + + +If you require a default gateway to be setup, run the following command: + + + + +cat >> /etc/sysconfig/network << "EOF" +GATEWAY=192.168.1.2 +EOF + + + + +Change GATEWAY to match your network setup. + + + + + +Creating NIC configuration files + + +Which interfaces are brought up and down by the ethnet script depends on +the files in the /etc/sysconfig/network-scripts directory. This +directory should contain files in the form of ifcfg-x where x is an +identification number (or whatever you choose to name it). + + + +First create the network-scripts directory by running: + + +
+ + mkdir /etc/sysconfig/network-scripts + +
+ + +Now, create new files in that directory containing the following. +Example file names are ifcfg-eth0, ifcfg-eth0:3 and ifcfg-eth1:2 + + +
+ +ONBOOT=yes +DEVICE=eth0 +IP=192.168.1.1 +NETMASK=255.255.255.0 +BROADCAST=192.168.1.255 + +
+ + +Of course, change the values of those four variables in every file to +match the proper setup. Usually NETMASK and BROADCAST will remain the +same, just the DEVICE IP variables will change per network interface. If +the ONBOOT variable is set to yes, the ethnet script will bring it up +during boot up of the system. If set to anything else but yes it will be +ignored by the ethnet script and thus not brought up. + + +
+ +&c9-ethnet-symperm; + +
+ diff --git a/chapter07/fstab.sgml b/chapter07/fstab.sgml deleted file mode 100644 index 1c0be5826..000000000 --- a/chapter07/fstab.sgml +++ /dev/null @@ -1,32 +0,0 @@ - -Creating the /etc/fstab file - - -In order for certain programs to be able to determine where certain -partitions are supposed to be mounted by default, the /etc/fstab file is -used. Create a new file /etc/fstab containing the -following: - - - - -cat > /etc/fstab << "EOF" -# Begin /etc/fstab - -/dev/<LFS-partition designation> / ext2 defaults 1 1 -/dev/<swap-partition designation> swap swap defaults 0 0 -proc /proc proc defaults 0 0 - -# End /etc/fstab -EOF - - - - -Replace <LFS-partition designation> and <swap-partition -designation> with the appropriate devices (/dev/hda5 and /dev/hda6 in my -case). - - - - diff --git a/chapter07/fstab.xml b/chapter07/fstab.xml new file mode 100644 index 000000000..1c0be5826 --- /dev/null +++ b/chapter07/fstab.xml @@ -0,0 +1,32 @@ + +Creating the /etc/fstab file + + +In order for certain programs to be able to determine where certain +partitions are supposed to be mounted by default, the /etc/fstab file is +used. Create a new file /etc/fstab containing the +following: + + + + +cat > /etc/fstab << "EOF" +# Begin /etc/fstab + +/dev/<LFS-partition designation> / ext2 defaults 1 1 +/dev/<swap-partition designation> swap swap defaults 0 0 +proc /proc proc defaults 0 0 + +# End /etc/fstab +EOF + + + + +Replace <LFS-partition designation> and <swap-partition +designation> with the appropriate devices (/dev/hda5 and /dev/hda6 in my +case). + + + + diff --git a/chapter07/functions.sgml b/chapter07/functions.sgml deleted file mode 100644 index e46522c0f..000000000 --- a/chapter07/functions.sgml +++ /dev/null @@ -1,451 +0,0 @@ - -Creating the functions script - - -Create a new file /etc/init.d/functions containing -the following: - - - - -cat > functions << "EOF" -#!/bin/sh -# Begin /etc/init.d/functions - -# -# Set a few variables that influence the text that's printed on the -# screen. The SET_COL variable starts the text in column number 70 (as -# defined by the COL variable). NORMAL prints text in normal mode. -# SUCCESS prints text in a green colour and FAILURE prints text in a red -# colour -# - -COL=70 -SET_COL="echo -en \\033[${COL}G" -NORMAL="echo -en \\033[0;39m" -SUCCESS="echo -en \\033[1;32m" -FAILURE="echo -en \\033[1;31m" - -# -# The evaluate_retval function evaluates the return value of the process -# that was run just before this function was called. If the return value -# was 0, indicating success, the print_status function is called with -# the 'success' parameter. Otherwise the print_status function is called -# with the failure parameter. -# - -evaluate_retval() -{ - if [ $? = 0 ] - then - print_status success - else - print_status failure - fi -} - -# -# The print_status prints [ OK ] or [FAILED] to the screen. OK appears -# in the colour defined by the SUCCESS variable and FAILED appears in -# the colour defined by the FAILURE variable. Both are printed starting -# in the colomn defined by the COL variable. -# - -print_status() -{ - -# -# If no parameters are given to the print_status function, print usage -# information. -# - - if [ $# = 0 ] - then - echo "Usage: print_status {success|failure}" - return 1 - fi - - case "$1" in - success) - $SET_COL - echo -n "[ " - $SUCCESS - echo -n "OK" - $NORMAL - echo " ]" - ;; - failure) - $SET_COL - echo -n "[" - $FAILURE - echo -n "FAILED" - $NORMAL - echo "]" - ;; - esac - -} - -# -# The loadproc function starts a process (often a daemon) with -# proper error checking -# - -loadproc() -{ - -# -# If no parameters are given to the print_status function, print usage -# information. - -# - - if [ $# = 0 ] - then - echo "Usage: loadproc {program}" - exit 1 - fi -# -# Find the basename of the first parameter (the daemon's name without -# the path -# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after -# basename ran) -# - - base=$(/usr/bin/basename $1) -# -# the pidlist variable will contains the output of the pidof command. -# pidof will try to find the PID's that belong to a certain string; -# $base in this case -# - - pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base) - - pid="" - - for apid in $pidlist - do - if [ -d /proc/$apid ] - then - pid="$pid $apid" - fi - done -# -# If the $pid variable contains anything (from the previous for loop) it -# means the daemon is already running -# - - if [ ! -n "$pid" ] - then -# -# Empty $pid variable means it's not running, so we run $* (all -# parameters giving to this function from the script) and then check the -# return value -# - $* - evaluate_retval - else -# -# The variable $pid was not empty, meaning it was already running. We -# print [FAILED] now -# - print_status failure - fi - -} - -# -# The killproc function kills a process with proper error checking -# - -killproc() -{ - -# -# If no parameters are given to the print_status function, print usage -# information. - -# - - if [ $# = 0 ] - then - echo "Usage: killproc {program} [signal]" - exit 1 - fi - -# -# Find the basename of the first parameter (the daemon's name without -# the path -# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after -# basename ran) -# - - base=$(/usr/bin/basename $1) - -# -# Check if we gave a signal to kill the process with (like -HUP, -TERM, -# -KILL, etc) to this function (the second parameter). If no second -# parameter was provided set the nolevel variable. Else set the -# killlevel variable to the value of $2 (the second parameter) -# - - if [ "$2" != "" ] - then - killlevel=-$2 - else - nolevel=1 - fi - -# -# the pidlist variable will contains the output of the pidof command. -# pidof will try to find the PID's that belong to a certain string; -# $base in this case - - pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base) - - pid="" - - for apid in $pidlist - do - if [ -d /proc/$apid ] - then - pid="$pid $apid" - fi - done - -# -# If $pid contains something from the previous for loop it means one or - -# more PID's were found that belongs to the processes to be killed -# - if [ -n "$pid" ] - then -# -# If no kill level was specified we'll try -TERM first and then sleep -# for 2 seconds to allow the kill to be completed -# - if [ "$nolevel" = 1 ] - then - /bin/kill -TERM $pid -/usr/bin/sleep 2 -# -# If after -TERM the PID still exists we'll try killing it with -KILL -# and wait for 2 seconds again to allow the kill to be completed -# - - if ps h $pid >/dev/null 2>&1 - then - /bin/kill -KILL $pid -/usr/bin/sleep 2 - fi - /bin/ps h $pid >/dev/null 2>&1 - if [ $? = 0 ] - then -# -# If after the -KILL it still exists it can't be killed for some reason -# and we'll print [FAILED] -# - print_status failure - else -# -# It was killed, remove possible stale PID file in /var/run and -# print [ OK ] -# - /bin/rm -f /var/run/$base.pid - print_status success - fi - else -# -# A kill level was provided. Kill with the provided kill level and wait -# for 2 seconds to allow the kill to be completed - -# - /bin/kill $killlevel $pid -/usr/bin/sleep 2 - /bin/ps h $pid >/dev/null 2>&1 - if [ $? = 0 ] - then -# -# If ps' return value is 0 it means it ran ok which indicates that the -# PID still exists. This means the process wasn't killed properly with -# the signal provided. Print [FAILED] -# - print_status failure - else -# -# If the return value was 1 or higher it means the PID didn't exist -# anymore which means it was killed successfully. Remove possible stale -# PID file and print [ OK ] -# - /bin/rm -f /var/run/$base.pid - print_status success - fi - fi - else -# -# The PID didn't exist so we can't attempt to kill it. Print [FAILED] -# - print_status failure - fi -} - -# -# The reloadproc functions sends a signal to a daemon telling it to -# reload it's configuration file. This is almost identical to the -# killproc function with the exception that it won't try to kill it with -# a -KILL signal (aka -9) -# - -reloadproc() -{ - -# -# If no parameters are given to the print_status function, print usage -# information. - -# - - if [ $# = 0 ] - then - echo "Usage: reloadproc {program} [signal]" - exit 1 - fi - -# -# Find the basename of the first parameter (the daemon's name without -# the path -# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after -# basename ran) -# - - base=$(/usr/bin/basename $1) - -# -# Check if we gave a signal to send to the process (like -HUP) -# to this function (the second parameter). If no second -# parameter was provided set the nolevel variable. Else set the -# killlevel variable to the value of $2 (the second parameter) -# - - - if [ -n "$2" ] - then - killlevel=-$2 - else - nolevel=1 - fi - -# -# the pidlist variable will contains the output of the pidof command. -# pidof will try to find the PID's that belong to a certain string; -# $base in this case - -# - - pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base) - - pid="" - - for apid in $pidlist - do - if [ -d /proc/$apid ] - then - pid="$pid $apid" - fi - done - -# -# If $pid contains something from the previous for loop it means one or -# more PID's were found that belongs to the processes to be reloaded -# - - if [ -n "$pid" ] - then - -# -# If nolevel was set we will use the default reload signal SIGHUP. -# - - if [ "$nolevel" = 1 ] - then - /bin/kill -SIGHUP $pid - evaluate_retval - else -# -# Else we will use the provided signal -# - - /bin/kill $killlevel $pid - evaluate_retval - fi - else -# -# If $pid is empty no PID's have been found that belong to the process -# and print [FAILED] -# - - print_status failure - fi -} - -# -# The statusproc function will try to find out if a process is running -# or not -# - -statusproc() -{ - -# -# If no parameters are given to the print_status function, print usage -# information. - -# - - if [ $# = 0 ] - then - echo "Usage: status {program}" - return 1 - fi - -# -# $pid will contain a list of PID's that belong to a process -# - - pid=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $1) - if [ -n "$pid" ] - then -# -# If $pid contains something, the process is running, print the contents -# of the $pid variable -# - echo "$1 running with Process ID $pid" - return 0 - fi - -# -# If $pid doesn't contain it check if a PID file exists and inform the -# user about this stale file. -# - - if [ -f /var/run/$1.pid ] - then - pid=$(/usr/bin/head -1 /var/run/$1.pid) - if [ -n "$pid" ] - then - echo "$1 not running but /var/run/$1.pid exists" - return 1 - fi - else - echo "$1 is not running" - fi - -} - -# End /etc/init.d/functions -EOF - - - - - diff --git a/chapter07/functions.xml b/chapter07/functions.xml new file mode 100644 index 000000000..e46522c0f --- /dev/null +++ b/chapter07/functions.xml @@ -0,0 +1,451 @@ + +Creating the functions script + + +Create a new file /etc/init.d/functions containing +the following: + + + + +cat > functions << "EOF" +#!/bin/sh +# Begin /etc/init.d/functions + +# +# Set a few variables that influence the text that's printed on the +# screen. The SET_COL variable starts the text in column number 70 (as +# defined by the COL variable). NORMAL prints text in normal mode. +# SUCCESS prints text in a green colour and FAILURE prints text in a red +# colour +# + +COL=70 +SET_COL="echo -en \\033[${COL}G" +NORMAL="echo -en \\033[0;39m" +SUCCESS="echo -en \\033[1;32m" +FAILURE="echo -en \\033[1;31m" + +# +# The evaluate_retval function evaluates the return value of the process +# that was run just before this function was called. If the return value +# was 0, indicating success, the print_status function is called with +# the 'success' parameter. Otherwise the print_status function is called +# with the failure parameter. +# + +evaluate_retval() +{ + if [ $? = 0 ] + then + print_status success + else + print_status failure + fi +} + +# +# The print_status prints [ OK ] or [FAILED] to the screen. OK appears +# in the colour defined by the SUCCESS variable and FAILED appears in +# the colour defined by the FAILURE variable. Both are printed starting +# in the colomn defined by the COL variable. +# + +print_status() +{ + +# +# If no parameters are given to the print_status function, print usage +# information. +# + + if [ $# = 0 ] + then + echo "Usage: print_status {success|failure}" + return 1 + fi + + case "$1" in + success) + $SET_COL + echo -n "[ " + $SUCCESS + echo -n "OK" + $NORMAL + echo " ]" + ;; + failure) + $SET_COL + echo -n "[" + $FAILURE + echo -n "FAILED" + $NORMAL + echo "]" + ;; + esac + +} + +# +# The loadproc function starts a process (often a daemon) with +# proper error checking +# + +loadproc() +{ + +# +# If no parameters are given to the print_status function, print usage +# information. + +# + + if [ $# = 0 ] + then + echo "Usage: loadproc {program}" + exit 1 + fi +# +# Find the basename of the first parameter (the daemon's name without +# the path +# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after +# basename ran) +# + + base=$(/usr/bin/basename $1) +# +# the pidlist variable will contains the output of the pidof command. +# pidof will try to find the PID's that belong to a certain string; +# $base in this case +# + + pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base) + + pid="" + + for apid in $pidlist + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done +# +# If the $pid variable contains anything (from the previous for loop) it +# means the daemon is already running +# + + if [ ! -n "$pid" ] + then +# +# Empty $pid variable means it's not running, so we run $* (all +# parameters giving to this function from the script) and then check the +# return value +# + $* + evaluate_retval + else +# +# The variable $pid was not empty, meaning it was already running. We +# print [FAILED] now +# + print_status failure + fi + +} + +# +# The killproc function kills a process with proper error checking +# + +killproc() +{ + +# +# If no parameters are given to the print_status function, print usage +# information. + +# + + if [ $# = 0 ] + then + echo "Usage: killproc {program} [signal]" + exit 1 + fi + +# +# Find the basename of the first parameter (the daemon's name without +# the path +# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after +# basename ran) +# + + base=$(/usr/bin/basename $1) + +# +# Check if we gave a signal to kill the process with (like -HUP, -TERM, +# -KILL, etc) to this function (the second parameter). If no second +# parameter was provided set the nolevel variable. Else set the +# killlevel variable to the value of $2 (the second parameter) +# + + if [ "$2" != "" ] + then + killlevel=-$2 + else + nolevel=1 + fi + +# +# the pidlist variable will contains the output of the pidof command. +# pidof will try to find the PID's that belong to a certain string; +# $base in this case + + pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base) + + pid="" + + for apid in $pidlist + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + +# +# If $pid contains something from the previous for loop it means one or + +# more PID's were found that belongs to the processes to be killed +# + if [ -n "$pid" ] + then +# +# If no kill level was specified we'll try -TERM first and then sleep +# for 2 seconds to allow the kill to be completed +# + if [ "$nolevel" = 1 ] + then + /bin/kill -TERM $pid +/usr/bin/sleep 2 +# +# If after -TERM the PID still exists we'll try killing it with -KILL +# and wait for 2 seconds again to allow the kill to be completed +# + + if ps h $pid >/dev/null 2>&1 + then + /bin/kill -KILL $pid +/usr/bin/sleep 2 + fi + /bin/ps h $pid >/dev/null 2>&1 + if [ $? = 0 ] + then +# +# If after the -KILL it still exists it can't be killed for some reason +# and we'll print [FAILED] +# + print_status failure + else +# +# It was killed, remove possible stale PID file in /var/run and +# print [ OK ] +# + /bin/rm -f /var/run/$base.pid + print_status success + fi + else +# +# A kill level was provided. Kill with the provided kill level and wait +# for 2 seconds to allow the kill to be completed + +# + /bin/kill $killlevel $pid +/usr/bin/sleep 2 + /bin/ps h $pid >/dev/null 2>&1 + if [ $? = 0 ] + then +# +# If ps' return value is 0 it means it ran ok which indicates that the +# PID still exists. This means the process wasn't killed properly with +# the signal provided. Print [FAILED] +# + print_status failure + else +# +# If the return value was 1 or higher it means the PID didn't exist +# anymore which means it was killed successfully. Remove possible stale +# PID file and print [ OK ] +# + /bin/rm -f /var/run/$base.pid + print_status success + fi + fi + else +# +# The PID didn't exist so we can't attempt to kill it. Print [FAILED] +# + print_status failure + fi +} + +# +# The reloadproc functions sends a signal to a daemon telling it to +# reload it's configuration file. This is almost identical to the +# killproc function with the exception that it won't try to kill it with +# a -KILL signal (aka -9) +# + +reloadproc() +{ + +# +# If no parameters are given to the print_status function, print usage +# information. + +# + + if [ $# = 0 ] + then + echo "Usage: reloadproc {program} [signal]" + exit 1 + fi + +# +# Find the basename of the first parameter (the daemon's name without +# the path +# that was provided so /usr/sbin/syslogd becomes plain 'syslogd' after +# basename ran) +# + + base=$(/usr/bin/basename $1) + +# +# Check if we gave a signal to send to the process (like -HUP) +# to this function (the second parameter). If no second +# parameter was provided set the nolevel variable. Else set the +# killlevel variable to the value of $2 (the second parameter) +# + + + if [ -n "$2" ] + then + killlevel=-$2 + else + nolevel=1 + fi + +# +# the pidlist variable will contains the output of the pidof command. +# pidof will try to find the PID's that belong to a certain string; +# $base in this case + +# + + pidlist=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $base) + + pid="" + + for apid in $pidlist + do + if [ -d /proc/$apid ] + then + pid="$pid $apid" + fi + done + +# +# If $pid contains something from the previous for loop it means one or +# more PID's were found that belongs to the processes to be reloaded +# + + if [ -n "$pid" ] + then + +# +# If nolevel was set we will use the default reload signal SIGHUP. +# + + if [ "$nolevel" = 1 ] + then + /bin/kill -SIGHUP $pid + evaluate_retval + else +# +# Else we will use the provided signal +# + + /bin/kill $killlevel $pid + evaluate_retval + fi + else +# +# If $pid is empty no PID's have been found that belong to the process +# and print [FAILED] +# + + print_status failure + fi +} + +# +# The statusproc function will try to find out if a process is running +# or not +# + +statusproc() +{ + +# +# If no parameters are given to the print_status function, print usage +# information. + +# + + if [ $# = 0 ] + then + echo "Usage: status {program}" + return 1 + fi + +# +# $pid will contain a list of PID's that belong to a process +# + + pid=$(/bin/pidof -o $$ -o $PPID -o %PPID -x $1) + if [ -n "$pid" ] + then +# +# If $pid contains something, the process is running, print the contents +# of the $pid variable +# + echo "$1 running with Process ID $pid" + return 0 + fi + +# +# If $pid doesn't contain it check if a PID file exists and inform the +# user about this stale file. +# + + if [ -f /var/run/$1.pid ] + then + pid=$(/usr/bin/head -1 /var/run/$1.pid) + if [ -n "$pid" ] + then + echo "$1 not running but /var/run/$1.pid exists" + return 1 + fi + else + echo "$1 is not running" + fi + +} + +# End /etc/init.d/functions +EOF + + + + + diff --git a/chapter07/halt.sgml b/chapter07/halt.sgml deleted file mode 100644 index f7849ad0b..000000000 --- a/chapter07/halt.sgml +++ /dev/null @@ -1,27 +0,0 @@ - -Creating the halt script - - -Create a new file /etc/init.d/halt containing the -following: - - - - -cat > halt << "EOF" -#!/bin/sh -# Begin /etc/init.d/halt - -# -# Call halt. See man halt for the meaning of the parameters -# - -/sbin/halt -d -f -i -p - -# End /etc/init.d/halt -EOF - - - - - diff --git a/chapter07/halt.xml b/chapter07/halt.xml new file mode 100644 index 000000000..f7849ad0b --- /dev/null +++ b/chapter07/halt.xml @@ -0,0 +1,27 @@ + +Creating the halt script + + +Create a new file /etc/init.d/halt containing the +following: + + + + +cat > halt << "EOF" +#!/bin/sh +# Begin /etc/init.d/halt + +# +# Call halt. See man halt for the meaning of the parameters +# + +/sbin/halt -d -f -i -p + +# End /etc/init.d/halt +EOF + + + + + diff --git a/chapter07/hosts.xml b/chapter07/hosts.xml new file mode 100644 index 000000000..676291981 --- /dev/null +++ b/chapter07/hosts.xml @@ -0,0 +1,83 @@ + +Creating the /etc/hosts file + + +If you want to configure a network card, you have to decide on the +IP-address, FQDN and possible aliases for use in the /etc/hosts file. An +example is: + + +
+ + <my-IP> myhost.mydomain.org aliases + +
+ + +Make sure the IP-address is in the private network IP-address range. +Valid ranges are: + + +
+ + Class Networks + A 10.0.0.0 + B 172.16.0.0 through 172.31.0.0 + C 192.168.0.0 through 192.168.255.0 + +
+ + +A valid IP address could be 192.168.1.1. A valid FQDN for this IP could +be www.linuxfromscratch.org + + + +If you're not going to use a network card, you still need to come up with a +FQDN. This is necessary for programs like Sendmail to operate correctly (in +fact; Sendmail won't run when it can't determine the FQDN). + + + +If you don't configure a network card, create a new file +/etc/hosts by running: + + + + +cat > /etc/hosts << "EOF" +# Begin /etc/hosts (no network card version) + +127.0.0.1 www.mydomain.com <value of HOSTNAME> localhost + +# End /etc/hosts (no network card version) +EOF + + + + +If you do configure a network card, create a new file +/etc/hosts containing: + + + + +cat > /etc/hosts << "EOF" +# Begin /etc/hosts (network card version) + +127.0.0.1 localhost.localdomain localhost +192.168.1.1 www.mydomain.org <value of HOSTNAME> + +# End /etc/hosts (network card version) +EOF + + + + +Of course, change the 192.168.1.1 and www.mydomain.org to your own +liking (or requirements if you are assigned an IP-address by a network/system +administrator and you plan on connecting this machine to that network). + + +
+ diff --git a/chapter07/introduction.sgml b/chapter07/introduction.sgml deleted file mode 100644 index 5f1bea0b0..000000000 --- a/chapter07/introduction.sgml +++ /dev/null @@ -1,13 +0,0 @@ - -Introduction - - -This chapter will create the necessary scripts that are run at boottime. -These scripts perform tasks such as remounting the root file system -mounted read-only by the kernel into read-write mode, activiating the swap -partition(s), running a check on the root file system to make sure it's -intact and starting the daemons that the system uses. - - - - diff --git a/chapter07/introduction.xml b/chapter07/introduction.xml new file mode 100644 index 000000000..c9f266db3 --- /dev/null +++ b/chapter07/introduction.xml @@ -0,0 +1,13 @@ + +Introduction + + +This chapter will setup basic networking. Although you might not be +connected to a network, Linux software uses network functions anyway. +We'll be installing at least the local loopback device and a network +card as well if applicable. Also the proper bootscripts will be created +so that networking will be enabled during boot time. + + + + diff --git a/chapter07/loadkeys.sgml b/chapter07/loadkeys.sgml deleted file mode 100644 index bc17fd19d..000000000 --- a/chapter07/loadkeys.sgml +++ /dev/null @@ -1,36 +0,0 @@ - -Creating the loadkeys script - - -You only need to create this script if you don't have a default 101 keys -US keyboard layout. Create a new file -/etc/init.d/loadkeys containing the following: - - - - -cat > loadkeys << "EOF" -#!/bin/sh -# Begin /etc/init.d/loadkeys - -# -# Include the functions declared in the /etc/init.d/functions file -# - -source /etc/init.d/functions - -# -# Load the default keymap file -# - -echo -n "Loading keymap..." -/usr/bin/loadkeys -d >/dev/null -evaluate_retval - -# End /etc/init.d/loadkeys -EOF - - - - - diff --git a/chapter07/loadkeys.xml b/chapter07/loadkeys.xml new file mode 100644 index 000000000..bc17fd19d --- /dev/null +++ b/chapter07/loadkeys.xml @@ -0,0 +1,36 @@ + +Creating the loadkeys script + + +You only need to create this script if you don't have a default 101 keys +US keyboard layout. Create a new file +/etc/init.d/loadkeys containing the following: + + + + +cat > loadkeys << "EOF" +#!/bin/sh +# Begin /etc/init.d/loadkeys + +# +# Include the functions declared in the /etc/init.d/functions file +# + +source /etc/init.d/functions + +# +# Load the default keymap file +# + +echo -n "Loading keymap..." +/usr/bin/loadkeys -d >/dev/null +evaluate_retval + +# End /etc/init.d/loadkeys +EOF + + + + + diff --git a/chapter07/localnet-symperm.xml b/chapter07/localnet-symperm.xml new file mode 100644 index 000000000..137c3b7e5 --- /dev/null +++ b/chapter07/localnet-symperm.xml @@ -0,0 +1,19 @@ + +Setting up permissions and symlink + + +Set the proper file permissions and create the necessary symlink by +running the following commands: + + +
+ + cd /etc/init.d && + chmod 754 localnet && + cd ../rcS.d && + ln -s ../init.d/localnet S100localnet + +
+ +
+ diff --git a/chapter07/localnet.xml b/chapter07/localnet.xml new file mode 100644 index 000000000..e82f9ba0c --- /dev/null +++ b/chapter07/localnet.xml @@ -0,0 +1,59 @@ + +Creating the /etc/init.d/localnet bootscript + + +Create a new file /etc/init.d/localnet containing +the following: + + + + +cat > /etc/init.d/localnet << "EOF" +#!/bin/sh +# Begin /etc/init.d/localnet + +# +# Include the functions declared in the /etc/init.d/functions file +# and include the variables from the /etc/sysconfig/network file. +# + +source /etc/init.d/functions +source /etc/sysconfig/network + +case "$1" in + start) + echo -n "Bringing up the loopback interface..." + /sbin/ifconfig lo 127.0.0.1 + evaluate_retval + + echo -n "Setting up hostname..." + /bin/hostname $HOSTNAME + evaluate_retval + ;; + + stop) + echo -n "Bringing down the loopback interface..." + /sbin/ifconfig lo down + evaluate_retval + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: $0: {start|stop|restart}" + exit 1 + ;; +esac + +# End /etc/init.d/localnet +EOF + + + +&c9-localnet-symperm; + + + diff --git a/chapter07/mountfs.sgml b/chapter07/mountfs.sgml deleted file mode 100644 index f0fdf7a78..000000000 --- a/chapter07/mountfs.sgml +++ /dev/null @@ -1,110 +0,0 @@ - -Creating the mountfs script - - -Create a new file /etc/init.d/mountfs containing -the following: - - - - -cat > mountfs << "EOF" -#!/bin/sh -# Begin /etc/init.d/mountfs - -# -# Include the functions declared in the /etc/init.d/functions file -# - -source /etc/init.d/functions - -case "$1" in - start) - - # - # Remount the root partition in read-write mode. -n tells mount - # not to - # write to the /etc/mtab file (because it can't do this. The - # root - # partition is most likely still mounted in read-only mode - # - - echo -n "Remounting root file system in read-write mode..." - /bin/mount -n -o remount,rw / - evaluate_retval - - # - # First empty the /etc/mtab file. Then remount root partition - # in read-write - # mode again but pass -f to mount. This way mount does - # everything - # except the mount itself. This is needed for it to write to the - # mtab - # file which contains a list of currently mounted file systems. - # - - echo > /etc/mtab - /bin/mount -f -o remount,rw / - - # - # Remove the possible /fastboot and /forcefsck files. they are - # only - # supposed to be used during the next reboot's checkfs wich just - # happened. If you want to fastboot or forcefsck again you'll - # have to - # recreate the files - # - - /bin/rm -f /fastboot /forcefsck - - # - # Walk through /etc/fstab and mount all file systems that don't - # have the noauto option set in the fs_mntops field (the 4th - # field. - # See man fstab for more info) - # - - echo -n "Mounting other file systems..." - /bin/mount -a - evaluate_retval - ;; - - stop) - - # - # Deactive all the swap partitions - # - - echo -n "Deactivating swap..." - /sbin/swapoff -a - evaluate_retval - - # - # And unmount all the file systems, mounting the root file - # system - # read-only (all are unmounted but because root can't be - # unmounted - # at this point mount will automatically mount it read-only - # which - # is what supposed to happen. This way no data can be written - # anymore from disk) - # - - echo -n "Unmounting file systems..." - /bin/umount -a -r - evaluate_retval - ;; - - *) - echo "Usage: $0 {start|stop}" - exit 1 - ;; -esac - -# End /etc/init.d/mountfs -EOF - - - - - diff --git a/chapter07/mountfs.xml b/chapter07/mountfs.xml new file mode 100644 index 000000000..f0fdf7a78 --- /dev/null +++ b/chapter07/mountfs.xml @@ -0,0 +1,110 @@ + +Creating the mountfs script + + +Create a new file /etc/init.d/mountfs containing +the following: + + + + +cat > mountfs << "EOF" +#!/bin/sh +# Begin /etc/init.d/mountfs + +# +# Include the functions declared in the /etc/init.d/functions file +# + +source /etc/init.d/functions + +case "$1" in + start) + + # + # Remount the root partition in read-write mode. -n tells mount + # not to + # write to the /etc/mtab file (because it can't do this. The + # root + # partition is most likely still mounted in read-only mode + # + + echo -n "Remounting root file system in read-write mode..." + /bin/mount -n -o remount,rw / + evaluate_retval + + # + # First empty the /etc/mtab file. Then remount root partition + # in read-write + # mode again but pass -f to mount. This way mount does + # everything + # except the mount itself. This is needed for it to write to the + # mtab + # file which contains a list of currently mounted file systems. + # + + echo > /etc/mtab + /bin/mount -f -o remount,rw / + + # + # Remove the possible /fastboot and /forcefsck files. they are + # only + # supposed to be used during the next reboot's checkfs wich just + # happened. If you want to fastboot or forcefsck again you'll + # have to + # recreate the files + # + + /bin/rm -f /fastboot /forcefsck + + # + # Walk through /etc/fstab and mount all file systems that don't + # have the noauto option set in the fs_mntops field (the 4th + # field. + # See man fstab for more info) + # + + echo -n "Mounting other file systems..." + /bin/mount -a + evaluate_retval + ;; + + stop) + + # + # Deactive all the swap partitions + # + + echo -n "Deactivating swap..." + /sbin/swapoff -a + evaluate_retval + + # + # And unmount all the file systems, mounting the root file + # system + # read-only (all are unmounted but because root can't be + # unmounted + # at this point mount will automatically mount it read-only + # which + # is what supposed to happen. This way no data can be written + # anymore from disk) + # + + echo -n "Unmounting file systems..." + /bin/umount -a -r + evaluate_retval + ;; + + *) + echo "Usage: $0 {start|stop}" + exit 1 + ;; +esac + +# End /etc/init.d/mountfs +EOF + + + + + diff --git a/chapter07/network.xml b/chapter07/network.xml new file mode 100644 index 000000000..603c61b55 --- /dev/null +++ b/chapter07/network.xml @@ -0,0 +1,23 @@ + +Creating the /etc/sysconfig/network file + + +Create a new file /etc/sysconfig/network and put the +hostname in it by running: + + +
+ + echo "HOSTNAME=lfs" > /etc/sysconfig/network + +
+ + +Replace lfs by the name you wish to call your computer. +Please not that you should not enter the FQDN (Fully Qualified Domain +Name) here. That information will be put in the +/etc/hosts file later. + + +
+ diff --git a/chapter07/rc.sgml b/chapter07/rc.sgml deleted file mode 100644 index 3aba51da3..000000000 --- a/chapter07/rc.sgml +++ /dev/null @@ -1,253 +0,0 @@ - -Creating the rc script - - -The first main bootscript is the /etc/init.d/rc script. -Create a new file /etc/init.d/rc containing the -following: - - - -cat > rc << "EOF" -#!/bin/sh -# Begin /etc/init.d/rc -# -# By Jason Pearce - jason.pearce@linux.org -# Modified by Gerard Beekmans - gerard@linuxfromscratch.org -# print_error_msg based on ideas by Simon Perreault - nomis80@yahoo.com - -# -# Include the functions declared in the /etc/init.d/functions file -# - -source /etc/init.d/functions - -# -# The print_error_msg function prints an error message when an unforseen -# error occured that wasn't trapped for some reason by a evaluate_retval -# call or error checking in different ways. - -print_error_msg() -{ - - echo - $FAILURE - echo -n "You should not read this error message. It means " - echo "that an unforseen error " - echo -n "took place and subscript $i exited with " - echo "a return value " - echo -n "of $error_value for an unknown reason. If you're able " - echo "to trace this error down " - echo -n "to a bug in one of the files provided by this book, " - echo "please be so kind to " - echo -n "inform us at lfs-discuss@linuxfromscratch.org" - $NORMAL - echo - echo - echo "Press a key to continue..." - read -} - -# -# If you uncomment the debug variable below none of the scripts will be -# executed, just the script name and parameters will be echo'ed to the -# screen so you can see how the scripts are called by rc. -# - -# Un-comment the following for debugging. -# debug=echo - -# -# Start script or program. -# -startup() { - -$debug $* - -} - -# -# Ignore CTRL-C only in this shell, so we can interrupt subprocesses. -# - -trap ":" INT QUIT TSTP - -# -# Now find out what the current and what the previous runlevel are. The -# $RUNLEVEL variable is set by init for all it's children. This script -# runs as a child of init. -# - -runlevel=$RUNLEVEL - -# -# Get first argument. Set new runlevel to this argument. If no runlevel -# was passed to this script we won't change runlevels. -# - -[ "$1" != "" ] && runlevel=$1 -if [ "$runlevel" = "" ] -then - echo "Usage: $0 <runlevel>" >&2 - exit 1 -fi - -# -# The same goes for $PREVLEVEL (see above for $RUNLEVEL). previous will -# be set to the previous run level. If $PREVLEVEL is not set it means -# that there is no previous runlevel and we'll set previous to N. -# - -previous=$PREVLEVEL -[ "$previous" = "" ] && previous=N - -export runlevel previous - -# -# Is there an rc directory for the new runlevel? -# - -if [ -d /etc/rc$runlevel.d ] - -then - -# -# If so, first collect all the K* scripts in the new run level. -# - - if [ $previous != N ] - then - for i in /etc/rc$runlevel.d/K* - do - [ ! -f $i ] && continue - -# -# the suffix variable will contain the script name without the leading -# Kxxx -# - - suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9][0-9]} -# -# If there is a start script for this K script in the previous runlevel -# determine what it's full path is -# - previous_start=/etc/rc$previous.d/S[0-9][0-9][0-9]$suffix -# -# If there was no previous run level it could be that something was -# started in rcS.d (sysinit level) so we'll determine the path for that -# possibility as well. -# - - sysinit_start=/etc/rcS.d/S[0-9][0-9][0-9]$suffix - -# -# Stop the service if there is a start script in the previous run level -# or in the sysinit level. If previous_start or sysinit_start do not -# exist the 'continue' command is run which causes the script to abort -# this iteration of the for loop and continue with the next iteration. -# This boils down to that it won't run the commands after the next two -# lines and start over from the top of this for loop. See man bash for -# more info on this. -# - - [ ! -f $previous_start ] && - [ ! -f $sysinit_start ] && continue - -# -# If we found previous_start or sysinit_start, run the K script -# - - startup $i stop - error_value=$? -# -# If the return value of the script is not 0, something went wrong with -# error checking inside the script. the print_error_msg function will be -# called and the message plus the return value of the K script will be -# printed to the screen - -# - - if [ $error_value != 0 ] - then - print_error_msg - fi - - done - fi - -# -# Now run the START scripts for this runlevel. -# - - for i in /etc/rc$runlevel.d/S* - do - [ ! -f $i ] && continue - - if [ $previous != N ] - then -# -# Find start script in previous runlevel and stop script in this -# runlevel. -# - - suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9][0-9]} - stop=/etc/rc$runlevel.d/K[0-9][0-9][0-9]$suffix - previous_start=/etc/rc$previous.d/S[0-9][0-9][0-9]$suffix -# -# If there is a start script in the previous level and no stop script in -# this level, we don't have to re-start the service; abort this -# iteration and start the next one. -# - - [ -f $previous_start ] && [ ! -f $stop ] && - continue - fi - - case "$runlevel" in - 0|6) - -# -# levels 0 and 6 are halt and reboot levels. We don't really start -# anything here so we call with the 'stop' parameter -# - - startup $i stop - error_value=$? -# -# If the return value of the script is not 0, something went wrong with -# error checking inside the script. the print_error_msg function will be -# called and the message plus the return value of the K script will be -# printed to the screen -# - - if [ $error_value != 0 ] - then - print_error_msg - fi - ;; - *) - startup $i start - error_value=$? -# -# If the return value of the script is not 0, something went wrong with -# error checking inside the script. the print_error_msg function will be -# called and the message plus the return value of the K script will be -# printed to the screen -# - - if [ $error_value != 0 ] - then - print_error_msg - fi - ;; - esac - done -fi - -# End /etc/init.d/rc -EOF - - - - - diff --git a/chapter07/rc.xml b/chapter07/rc.xml new file mode 100644 index 000000000..3aba51da3 --- /dev/null +++ b/chapter07/rc.xml @@ -0,0 +1,253 @@ + +Creating the rc script + + +The first main bootscript is the /etc/init.d/rc script. +Create a new file /etc/init.d/rc containing the +following: + + + +cat > rc << "EOF" +#!/bin/sh +# Begin /etc/init.d/rc +# +# By Jason Pearce - jason.pearce@linux.org +# Modified by Gerard Beekmans - gerard@linuxfromscratch.org +# print_error_msg based on ideas by Simon Perreault - nomis80@yahoo.com + +# +# Include the functions declared in the /etc/init.d/functions file +# + +source /etc/init.d/functions + +# +# The print_error_msg function prints an error message when an unforseen +# error occured that wasn't trapped for some reason by a evaluate_retval +# call or error checking in different ways. + +print_error_msg() +{ + + echo + $FAILURE + echo -n "You should not read this error message. It means " + echo "that an unforseen error " + echo -n "took place and subscript $i exited with " + echo "a return value " + echo -n "of $error_value for an unknown reason. If you're able " + echo "to trace this error down " + echo -n "to a bug in one of the files provided by this book, " + echo "please be so kind to " + echo -n "inform us at lfs-discuss@linuxfromscratch.org" + $NORMAL + echo + echo + echo "Press a key to continue..." + read +} + +# +# If you uncomment the debug variable below none of the scripts will be +# executed, just the script name and parameters will be echo'ed to the +# screen so you can see how the scripts are called by rc. +# + +# Un-comment the following for debugging. +# debug=echo + +# +# Start script or program. +# +startup() { + +$debug $* + +} + +# +# Ignore CTRL-C only in this shell, so we can interrupt subprocesses. +# + +trap ":" INT QUIT TSTP + +# +# Now find out what the current and what the previous runlevel are. The +# $RUNLEVEL variable is set by init for all it's children. This script +# runs as a child of init. +# + +runlevel=$RUNLEVEL + +# +# Get first argument. Set new runlevel to this argument. If no runlevel +# was passed to this script we won't change runlevels. +# + +[ "$1" != "" ] && runlevel=$1 +if [ "$runlevel" = "" ] +then + echo "Usage: $0 <runlevel>" >&2 + exit 1 +fi + +# +# The same goes for $PREVLEVEL (see above for $RUNLEVEL). previous will +# be set to the previous run level. If $PREVLEVEL is not set it means +# that there is no previous runlevel and we'll set previous to N. +# + +previous=$PREVLEVEL +[ "$previous" = "" ] && previous=N + +export runlevel previous + +# +# Is there an rc directory for the new runlevel? +# + +if [ -d /etc/rc$runlevel.d ] + +then + +# +# If so, first collect all the K* scripts in the new run level. +# + + if [ $previous != N ] + then + for i in /etc/rc$runlevel.d/K* + do + [ ! -f $i ] && continue + +# +# the suffix variable will contain the script name without the leading +# Kxxx +# + + suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9][0-9]} +# +# If there is a start script for this K script in the previous runlevel +# determine what it's full path is +# + previous_start=/etc/rc$previous.d/S[0-9][0-9][0-9]$suffix +# +# If there was no previous run level it could be that something was +# started in rcS.d (sysinit level) so we'll determine the path for that +# possibility as well. +# + + sysinit_start=/etc/rcS.d/S[0-9][0-9][0-9]$suffix + +# +# Stop the service if there is a start script in the previous run level +# or in the sysinit level. If previous_start or sysinit_start do not +# exist the 'continue' command is run which causes the script to abort +# this iteration of the for loop and continue with the next iteration. +# This boils down to that it won't run the commands after the next two +# lines and start over from the top of this for loop. See man bash for +# more info on this. +# + + [ ! -f $previous_start ] && + [ ! -f $sysinit_start ] && continue + +# +# If we found previous_start or sysinit_start, run the K script +# + + startup $i stop + error_value=$? +# +# If the return value of the script is not 0, something went wrong with +# error checking inside the script. the print_error_msg function will be +# called and the message plus the return value of the K script will be +# printed to the screen + +# + + if [ $error_value != 0 ] + then + print_error_msg + fi + + done + fi + +# +# Now run the START scripts for this runlevel. +# + + for i in /etc/rc$runlevel.d/S* + do + [ ! -f $i ] && continue + + if [ $previous != N ] + then +# +# Find start script in previous runlevel and stop script in this +# runlevel. +# + + suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9][0-9]} + stop=/etc/rc$runlevel.d/K[0-9][0-9][0-9]$suffix + previous_start=/etc/rc$previous.d/S[0-9][0-9][0-9]$suffix +# +# If there is a start script in the previous level and no stop script in +# this level, we don't have to re-start the service; abort this +# iteration and start the next one. +# + + [ -f $previous_start ] && [ ! -f $stop ] && + continue + fi + + case "$runlevel" in + 0|6) + +# +# levels 0 and 6 are halt and reboot levels. We don't really start +# anything here so we call with the 'stop' parameter +# + + startup $i stop + error_value=$? +# +# If the return value of the script is not 0, something went wrong with +# error checking inside the script. the print_error_msg function will be +# called and the message plus the return value of the K script will be +# printed to the screen +# + + if [ $error_value != 0 ] + then + print_error_msg + fi + ;; + *) + startup $i start + error_value=$? +# +# If the return value of the script is not 0, something went wrong with +# error checking inside the script. the print_error_msg function will be +# called and the message plus the return value of the K script will be +# printed to the screen +# + + if [ $error_value != 0 ] + then + print_error_msg + fi + ;; + esac + done +fi + +# End /etc/init.d/rc +EOF + + + + + diff --git a/chapter07/rcS.sgml b/chapter07/rcS.sgml deleted file mode 100644 index 908059d04..000000000 --- a/chapter07/rcS.sgml +++ /dev/null @@ -1,43 +0,0 @@ - -Creating the rcS script - - -The second main bootscript is the rcS script. Create a -new file /etc/init.d/rcS containing the following: - - - - -cat > rcS << "EOF" -#!/bin/sh -# Begin /etc/init.d/rcS - -# -# See the rc script for the extensive comments on the constructions -# used here -# - -runlevel=S -prevlevel=N -umask 022 -export runlevel prevlevel - -trap ":" INT QUIT TSTP - -# -# Collect all the S scripts in /etc/rcS.d and execute them in the same -# - -for i in /etc/rcS.d/S??* -do - [ ! -f "$i" ] && continue; - $i start -done - -# End /etc/init.d/rcS -EOF - - - - - diff --git a/chapter07/rcS.xml b/chapter07/rcS.xml new file mode 100644 index 000000000..908059d04 --- /dev/null +++ b/chapter07/rcS.xml @@ -0,0 +1,43 @@ + +Creating the rcS script + + +The second main bootscript is the rcS script. Create a +new file /etc/init.d/rcS containing the following: + + + + +cat > rcS << "EOF" +#!/bin/sh +# Begin /etc/init.d/rcS + +# +# See the rc script for the extensive comments on the constructions +# used here +# + +runlevel=S +prevlevel=N +umask 022 +export runlevel prevlevel + +trap ":" INT QUIT TSTP + +# +# Collect all the S scripts in /etc/rcS.d and execute them in the same +# + +for i in /etc/rcS.d/S??* +do + [ ! -f "$i" ] && continue; + $i start +done + +# End /etc/init.d/rcS +EOF + + + + + diff --git a/chapter07/reboot.sgml b/chapter07/reboot.sgml deleted file mode 100644 index e57410c48..000000000 --- a/chapter07/reboot.sgml +++ /dev/null @@ -1,30 +0,0 @@ - -Creating the reboot script - - -Create a new file /etc/init.d/reboot containing the -following: - - - - -cat > reboot << "EOF" -#!/bin/sh -# Begin /etc/init.d/reboot - -# -# Call reboot. See man halt for the meaning of the parameters -# - - -echo "System reboot in progress..." - -/sbin/reboot -d -f -i - -# End /etc/init.d/reboot -EOF - - - - - diff --git a/chapter07/reboot.xml b/chapter07/reboot.xml new file mode 100644 index 000000000..e57410c48 --- /dev/null +++ b/chapter07/reboot.xml @@ -0,0 +1,30 @@ + +Creating the reboot script + + +Create a new file /etc/init.d/reboot containing the +following: + + + + +cat > reboot << "EOF" +#!/bin/sh +# Begin /etc/init.d/reboot + +# +# Call reboot. See man halt for the meaning of the parameters +# + + +echo "System reboot in progress..." + +/sbin/reboot -d -f -i + +# End /etc/init.d/reboot +EOF + + + + + diff --git a/chapter07/sendsignals.sgml b/chapter07/sendsignals.sgml deleted file mode 100644 index 3aff74996..000000000 --- a/chapter07/sendsignals.sgml +++ /dev/null @@ -1,44 +0,0 @@ - -Creating the sendsignals script - - -Create a new file /etc/init.d/sendsignals -containing the following: - - - - -cat > sendsignals << "EOF" -#!/bin/sh -# Begin /etc/init.d/sendsignals - -# -# Include the functions declared in the /etc/init.d/functions file -# - -source /etc/init.d/functions - -# -# Send all the remaining processes the TERM signal -# - -echo -n "Sending all processes the TERM signal..." -/sbin/killall5 -15 -evaluate_retval - -# -# Send all the remaining process (after sending them the TERM signal -# before) the KILL signal. -# - -echo -n "Sending all processes the KILL signal..." -/sbin/killall5 -9 -evaluate_retval - -# End /etc/init.d/sendsignals -EOF - - - - - diff --git a/chapter07/sendsignals.xml b/chapter07/sendsignals.xml new file mode 100644 index 000000000..3aff74996 --- /dev/null +++ b/chapter07/sendsignals.xml @@ -0,0 +1,44 @@ + +Creating the sendsignals script + + +Create a new file /etc/init.d/sendsignals +containing the following: + + + + +cat > sendsignals << "EOF" +#!/bin/sh +# Begin /etc/init.d/sendsignals + +# +# Include the functions declared in the /etc/init.d/functions file +# + +source /etc/init.d/functions + +# +# Send all the remaining processes the TERM signal +# + +echo -n "Sending all processes the TERM signal..." +/sbin/killall5 -15 +evaluate_retval + +# +# Send all the remaining process (after sending them the TERM signal +# before) the KILL signal. +# + +echo -n "Sending all processes the KILL signal..." +/sbin/killall5 -9 +evaluate_retval + +# End /etc/init.d/sendsignals +EOF + + + + + diff --git a/chapter07/setclock.sgml b/chapter07/setclock.sgml deleted file mode 100644 index 9e5992c39..000000000 --- a/chapter07/setclock.sgml +++ /dev/null @@ -1,93 +0,0 @@ - -Creating the setclock script - - -The following script is only for real use when your hardware clock (also -known as BIOS or CMOS clock) isn't set to GMT time. The recommended -setup is setting your hardware clock to GMT and have the time converted -to localtime using the /etc/localtime symbolic link. But if you run an -OS that doesn't understand a clock set to GMT (most notable are -Microsoft OS'es) you might want to set your clock to localtime so that -the time is properly displayed on those OS'es. This script will reset -the kernel time to the hardware clock without converting the time using -the /etc/localtime symlink. - - - -If you want to use this script on your system even if you have your -hardware clock set to GMT, then change the UTC variable below to the -value of 1. - - - - -cat > setclock << "EOF" -#!/bin/sh -# Begin /etc/init.d/setclock - -# -# Include the functions declared in the /etc/init.d/functions file -# and include the variables from the /etc/sysconfig/clock file -# - -source /etc/init.d/functions -source /etc/sysconfig/clock - -# -# Right now we want to set the kernel clock according to the hardware -# clock, so we use the -hctosys parameter. -# - -CLOCKPARAMS="--hctosys" - -# -# If the UTC variable is set in the /etc/sysconfig/clock file, add the -# -u parameter as well which tells hwclock that the hardware clock is -# set to UTC time instead of local time. -# - -case "$UTC" in - yes|true|1) - CLOCKPARAMS="$CLOCKPARAMS -u" - ;; -esac - -echo -n "Setting clock..." -/sbin/hwclock $CLOCKPARAMS -evaluate_retval - -# End /etc/init.d/setclock -EOF - - - - -Creating the /etc/sysconfig/clock file - - -Create a new file /etc/sysconfig/clock by running -the following: - - - - -cat > /etc/sysconfig/clock << "EOF" -# Begin /etc/sysconfig/clock - -UTC=1 - -# End /etc/sysconfig/clock -EOF - - - - -If your hardware clock (also known as BIOS or CMOS clock) is not set to -GMT time, than set the UTC variable in the /etc/sysconfig/clock file to -the value 0 (zero). - - - - - - diff --git a/chapter07/setclock.xml b/chapter07/setclock.xml new file mode 100644 index 000000000..9e5992c39 --- /dev/null +++ b/chapter07/setclock.xml @@ -0,0 +1,93 @@ + +Creating the setclock script + + +The following script is only for real use when your hardware clock (also +known as BIOS or CMOS clock) isn't set to GMT time. The recommended +setup is setting your hardware clock to GMT and have the time converted +to localtime using the /etc/localtime symbolic link. But if you run an +OS that doesn't understand a clock set to GMT (most notable are +Microsoft OS'es) you might want to set your clock to localtime so that +the time is properly displayed on those OS'es. This script will reset +the kernel time to the hardware clock without converting the time using +the /etc/localtime symlink. + + + +If you want to use this script on your system even if you have your +hardware clock set to GMT, then change the UTC variable below to the +value of 1. + + + + +cat > setclock << "EOF" +#!/bin/sh +# Begin /etc/init.d/setclock + +# +# Include the functions declared in the /etc/init.d/functions file +# and include the variables from the /etc/sysconfig/clock file +# + +source /etc/init.d/functions +source /etc/sysconfig/clock + +# +# Right now we want to set the kernel clock according to the hardware +# clock, so we use the -hctosys parameter. +# + +CLOCKPARAMS="--hctosys" + +# +# If the UTC variable is set in the /etc/sysconfig/clock file, add the +# -u parameter as well which tells hwclock that the hardware clock is +# set to UTC time instead of local time. +# + +case "$UTC" in + yes|true|1) + CLOCKPARAMS="$CLOCKPARAMS -u" + ;; +esac + +echo -n "Setting clock..." +/sbin/hwclock $CLOCKPARAMS +evaluate_retval + +# End /etc/init.d/setclock +EOF + + + + +Creating the /etc/sysconfig/clock file + + +Create a new file /etc/sysconfig/clock by running +the following: + + + + +cat > /etc/sysconfig/clock << "EOF" +# Begin /etc/sysconfig/clock + +UTC=1 + +# End /etc/sysconfig/clock +EOF + + + + +If your hardware clock (also known as BIOS or CMOS clock) is not set to +GMT time, than set the UTC variable in the /etc/sysconfig/clock file to +the value 0 (zero). + + + + + + diff --git a/chapter07/symperm.sgml b/chapter07/symperm.sgml deleted file mode 100644 index 044f29d7a..000000000 --- a/chapter07/symperm.sgml +++ /dev/null @@ -1,49 +0,0 @@ - -Setting up symlinks and permissions - - -Give these files the proper permissions and create the necessary symlinks -by running the following commands. If you did not create the loadkeys -and setclock scripts, make sure you don't type them in the commands -below. - - -
- - cd /etc/init.d && - chmod 754 rc rcS functions checkfs halt loadkeys mountfs - reboot && - chmod 754 sendsignals setclock sysklogd template - && - cd ../rc0.d && - ln -s ../init.d/sysklogd K900sysklogd && - ln -s ../init.d/sendsignals S800sendsignals && - - ln -s ../init.d/mountfs S900mountfs && - ln -s ../init.d/halt S999halt && - cd ../rc6.d && - ln -s ../init.d/sysklogd K900sysklogd && - ln -s ../init.d/sendsignals S800sendsignals && - - ln -s ../init.d/mountfs S900mountfs && - ln -s ../init.d/reboot S999reboot && - cd ../rcS.d && - ln -s ../init.d/checkfs S200checkfs && - ln -s ../init.d/mountfs S300mountfs && - ln -s ../init.d/setclock S400setclock && - ln -s ../init.d/loadkeys S500loadkeys && - cd ../rc1.d && - ln -s ../init.d/sysklogd K900sysklogd && - cd ../rc2.d && - ln -s ../init.d/sysklogd S100sysklogd && - cd ../rc3.d && - ln -s ../init.d/sysklogd S100sysklogd && - cd ../rc4.d && - ln -s ../init.d/sysklogd S100sysklogd && - cd ../rc5.d && - ln -s ../init.d/sysklogd S100sysklogd - -
- -
- diff --git a/chapter07/symperm.xml b/chapter07/symperm.xml new file mode 100644 index 000000000..044f29d7a --- /dev/null +++ b/chapter07/symperm.xml @@ -0,0 +1,49 @@ + +Setting up symlinks and permissions + + +Give these files the proper permissions and create the necessary symlinks +by running the following commands. If you did not create the loadkeys +and setclock scripts, make sure you don't type them in the commands +below. + + +
+ + cd /etc/init.d && + chmod 754 rc rcS functions checkfs halt loadkeys mountfs + reboot && + chmod 754 sendsignals setclock sysklogd template + && + cd ../rc0.d && + ln -s ../init.d/sysklogd K900sysklogd && + ln -s ../init.d/sendsignals S800sendsignals && + + ln -s ../init.d/mountfs S900mountfs && + ln -s ../init.d/halt S999halt && + cd ../rc6.d && + ln -s ../init.d/sysklogd K900sysklogd && + ln -s ../init.d/sendsignals S800sendsignals && + + ln -s ../init.d/mountfs S900mountfs && + ln -s ../init.d/reboot S999reboot && + cd ../rcS.d && + ln -s ../init.d/checkfs S200checkfs && + ln -s ../init.d/mountfs S300mountfs && + ln -s ../init.d/setclock S400setclock && + ln -s ../init.d/loadkeys S500loadkeys && + cd ../rc1.d && + ln -s ../init.d/sysklogd K900sysklogd && + cd ../rc2.d && + ln -s ../init.d/sysklogd S100sysklogd && + cd ../rc3.d && + ln -s ../init.d/sysklogd S100sysklogd && + cd ../rc4.d && + ln -s ../init.d/sysklogd S100sysklogd && + cd ../rc5.d && + ln -s ../init.d/sysklogd S100sysklogd + +
+ +
+ diff --git a/chapter07/sysklogd.sgml b/chapter07/sysklogd.sgml deleted file mode 100644 index 74e8b9d6d..000000000 --- a/chapter07/sysklogd.sgml +++ /dev/null @@ -1,67 +0,0 @@ - -Creating the sysklogd script - - -Create a new file /etc/init.d/sysklogd containing -the following: - - - - -cat > sysklogd << "EOF" -#!/bin/sh -# Begin /etc/init.d/sysklogd - -# -# Include the functions declared in the /etc/init.d/functions file -# - -source /etc/init.d/functions - -case "$1" in - start) - echo -n "Starting system log daemon..." - loadproc /usr/sbin/syslogd -m 0 - - echo -n "Starting kernel log daemon..." - loadproc /usr/sbin/klogd - ;; - - stop) - echo -n "Stopping kernel log daemon..." - killproc klogd - - echo -n "Stopping system log daemon..." - killproc syslogd - ;; - - reload) - echo -n "Reloading system log daemon configuration file..." - reloadproc syslogd 1 - ;; - - restart) - $0 stop - /usr/bin/sleep 1 - $0 start - ;; - - status) - statusproc /usr/sbin/syslogd - statusproc /usr/sbin/klogd - ;; - - *) - echo "Usage: $0 {start|stop|reload|restart|status}" - exit 1 - ;; - -esac - -# End /etc/init.d/sysklogd -EOF - - - - - diff --git a/chapter07/sysklogd.xml b/chapter07/sysklogd.xml new file mode 100644 index 000000000..74e8b9d6d --- /dev/null +++ b/chapter07/sysklogd.xml @@ -0,0 +1,67 @@ + +Creating the sysklogd script + + +Create a new file /etc/init.d/sysklogd containing +the following: + + + + +cat > sysklogd << "EOF" +#!/bin/sh +# Begin /etc/init.d/sysklogd + +# +# Include the functions declared in the /etc/init.d/functions file +# + +source /etc/init.d/functions + +case "$1" in + start) + echo -n "Starting system log daemon..." + loadproc /usr/sbin/syslogd -m 0 + + echo -n "Starting kernel log daemon..." + loadproc /usr/sbin/klogd + ;; + + stop) + echo -n "Stopping kernel log daemon..." + killproc klogd + + echo -n "Stopping system log daemon..." + killproc syslogd + ;; + + reload) + echo -n "Reloading system log daemon configuration file..." + reloadproc syslogd 1 + ;; + + restart) + $0 stop + /usr/bin/sleep 1 + $0 start + ;; + + status) + statusproc /usr/sbin/syslogd + statusproc /usr/sbin/klogd + ;; + + *) + echo "Usage: $0 {start|stop|reload|restart|status}" + exit 1 + ;; + +esac + +# End /etc/init.d/sysklogd +EOF + + + + + diff --git a/chapter07/template.sgml b/chapter07/template.sgml deleted file mode 100644 index 0c062ca30..000000000 --- a/chapter07/template.sgml +++ /dev/null @@ -1,60 +0,0 @@ - -Creating the template script - - -Create a new file /etc/init.d/template containing -the following: - - - - -cat > template << "EOF" -#!/bin/sh -# Begin /etc/init.d/ - -# -# Include the functions declared in the /etc/init.d/functions file -# - -source /etc/init.d/functions - -case "$1" in - start) - echo -n "Starting ..." - loadproc - ;; - - stop) - echo -n "Stopping ..." - killproc - ;; - - reload) - echo -n "Reloading ..." - reloadproc - ;; - - restart) - $0 stop - /usr/bin/sleep 1 - $0 start - ;; - - status) - statusproc - ;; - - *) - echo "Usage: $0 {start|stop|reload|restart|status}" - exit 1 - ;; - -esac - -# End /etc/init.d/ -EOF - - - - - diff --git a/chapter07/template.xml b/chapter07/template.xml new file mode 100644 index 000000000..0c062ca30 --- /dev/null +++ b/chapter07/template.xml @@ -0,0 +1,60 @@ + +Creating the template script + + +Create a new file /etc/init.d/template containing +the following: + + + + +cat > template << "EOF" +#!/bin/sh +# Begin /etc/init.d/ + +# +# Include the functions declared in the /etc/init.d/functions file +# + +source /etc/init.d/functions + +case "$1" in + start) + echo -n "Starting ..." + loadproc + ;; + + stop) + echo -n "Stopping ..." + killproc + ;; + + reload) + echo -n "Reloading ..." + reloadproc + ;; + + restart) + $0 stop + /usr/bin/sleep 1 + $0 start + ;; + + status) + statusproc + ;; + + *) + echo "Usage: $0 {start|stop|reload|restart|status}" + exit 1 + ;; + +esac + +# End /etc/init.d/ +EOF + + + + + -- cgit v1.2.3-54-g00ecf