cvs commit: LFS/bootscripts/sysconfig/network-devices/services static

nathan at linuxfromscratch.org nathan at linuxfromscratch.org
Wed Mar 17 14:24:24 PST 2004


nathan      04/03/17 15:24:24

  Modified:    bootscripts CHANGELOG Makefile
  Added:       bootscripts/lfs/init.d checkfs cleanfs functions halt
                        loadkeys localnet mountfs mountproc network rc
                        reboot sendsignals setclock swap sysklogd template
               bootscripts/lfs/sysconfig rc
               bootscripts/lfs/sysconfig/network-devices ifdown ifup
               bootscripts/lfs/sysconfig/network-devices/services static
  Removed:     bootscripts makesymlinks
               bootscripts/rc.d/init.d checkfs cleanfs functions halt
                        loadkeys localnet mountfs mountproc network rc
                        reboot sendsignals setclock swap sysklogd template
               bootscripts/sysconfig rc
               bootscripts/sysconfig/network-devices ifdown ifup
               bootscripts/sysconfig/network-devices/services static
  Log:
  Moved files around, as we no longer use the
  rc.d/rc{0,1,2,3,4,5,6,sysconfig} directories.
  
  some BLFS scripts may be added in the future, so this will help in organization
  
  Revision  Changes    Path
  1.25      +1 -0      LFS/bootscripts/CHANGELOG
  
  Index: CHANGELOG
  ===================================================================
  RCS file: /home/cvsroot/LFS/bootscripts/CHANGELOG,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- CHANGELOG	17 Mar 2004 08:38:19 -0000	1.24
  +++ CHANGELOG	17 Mar 2004 22:24:23 -0000	1.25
  @@ -1,6 +1,7 @@
   1.99.4 - March 17, 2004
   
   	* Fixed one last halt line in checkfs script
  +	* Moved the directory structure around
   	* Tagged as development release 1.99.4
   
   n/a - February 28, 2004
  
  
  
  1.6       +21 -21    LFS/bootscripts/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /home/cvsroot/LFS/bootscripts/Makefile,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Makefile	5 Feb 2004 02:38:40 -0000	1.5
  +++ Makefile	17 Mar 2004 22:24:23 -0000	1.6
  @@ -3,23 +3,23 @@
   install:
   	install -d -m 755 ${EXTDIR}/rc.d/rc{0,1,2,3,4,5,6,sysinit}.d
   	install -d -m 755 ${EXTDIR}/rc.d/init.d
  -	install -m 754 rc.d/init.d/checkfs      ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/cleanfs      ${EXTDIR}/rc.d/init.d/
  -	install -m 644 rc.d/init.d/functions    ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/halt         ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/loadkeys     ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/localnet     ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/mountfs      ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/mountproc    ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/network      ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/rc           ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/reboot       ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/rc           ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/sendsignals  ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/setclock     ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/swap         ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/sysklogd     ${EXTDIR}/rc.d/init.d/
  -	install -m 754 rc.d/init.d/template     ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/checkfs      ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/cleanfs      ${EXTDIR}/rc.d/init.d/
  +	install -m 644 lfs/init.d/functions    ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/halt         ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/loadkeys     ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/localnet     ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/mountfs      ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/mountproc    ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/network      ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/rc           ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/reboot       ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/rc           ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/sendsignals  ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/setclock     ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/swap         ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/sysklogd     ${EXTDIR}/rc.d/init.d/
  +	install -m 754 lfs/init.d/template     ${EXTDIR}/rc.d/init.d/
   	ln -s ../init.d/sysklogd    ${EXTDIR}/rc.d/rc0.d/K40sysklogd
   	ln -s ../init.d/network     ${EXTDIR}/rc.d/rc0.d/K50network
   	ln -s ../init.d/sendsignals ${EXTDIR}/rc.d/rc0.d/K60sendsignals
  @@ -53,9 +53,9 @@
   	ln -s ../init.d/loadkeys    ${EXTDIR}/rc.d/rcsysinit.d/S70loadkeys
   	ln -s ../init.d/localnet    ${EXTDIR}/rc.d/rcsysinit.d/S80localnet
   	install -d -m 755 ${EXTDIR}/sysconfig/network-devices/services
  -	install -m 644 sysconfig/rc                              ${EXTDIR}/sysconfig/
  -	install -m 754 sysconfig/network-devices/ifup            ${EXTDIR}/sysconfig/network-devices
  -	install -m 754 sysconfig/network-devices/ifdown          ${EXTDIR}/sysconfig/network-devices
  -	install -m 754 sysconfig/network-devices/services/static ${EXTDIR}/sysconfig/network-devices/services
  +	install -m 644 lfs/sysconfig/rc                              ${EXTDIR}/sysconfig/
  +	install -m 754 lfs/sysconfig/network-devices/ifup            ${EXTDIR}/sysconfig/network-devices
  +	install -m 754 lfs/sysconfig/network-devices/ifdown          ${EXTDIR}/sysconfig/network-devices
  +	install -m 754 lfs/sysconfig/network-devices/services/static ${EXTDIR}/sysconfig/network-devices/services
   
   .PHONY: install
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/checkfs
  
  Index: checkfs
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/checkfs - File System Check Script
  
  # Based on checkfs script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  # Patch to handle all fsck variants by A. Luebke - luebke at users.sourceforge.net
  
  # From man fsck
  # 0    - No errors
  # 1    - File system errors corrected
  # 2    - System should be rebooted
  # 4    - File system errors left uncorrected
  # 8    - Operational error
  # 16   - Usage or syntax error
  # 32   - Fsck canceled by user request
  # 128  - Shared library error
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		if [ -f /fastboot ]
  		then
  			echo "Fast boot requested, will not perform file system checks"
  			exit 0
  		fi
  
  		echo "Mounting root file system in read-only mode..."
  		mount -n -o remount,ro /
  		evaluate_retval
  
  		if [ $? != 0 ]
  		then
  			echo -n -e $FAILURE
  			echo
  			echo "Cannot check root file system because it could not"
  			echo "be mounted in read-only mode."
  			echo
  			echo -n "When you press Enter, this system will be halted."
  			echo -n -e $NORMAL
  			echo
  			echo "Press Enter to continue..."
  			read ENTER
  			halt -f
  		fi
  
  		if [ -f /forcefsck ]
  		then
  			echo "/forcefsck exists, forcing file system check"
  			options="-f"
  			else
  			options=""
  		fi
  
  		echo "Checking file systems..."
  		#Note: -a option used to be -p; but this fails e.g. on fsck.minix
  		fsck $options -a -A -C -T
  		error_value=$?
  
  		if [ "$error_value" = 1 ]
  		then
  			echo -n -e $WARNING
  			echo "File system errors were found and have been corrected."
  			echo "You may want to double-check that everything was fixed"
  			echo -n "properly"
  			echo -n -e $NORMAL
  			print_status warning
  		fi
  
  		if [ "$error_value" = 0 ]
  		then
  			print_status success
  		fi
  
  		if [ "$error_value" = 2 -o "$error_value" = 3 ]
  		then
  			echo -n -e $WARNING
  			echo "File system errors were found and have been corrected, but"
  			echo "the nature of the errors require this system to be rebooted."
  			echo
  			echo -n "When you press Enter, this system will be rebooted."
  			echo -n -e $NORMAL
  			print_status warning
  			echo
  			echo "Please Enter to continue..."
  			read ENTER
  			reboot -f
  		fi
  
  		if [ "$error_value" -gt 3 -a "$error_value" -lt 16 ]
  		then
  			echo -n -e $FAILURE
  			echo "File system errors were encountered that couldn't be"
  			echo "fixed automatically. This system cannot continue to boot"
  			echo "and will therefore be halted until those errors fixed manually"
  			echo "by a System Administrator."
  			echo
  			echo -n "When you press Enter, this system will be halted."
  			echo -n -e $NORMAL
  			print_status failure
  			echo
  			echo "Press Enter to continue..."
  			read ENTER
  			halt -f
  		fi
  
  		if [ "$error_value" -ge 16 ]
  		then 
  			echo -n -e $FAILURE
  			echo "Unexpected Failure running fsck. Exited with "$error_value
  			echo -n -e $NORMAL
  			print_status failure
  			exit $error_value
  		fi
  		;;
  	*)
  		echo "Usage: $0 {start}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/checkfs
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/cleanfs
  
  Index: cleanfs
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/cleanfs - Clean file system
  
  # Written by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		echo "Removing /var/run/* and /var/lock/*"
  		rm -rf /var/run/* /var/lock/*
  		evaluate_retval
  
  		echo "Creating new /var/run/utmp..."
  		echo > /var/run/utmp && chmod 644 /var/run/utmp
  		evaluate_retval
  
  		echo "Removing possible /etc/nologin /fastboot and /forcefsck..."
  		rm -f /etc/nologin /fastboot /forcefsck
  		evaluate_retval
  		;;
  	*)
  		echo "Usage: $0 {start}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/cleanfs
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/functions
  
  Index: functions
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/functions - Run Level Control Functions
  
  # Based on functions script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  # With code based on Matthias Benkmann's simpleinit-msb @
  # http://winterdrache.de/linux/newboot/index.html
  
  # Number of seconds between term signal and kill signal when stopping processes
  KILLDELAY=3
  
  umask 022
  export PATH="/bin:/usr/bin:/sbin:/usr/sbin"
  
  # Width of the Screen
  COLUMNS=$(stty size)
  COLUMNS=${COLUMNS##* }
  # When using remote connections, such as a serial port, stty size returns 0
  if [ "$COLUMNS" = "0" ]; then COLUMNS=80; fi
  
  # Measurements for positioning result messages
  COL=$(($COLUMNS - 10))
  WCOL=$(($COLUMNS - 30))
  
  # Set Cursur Position Commands, used via echo -e
  SET_COL="\\033[${COL}G"
  SET_WCOL="\\033[${WCOL}G"
  CURS_UP="\\033[A"
  
  # Set color commands, used via echo -e
  NORMAL="\\033[0;39m"
  SUCCESS="\\033[1;32m"
  WARNING="\\033[1;33m"
  FAILURE="\\033[1;31m"
  
  echo_ok()
  {
          echo -e "$CURS_UP$SET_COL"["$SUCCESS""  OK  ""$NORMAL"]
  }
  
  echo_failure()
  {
          echo -e "$CURS_UP$SET_COL"["$FAILURE"FAILED"$NORMAL"]
  }
  
  echo_warning()
  {
          echo -e "$CURS_UP$SET_WCOL$@$SET_COL"["$WARNING" WARN  "$NORMAL"]
  }
  
  # $i is inherited by the rc script
  print_error_msg()
  {
          echo
          echo "You should not be reading this error message. It means"
          echo "that an unforseen error took place in $i,"
          echo "which exited with a return value of $error_value"
          echo
          echo "If you're able to track this error down to a bug in one"
          echo "of the files provided by the LFS book, please be so kind"
          echo "to inform us at lfs-dev at linuxfromscratch.org"
          echo
          echo
          echo "Press Enter to continue..."
          read ENTER
  }
  
  # $i is inherited by the rc script
  check_script_status()
  {
          if [ ! -f $i ]
          then
                  echo "$i is not a valid symlink"
                  continue
          fi
  
          if [ ! -x $i ]
          then
                  echo "$i is not executable, skipping"
                  continue
          fi
  }
  
  evaluate_retval()
  {
          error_value=$?
  
          if [ $error_value = 0 ]
          then
                  print_status success
          else
                  print_status failure
  		sleep 5
          fi
  
          return 0
          #return $error_value
  }
  
  print_status()
  {
          if [ $# = 0 ]
          then
                  echo "Usage: $0 {success|warning|failure}"
                  return 1
          fi
  
          case "$1" in
                  success)
                          echo_ok
                  ;;
                  warning)
                          case "$2" in
                                  running)
                                          echo_warning "Already running"
                                  ;;
                                  not_running)
                                          echo_warning "Not running"
                                  ;;
                          esac
                  ;;
                  failure)
                          echo_failure
                  ;;
          esac
  }
  
  # Returns all of the pid #'s for $1 process
  getpids()
  {
          base=${1##*/}
          local lpids=""
          local pid
  
          pidlist=""
          lpids=$(pidof $base)
          for pid in $lpids
          do
                  if [ $pid -ne $$ ] && [ $pid -ne $PPID ]
                  then
                          pidlist="$pidlist $pid"
                  fi
          done
  }
  
  # Starts a program if it is currently not running
  loadproc()
  {
          if [ $# = 0 ]
          then
                  echo "Usage: loadproc {program}"
                  exit 1
          fi
  
          getpids $1
  
          if [ -z "$pidlist" ]
          then
                  "$@"
                  evaluate_retval
          else
                  print_status warning running
          fi
  }
  
  # Stops a process if it is running
  killproc()
  {
          if [ $# = 0 ]
          then
                  echo "Usage: killproc {program} [signal]"
                  exit 1
          fi
  
          if [ -z "$2" ]; then
                  signal=TERM
                  fallback=KILL
          else
                  signal=${2##-}
                  signal=${signal##SIG}
                  fallback=""
          fi
  
          getpids $1
  
          if [ -n "$pidlist" ]; then
                  failure=0
  
                  local i=0
                  for pid in $pidlist
                  do
                          kill -$signal $pid 2>/dev/null
  
                          while [ $i -lt $KILLDELAY ]; do
                                  kill -0 $pid 2>/dev/null || break
                                  sleep 1
                                  i=`expr $i + 1`
                          done
  
                          if [ -n "$fallback" ]; then kill -$fallback $pid 2>/dev/null; fi
  
                          kill -0 $pid 2>/dev/null && failure=1
                  done
  
                  base=${1##*/}
                  if [ $failure = 0 ]; then rm -f /var/run/$base.pid; fi
  
                  (exit $failure)
                  evaluate_retval
          else
                  print_status warning not_running
          fi
  }
  
  reloadproc()
  {
          if [ $# = 0 ]
          then
                  echo "Usage: reloadproc {program} [signal]"
                  exit 1
          fi
  
          if [ -z "$2" ]; then
                  signal=HUP
          else
                  signal=${2##-}
                  signal=${signal##SIG}
  
          fi
  
          getpids $1
  
          if [ -n "$pidlist" ]
          then
                  failure=0
  
                  for pid in $pidlist
                  do
                          kill -$signal $pid || failure=1
                  done
  
                  (exit $failure)
                  evaluate_retval
          else
                  print_status warning not_running
          fi
  }
  
  statusproc()
  {
          if [ $# = 0 ]
          then
                  echo "Usage: statusproc {program}"
                  exit 1
          fi
  
          base=${1##*/}
          getpids $base
  
          if [ -n "$pidlist" ]
          then
                  echo "$base is running with Process ID(s) $pidlist"
          else
                  if [ -s /var/run/$base.pid ]
                  then
                          echo "$1 is not running but /var/run/$base.pid exists"
                          return 1
                  else
                          echo "$1 is not running"
                  fi
          fi
  }
  
  # End $rc_base/init.d/functions
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/halt
  
  Index: halt
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/halt - Halt Script
  
  # Written by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	stop)
  		halt -d -f -i -p
  		;;
  	*)
  		echo "Usage: {stop}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/halt
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/loadkeys
  
  Index: loadkeys
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/loadkeys - Loadkeys Script
  
  # Based on loadkeys script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		echo -n "Loading keymap..."
  		loadkeys -d
  		evaluate_retval
  		;;
  	*)
  		echo "Usage: $0 {start}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/loadkeys
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/localnet
  
  Index: localnet
  ===================================================================
  #!/bin/bash
  # Begin $rc_base/init.d/localnet - Loopback device
  
  # Based on localnet sysklogd script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  . /etc/sysconfig/network
  
  case "$1" in
  	start)
  		echo "Bringing up the loopback interface..."
  		loadproc ifconfig lo 127.0.0.1
  
  		echo "Setting hostname to $HOSTNAME..."
  		loadproc hostname $HOSTNAME
  		;;
  
  	stop)
  		echo "Bringing down the loopback interface..."
  		loadproc ifconfig lo down
  		;;
  
  	restart)
  		$0 stop
  		sleep 1
  		$0 start
  		;;
  
  	status)
  		echo "Hostname is: $(hostname)"
  		ifconfig lo
  		;;
  
  	*)
  		echo "Usage: $0 {start|stop|restart|status}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/localnet
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/mountfs
  
  Index: mountfs
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/mountfs - File System Mount Script
  
  # Based on mountfs script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		echo "Remounting root file system in read-write mode..."
  		mount -n -o remount,rw /
  		evaluate_retval
  
  		echo "Recording existing mounts in /etc/mtab..."
  		> /etc/mtab
  		mount -f / && mount -f /proc
  		# add /dev above if you use devfs
  		evaluate_retval
  
  		# The following mount command will mount all file systems.  If
  		# you have any other filesystems that should not be or cannot be
  		# mounted at this time, add them to the NO_FS variable below.
  		# All file systems that are added to the variable in the form of
  		# no<filesystem> will be skipped.  Any network filesystems will
  		# not be mounted at this time
  
  		NO_FS="noproc"
  		echo "Mounting remaining file systems..."
  		mount -a -t $NO_FS -O no_netdev
  		evaluate_retval
  		;;
  
  	stop)
  		echo "Unmounting all other currently mounted file systems..."
  		umount -a -d -r
  		evaluate_retval
  		;;
  
  	*)
  		echo "Usage: $0 {start|stop}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/mountfs
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/mountproc
  
  Index: mountproc
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/mountproc
  
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		if [ ! -e /proc/mounts ]; then
  			echo "Mounting proc file system..."
  			mount -n /proc
  			evaluate_retval
  		fi
  		;;
  	*)
  		echo "Usage $0 {start}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/mountproc
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/network
  
  Index: network
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/network - Network Control Script
  
  # Based on ethnet script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  . /etc/sysconfig/network
  
  case "$1" in
  	start)
  		# Start all network interfaces which have ONBOOT in them.
  		for file in $(grep -sil "ONBOOT=yes" $network_devices/ifconfig.*)
  		do
  			interface=${file##*/ifconfig.}
  			case "$interface" in
  				*~) ;;
  				*)
  					$network_devices/ifup $interface
  					;;
  			esac
  		done
  
  		# Setup the Gateway
  		if [ "$GATEWAY" != "" ]
  		then
  			echo "Setting up default gateway..."
  			route add default gateway $GATEWAY metric 1 \
  				dev $GATEWAY_IF
  			evaluate_retval
  		fi
  		;;
  
  	stop)
  		if [ "$GATEWAY" != "" ]
  		then
  			echo "Removing default gateway..."
  			route del -net default
  			evaluate_retval
  		fi
  
  		# Stop all network interfaces
  		for file in $(grep -sil "ONBOOT=yes" $network_devices/ifconfig.*)
  		do
  			interface=${file##*/ifconfig.}
  			case "$interface" in
  				*~) ;;
  				*)
  					$network_devices/ifdown $interface
  					;;
  			esac
  		done
  		;;
  
  	restart)
  		$0 stop
  		sleep 1
  		$0 start
  		;;
  
  	*)
  		echo "Usage: $0 {start|stop|restart}"
  		exit 1
  		;;
  esac
  
  # End /etc/rc.d/init.d/network
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/rc
  
  Index: rc
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/rc - Main Run Level Control Script
  
  # Based on rc script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  # This sets a few default terminal options.
  stty sane
  
  # These 3 signals will not cause our script to exit
  trap "" INT QUIT TSTP
  
  [ "$1" != "" ] && runlevel=$1
  
  if [ "$runlevel" = "" ]
  then
          echo "Usage: $0 <runlevel>" >&2
          exit 1
  fi
  
  previous=$PREVLEVEL
  [ "$previous" = "" ] && previous=N
  
  if [ ! -d $rc_base/rc$runlevel.d ]
  then
          echo "$rc_base/rc$runlevel.d does not exist"
          exit 1
  fi
  
  # Attempt to stop all service started by previous runlevel,
  # and killed in this runlevel
  if [ "$previous" != "N" ]
  then
          for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null)
          do
  
                  check_script_status
  
                  suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
                  prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
                  sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix
  
                  if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ]
                  then
                          if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
                          then
                                  echo -n -e $WARNING
                                  echo "$i can't be executed because it was"
                                  echo "not started in the previous runlevel ($previous)"
                                  echo -n -e $NORMAL
                                  continue
                          fi
                  fi
                  $i stop
                  error_value=$?
  
                  if [ "$error_value" != "0" ]
                  then
                          print_error_msg
                  fi
          done
  fi
  
  #Start all functions in this runlevel
  for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null)
  do
          if [ "$previous" != "N" ]
          then
                  suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
                  stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
                  prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
  
                  [ -f $prev_start ] && [ ! -f $stop ] && continue
          fi
  
          check_script_status
  
          $i start
          error_value=$?
  
          if [ "$error_value" != "0" ]
          then
                  print_error_msg
          fi
  done
  
  # End $rc_base/init.d/rc
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/reboot
  
  Index: reboot
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/reboot - Reboot Script
  
  # Written by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	stop)
  		reboot -d -f -i
  		;;
  
  	*)
  		echo "Usage: $0 {stop}"
  		exit 1
  		;;
  
  esac
  
  # End $rc_base/init.d/reboot
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/sendsignals
  
  Index: sendsignals
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/sendsignals - Sendsignals Script
  
  # Based on sendsignals script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	stop)
  		echo "Sending all processes the TERM signal..."
  		killall5 -15
  		error_value=$?
  
  		sleep $KILLDELAY
  
  		if [ "$error_value" = 0 ]
  		then
  			print_status success
  		else
  			print_status failure
  		fi
  
  		echo "Sending all processes the KILL signal..."
  		killall5 -9
  		error_value=$?
  
  		sleep $KILLDELAY
  
  		if [ "$error_value" = 0 ]
  		then
  			print_status success
  		else
  			print_status failure
  		fi
  		;;
  
  	*)
  		echo "Usage: $0 {stop}"
  		exit 1
  		;;
  
  esac
  
  # End $rc_base/init.d/sendsignals
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/setclock
  
  Index: setclock
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/setclock - Setting Linux Clock
  
  # Based on setclock script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  . /etc/sysconfig/clock
  
  CLOCKPARAMS=
  
  case "$UTC" in
  	yes|true|1)
  		CLOCKPARAMS="$CLOCKPARAMS --utc"
  		;;
  
  	no|false|0)
  		CLOCKPARAMS="$CLOCKPARAMS --localtime"
  		;;
  
  esac
  
  case $1 in
  	start)
  		echo "Setting clock..."
  		hwclock --hctosys $CLOCKPARAMS
  		evaluate_retval
  		;;
  
  	*)
  		echo "Usage: $0 {start}"
  		;;
  
  esac
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/swap
  
  Index: swap
  ===================================================================
  #!/bin/bash
  # Begin $rc_base/init.d/swap - Swap Control Script
  
  # Written by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		echo "Activating all swap files/partitions..."
  		swapon -a
  		evaluate_retval
  		;;
  
  	stop)
  		echo "Deactivating all swap files/partitions..."
  		swapoff -a
  		evaluate_retval
  		;;
  
  	restart)
  		$0 stop
  		sleep 1
  		$0 start
  		;;
  
  	status)
  		echo "Retrieving swap status..."
  		echo
  		swapon -s
  		;;
  
  	*)
  		echo "Usage: $0 {start|stop|restart|status}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/swap
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/sysklogd
  
  Index: sysklogd
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/sysklogd - Syslogd and Klogd loaders
  
  # Based on sysklogd script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		echo "Starting system log daemon..."
  		loadproc syslogd -m 0
  
  		echo "Starting kernel log daemon..."
  		loadproc klogd
  		;;
  
  	stop)
  		echo "Stopping kernel log daemon..."
  		killproc klogd
  
  		echo "Stopping system log daemon..."
  		killproc syslogd
  		;;
  
  	reload)
  		echo "Reloading system log daemon config file..."
  		reloadproc syslogd 1
  		;;
  
  	restart)
  		$0 stop
  		sleep 1
  		$0 start
  		;;
  
  	status)
  		statusproc syslogd
  		statusproc klogd
  		;;
  
  	*)
  		echo "Usage: $0 {start|stop|reload|restart|status}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/sysklogd
  
  
  
  1.1                  LFS/bootscripts/lfs/init.d/template
  
  Index: template
  ===================================================================
  #!/bin/sh
  # Begin $rc_base/init.d/
  
  # Based on sysklogd script from LFS-3.1 and earlier.
  # Rewritten by Gerard Beekmans  - gerard at linuxfromscratch.org
  
  . /etc/sysconfig/rc
  . $rc_functions
  
  case "$1" in
  	start)
  		echo "Starting..."
  		loadproc
  		;;
  
  	stop)
  		echo "Stopping..."
  		killproc
  		;;
  
  	reload)
  		echo "Reloading..."
  		reloadproc
  		;;
  
  	restart)
  		$0 stop
  		sleep 1
  		$0 start
  		;;
  
  	status)
  		statusproc
  		;;
  
  	*)
  		echo "Usage: $0 {start|stop|reload|restart|status}"
  		exit 1
  		;;
  esac
  
  # End $rc_base/init.d/
  
  
  
  1.1                  LFS/bootscripts/lfs/sysconfig/rc
  
  Index: rc
  ===================================================================
  rc_base=/etc/rc.d
  rc_functions=$rc_base/init.d/functions
  network_devices=/etc/sysconfig/network-devices
  
  
  
  1.1                  LFS/bootscripts/lfs/sysconfig/network-devices/ifdown
  
  Index: ifdown
  ===================================================================
  #!/bin/sh
  # Begin $network_devices/ifdown
  
  # Written by Nathan Coulson <nathan at linuxfromscratch.org>
  . /etc/sysconfig/rc 
  . $rc_functions 
  . $network_devices/ifconfig.$1 
  
  if [ -f $network_devices/ifdown-$1 ]
  then
  	$network_devices/ifdown-$1
  else
  	if [ -z $SERVICE ]
  	then
  		echo -n "SERVICE variable missing from ifconfig.$1, "
  		echo "using static"
  		SERVICE=static
  	fi
  	if [ ! -f $network_devices/services/$SERVICE ]
  	then
  		echo -n "Unknown Service: $SERVICE, cannot continue"
  		exit 1
  	fi
  	$network_devices/services/${SERVICE} $1 down
  fi
  
  # End $network_devices/ifdown
  
  
  
  1.1                  LFS/bootscripts/lfs/sysconfig/network-devices/ifup
  
  Index: ifup
  ===================================================================
  #!/bin/sh
  # Begin $network_devices/ifup
  
  # Written by Nathan Coulson <nathan at linuxfromscratch.org>
  
  . /etc/sysconfig/rc 
  . $rc_functions 
  . $network_devices/ifconfig.$1 
  
  if [ -f $network_devices/ifup-$1 ]
  then
  	$network_devices/ifup-$1
  else
  	if [ -z $SERVICE ]
  	then
  		echo -n "SERVICE variable missing from ifconfig.$1, "
  		echo "using static"
  		SERVICE=static
  	fi
  	if [ ! -f $network_devices/services/$SERVICE ]
  	then
  		echo -n "Unknown Service: $SERVICE, cannot continue"
  		exit 1
  	fi
  	$network_devices/services/${SERVICE} $1 up
  fi
  
  # End $network_devices/ifup
  
  
  
  1.1                  LFS/bootscripts/lfs/sysconfig/network-devices/services/static
  
  Index: static
  ===================================================================
  #!/bin/sh
  # Begin $network_devices/services/static
  
  # Based upon lfs-bootscripts-1.12 $network_devices/if{down,up}
  # Rewritten by Nathan Coulson <nathan at linuxfromscratch.org>
  
  . /etc/sysconfig/rc 
  . $rc_functions 
  . $network_devices/ifconfig.$1
  
  case "$2" in
  	up)
  		if [ -z $IP ]
  		then
  			echo "IP variable missing for ifconfig.$1, cannot continue"
  			exit 1
  		fi
  
  		if [ -z $NETMASK ]
  		then
  			echo -n "NETMASK variable missing for ifconfig.$1, "
  			echo "using 255.255.255.0"
  			NETMASK=255.255.255.0
  		fi
  
  		if [ -z $BROADCAST ]
  		then
  			echo -n "BROADCAST variable missing for ifconfig.$1, "
  			echo "using default address"
  		fi
  
  		echo "Bringing up the $1 interface..."
  		ifconfig $1 $IP netmask $NETMASK broadcast $BROADCAST
  		evaluate_retval
  	;;
  
  	down)
  		echo "Bringing down the $1 interface..."
  		ifconfig $1 down
  		evaluate_retval
  	;;
  
  	*)
  		echo "Usage: $0 [interface] {up|down}"
  		exit 1
  	;;
  esac
  
  # End $network_devices/services/static
  
  
  



More information about the lfs-book mailing list