cvs commit: LFS/bootscripts/lfs/init.d rc

nathan at linuxfromscratch.org nathan at linuxfromscratch.org
Thu Jun 3 20:29:05 PDT 2004


nathan      04/06/03 21:29:05

  Modified:    bootscripts CHANGELOG
               bootscripts/lfs/init.d rc
  Log:
  Stage 1, of adding basic bootscript logging.  Only works if /var/log/boot.log
  exists, and is writeable
  
  Revision  Changes    Path
  1.97      +2 -0      LFS/bootscripts/CHANGELOG
  
  Index: CHANGELOG
  ===================================================================
  RCS file: /home/cvsroot/LFS/bootscripts/CHANGELOG,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- CHANGELOG	4 Jun 2004 02:55:44 -0000	1.96
  +++ CHANGELOG	4 Jun 2004 03:29:05 -0000	1.97
  @@ -2,6 +2,8 @@
   
   	* Added '> /proc/sys/kernel/hotplug' to sendsignals, to disable hotplug
   	  events, which may start up new daemons
  +	* Added elementry bootup logging support.  If it can write to
  +	  /var/log/boot.log, it will
   
   n/a - June 2, 2004
   
  
  
  
  1.3       +23 -11    LFS/bootscripts/lfs/init.d/rc
  
  Index: rc
  ===================================================================
  RCS file: /home/cvsroot/LFS/bootscripts/lfs/init.d/rc,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- rc	15 May 2004 19:38:29 -0000	1.2
  +++ rc	4 Jun 2004 03:29:05 -0000	1.3
  @@ -7,6 +7,16 @@
   . /etc/sysconfig/rc
   . $rc_functions
   
  +# Function used for logging
  +logboot()
  +{
  +	if [ -w "/var/log/boot.log" ]; then
  +		( "$@" | tee /var/log/boot.log && exit $PIPESTATUS )
  +	else
  +		"$@"
  +	fi
  +}
  +
   # This sets a few default terminal options.
   stty sane
   
  @@ -17,7 +27,7 @@
   
   if [ "$runlevel" = "" ]
   then
  -        echo "Usage: $0 <runlevel>" >&2
  +        logboot echo "Usage: $0 <runlevel>" >&2
           exit 1
   fi
   
  @@ -26,7 +36,7 @@
   
   if [ ! -d $rc_base/rc$runlevel.d ]
   then
  -        echo "$rc_base/rc$runlevel.d does not exist"
  +        logboot echo "$rc_base/rc$runlevel.d does not exist"
           exit 1
   fi
   
  @@ -47,19 +57,21 @@
                   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
  +                                logboot echo -n -e $WARNING
  +                                logboot echo "$i can't be executed because it was"
  +                                logboot echo "not started in the previous runlevel ($previous)"
  +                                logboot echo -n -e $NORMAL
                                   continue
                           fi
                   fi
  -                $i stop
  +                logboot echo -n "$i stop:"
  +                logboot $i stop
  +                logboot echo
                   error_value=$?
   
                   if [ "$error_value" != "0" ]
                   then
  -                        print_error_msg
  +                        logboot print_error_msg
                   fi
           done
   fi
  @@ -79,14 +91,14 @@
           check_script_status
   
   	case $runlevel in
  -		0|6)	$i stop		;;
  -		*)	$i start	;;
  +                0|6) logboot echo -n "$i stop:"  && logboot $i stop	;;
  +		*)   logboot echo -n "$i start:" && logboot $i start	;;
   	esac
           error_value=$?
   
           if [ "$error_value" != "0" ]
           then
  -                print_error_msg
  +                logboot print_error_msg
           fi
   done
   
  
  
  



More information about the lfs-book mailing list