Mostly for Bruce, but sent to list for everyone's review:

Attached are some fixes for the bootscripts. These are mostly cosmetic,
but there are some minor functional changes due in part to reverting to
multi-part writes to the screen, some clean-up/simplification of syntax,
for instance, == instead of = in comparison tests, use "-a" and "-o"
instead of "] && [" or "] || [" resp., removed the second interactive
prompt, made available boot message prefixes and color ${INFO} for
mountvirtfs, made certain that control charcters are not written to the
boot log in case color codes are used in screen messages, and reduced
duplication of items in rc.site and init-functions (rc.site is required
for init-functions/rc). Please review, and discuss if necessary, before
commit.

Thanks.

-- DJ Lucas

-- 
This message has been scanned for viruses and
dangerous content, and is believed to be clean.

diff -Naurp lfs-bootscripts-20111017-orig/lfs/init.d/checkfs lfs-bootscripts-20111017/lfs/init.d/checkfs
--- lfs-bootscripts-20111017-orig/lfs/init.d/checkfs	2011-09-19 03:31:46.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/init.d/checkfs	2011-11-05 19:52:36.000000000 +0000
@@ -79,7 +79,7 @@ case "${1}" in
 
       log_info_msg "Checking file systems..."
       # Note: -a option used to be -p; but this fails e.g. on fsck.minix
-      fsck ${options} -a -A -C -T
+      fsck ${options} -a -A -C -T >/dev/null
       error_value=${?}
 
       if [ "${error_value}" = 0 ]; then
diff -Naurp lfs-bootscripts-20111017-orig/lfs/init.d/cleanfs lfs-bootscripts-20111017/lfs/init.d/cleanfs
--- lfs-bootscripts-20111017-orig/lfs/init.d/cleanfs	2011-09-19 03:31:46.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/init.d/cleanfs	2011-11-05 19:52:41.000000000 +0000
@@ -90,7 +90,7 @@ case "${1}" in
       log_info_msg "Cleaning file systems:" 
 
       if [ "${SKIPTMPCLEAN}" = "" ]; then
-         log_info_msg2 "\n /tmp" 
+         log_info_msg2 " /tmp" 
          cd /tmp &&
          find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1
       fi
diff -Naurp lfs-bootscripts-20111017-orig/lfs/init.d/consolelog lfs-bootscripts-20111017/lfs/init.d/consolelog
--- lfs-bootscripts-20111017-orig/lfs/init.d/consolelog	2011-09-19 03:31:46.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/init.d/consolelog	1970-01-01 00:00:00.000000000 +0000
@@ -1,78 +0,0 @@
-#!/bin/sh
-########################################################################
-# Begin consolelog
-#
-# Description : Set the kernel log level for the console
-#
-# Authors     : Dan Nicholson - dnichol...@linuxfromscratch.org
-#               Gerard Beekmans  - ger...@linuxfromscratch.org
-#               DJ Lucas - d...@linuxfromscratch.org
-# Update      : Bruce Dubbs - bdu...@linuxfromscratch.org
-#
-# Version     : LFS 7.0
-#
-# Notes       : /proc must be mounted before this can run
-#
-########################################################################
-
-### BEGIN INIT INFO
-# Provides:            consolelog
-# Required-Start:
-# Should-Start:        
-# Required-Stop:
-# Should-Stop:
-# Default-Start:       S
-# Default-Stop:
-# Short-Description:   Sets the console log level.
-# Description:         Sets the console log level.
-# X-LFS-Provided-By:   LFS
-### END INIT INFO
-
-. /lib/lsb/init-functions
-
-# set the default loglevel if needed
-LOGLEVEL=${LOGLEVEL:-7}
-
-[ -r /etc/sysconfig/console ] && . /etc/sysconfig/console
-
-case "${1}" in
-   start)
-      case "$LOGLEVEL" in
-      [1-8])
-         log_info_msg "Setting the console log level to ${LOGLEVEL}..."
-         dmesg -n $LOGLEVEL
-         evaluate_retval
-         exit 0
-         ;;
-
-      *)
-         log_failure_msg "Console log level '${LOGLEVEL}' is invalid"
-         exit 1
-         ;;
-      
-      esac
-      ;;
-
-   status)
-      # Read the current value if possible
-      if [ -r /proc/sys/kernel/printk ]; then
-         read level line < /proc/sys/kernel/printk
-      else
-         log_failure_msg "Can't read the current console log level"
-         exit 1
-      fi
-
-      # Print the value
-      if [ -n "$level" ]; then
-         log_info_msg "The current console log level is ${level}\n"
-         exit 0
-      fi
-      ;;
-
-   *)
-      echo "Usage: ${0} {start|status}"
-      exit 1
-      ;;
-esac
-
-# End consolelog
diff -Naurp lfs-bootscripts-20111017-orig/lfs/init.d/mountvirtfs lfs-bootscripts-20111017/lfs/init.d/mountvirtfs
--- lfs-bootscripts-20111017-orig/lfs/init.d/mountvirtfs	2011-09-19 03:31:46.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/init.d/mountvirtfs	2011-11-05 19:53:19.000000000 +0000
@@ -36,15 +36,15 @@ case "${1}" in
       mount -n /run || failed=1
       mkdir -p /run/{var,lock,shm}
 
-      log_info_msg "Mounting virtual file systems: /run" 
+      log_info_msg "Mounting virtual file systems:     ${INFO}/run" 
 
       if ! mountpoint /proc >/dev/null; then
-         log_info_msg2 " /proc"
+         log_info_msg2 " ${INFO}/proc"
          mount -n /proc || failed=1
       fi
 
       if ! mountpoint /sys >/dev/null; then
-         log_info_msg2 " /sys" 
+         log_info_msg2 " ${INFO}/sys" 
          mount -n /sys || failed=1
       fi
 
diff -Naurp lfs-bootscripts-20111017-orig/lfs/init.d/rc lfs-bootscripts-20111017/lfs/init.d/rc
--- lfs-bootscripts-20111017-orig/lfs/init.d/rc	2011-09-19 03:50:56.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/init.d/rc	2011-11-05 20:08:32.000000000 +0000
@@ -84,47 +84,52 @@ function run()
 # Read any local settings/overrides
 [ -r /etc/sysconfig/rc.site ] && source /etc/sysconfig/rc.site
 
-DISTRO=${DISTRO:-"Linux From Scratch"}
-DISTRO_CONTACT=${DISTRO_CONTACT:-"lfs-dev@linuxfromscratch.org (Registration required)"}
-DISTRO_MINI=${DISTRO_MINI:-"LFS"}
-
 # These 3 signals will not cause our script to exit
 trap "" INT QUIT TSTP
 
 [ "${1}" != "" ] && runlevel=${1}
 
-if [ "${runlevel}" = "" ]; then
+if [ "${runlevel}" == "" ]; then
    echo "Usage: ${0} <runlevel>" >&2
    exit 1
 fi
 
 previous=${PREVLEVEL}
-[ "${previous}" = "" ] && previous=N
+[ "${previous}" == "" ] && previous=N
 
 if [ ! -d /etc/rc.d/rc${runlevel}.d ]; then
    log_info_msg "/etc/rc.d/rc${runlevel}.d does not exist.\n" 
    exit 1
 fi
 
-if [ "$runlevel" == "6" ] || [ "$runlevel" == "0" ]; then IPROMPT="no"; fi
+if [ "$runlevel" == "6" -o "$runlevel" == "0" ]; then IPROMPT="no"; fi
+
+# Set initial console logging level
+[ "${LOGLEVEL}" == "" ] && LOGLEVEL=7
+dmesg -n "${LOGLEVEL}"
 
-if [ "${IPROMPT}" == "yes" ]; then
+if [ "${IPROMPT}" == "yes" -a "${runlevel}" == "S" ]; then
    # dcol and icol are spaces before the message to center the
    # message on screen.
 
    wcol=$(( ( ${COLUMNS} - ${wlen} ) / 2 ))
    icol=$(( ( ${COLUMNS} - ${ilen} ) / 2 ))
 
+   echo -e "\n\n"
    echo -e "\\033[${wcol}G${welcome_message}"
    echo -e "\\033[${icol}G${i_message}${NORMAL}"
    echo ""
    read -t "${itime}" -n 1 interactive 2>&1 > /dev/null
 
-   # Make lower case
-   [ "${interactive}" == "I" ] && interactive="i"
-   [ "${interactive}" != "i" ] && interactive=""
 fi
 
+# Make lower case
+[ "${interactive}" == "I" ] && interactive="i"
+[ "${interactive}" != "i" ] && interactive=""
+
+# Read the state file if it exists from runlevel S
+[ -r /var/run/interactive ] && source /var/run/interactive
+
 # Attempt to stop all services started by the previous runlevel,
 # and killed in this runlevel
 if [ "${previous}" != "N" ]; then
@@ -136,8 +141,8 @@ if [ "${previous}" != "N" ]; then
       prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
       sysinit_start=/etc/rc.d/rcS.d/S[0-9][0-9]$suffix
 
-      if [ "${runlevel}" != "0" ]  && [ "${runlevel}" != "6" ]; then
-         if [ ! -f ${prev_start} ] && [ ! -f ${sysinit_start} ]; then
+      if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then
+         if [ ! -f ${prev_start} -a ! -f ${sysinit_start} ]; then
             MSG="WARNING:\n\n${i} can't be "
             MSG="${MSG}executed because it was not "
             MSG="${MSG}not started in the previous "
@@ -156,7 +161,7 @@ fi
 
 if [ "${previous}" == "N" ]; then export IN_BOOT=1; fi
 
-if [ "$runlevel" == "6" ] && [ -n "${FASTBOOT}" ]; then
+if [ "$runlevel" == "6" -a -n "${FASTBOOT}" ]; then
    touch /fastboot
 fi
 
@@ -169,7 +174,7 @@ do
       stop=/etc/rc.d/rc$runlevel.d/K[0-9][0-9]$suffix
       prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
 
-      [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue
+      [ -f ${prev_start} -a ! -f ${stop} ] && continue
    fi
 
    check_script_status
@@ -188,10 +193,22 @@ do
    if [ "${error_value}" != "0" ]; then print_error_msg; fi
 done
 
+# Store interactive variable on switch from runlevel S and remove if not
+if [ "${runlevel}" == "S" -a "${interactive}" == "i" ]; then
+    echo "interactive=\"i\"" > /var/run/interactive
+else
+    rm -f /var/run/interactive 2> /dev/null
+fi
+
 # Copy the boot log on initial boot only
 if [ "${previous}" == "N" ]; then
    cat /run/var/bootlog >> /var/log/boot.log
-   echo "--------" >> /var/log/boot.log  # Mark the end of boot
+   if [ "${runlevel}" != "S" ]; then
+      # Mark the end of boot
+      echo "--------" >> /var/log/boot.log
+      # Remove the temporary file
+      rm -f /run/var/bootlog 2> /dev/null
+   fi
 fi
 
 # End rc
diff -Naurp lfs-bootscripts-20111017-orig/lfs/lib/services/init-functions lfs-bootscripts-20111017/lfs/lib/services/init-functions
--- lfs-bootscripts-20111017-orig/lfs/lib/services/init-functions	2011-10-22 03:30:16.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/lib/services/init-functions	2011-11-05 19:59:50.000000000 +0000
@@ -43,6 +43,7 @@ WCOL=$((${COL} - 2))
 SET_COL="\\033[${COL}G"      # at the $COL char
 SET_WCOL="\\033[${WCOL}G"    # at the $WCOL char
 CURS_UP="\\033[1A\\033[0G"   # Up one line, at the 0'th char
+CURS_ZERO="\\033[0G"
 
 ## Set color commands, used via echo
 # Please consult `man console_codes for more information
@@ -53,13 +54,6 @@ CURS_UP="\\033[1A\\033[0G"   # Up one li
 # the top 256 glyphs of the 9bit font.  This does
 # not affect framebuffer consoles
 
-NORMAL="\\033[0;39m"         # Standard console grey
-SUCCESS="\\033[1;32m"        # Success is green
-WARNING="\\033[1;33m"        # Warnings are yellow
-FAILURE="\\033[1;31m"        # Failures are red
-INFO="\\033[1;36m"           # Information is light cyan
-BRACKET="\\033[1;34m"        # Brackets are blue
-
 BOOTLOG=/run/var/bootlog
 KILLDELAY=3
 
@@ -553,18 +547,21 @@ timespec()
 ################################################################################
 log_success_msg()
 {
-    echo -n -e "${@}"
-    echo -e "${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
 
+    echo -n -e "${BMPREFIX}${@}"
+    echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
+
+    # Strip non-printable characters from log file
+    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
     timespec
-    echo -e "${STAMP} ${@} OK" >> ${BOOTLOG}
+    echo -e "${STAMP} ${logmessage} OK" >> ${BOOTLOG}
     return 0
 }
 
 log_success_msg2()
 {
-    echo -n -e "${@}"
-    echo -e "${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
+    echo -n -e "${BMPREFIX}${@}"
+    echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
 
     echo " OK" >> ${BOOTLOG}
     return 0
@@ -583,18 +580,20 @@ log_success_msg2()
 ################################################################################
 log_failure_msg()
 {
-    echo -n -e "${@}"
-    echo -e "${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
+    echo -n -e "${BMPREFIX}${@}"
+    echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
 
+    # Strip non-printable characters from log file
     timespec
-    echo -e "${STAMP} ${@} FAIL" >> ${BOOTLOG}
+    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
+    echo -e "${STAMP} ${logmessage} FAIL" >> ${BOOTLOG}
     return 0
 }
 
 log_failure_msg2()
 {
-    echo -n -e "${@}"
-    echo -e "${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
+    echo -n -e "${BMPREFIX}${@}"
+    echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
 
     echo "FAIL" >> ${BOOTLOG}
     return 0
@@ -611,11 +610,14 @@ log_failure_msg2()
 ################################################################################
 log_warning_msg()
 {
-    echo -n -e "${@}"
-    echo -e "${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}"
+    #echo -n -e "${WARNING} *** ${NORMAL}"
+    echo -n -e "${BMPREFIX}${@}"
+    echo -e "${CURS_ZERO}${WARNING_PREFIX}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}"
 
+    # Strip non-printable characters from log file
+    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
     timespec
-    echo -e "${STAMP} ${@} WARN" >> ${BOOTLOG}
+    echo -e "${STAMP} ${logmessage} WARN" >> ${BOOTLOG}
     return 0
 }
 
@@ -630,18 +632,22 @@ log_warning_msg()
 ################################################################################
 log_info_msg()
 {
-    echo -n -e "${@}"
+    echo -n -e "${BMPREFIX}${@}"
 
+    # Strip non-printable characters from log file
+    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
     timespec
-    echo -n -e "${STAMP} ${@}" >> ${BOOTLOG}
+    echo -n -e "${STAMP} ${logmessage}" >> ${BOOTLOG}
     return 0
 }
 
 log_info_msg2()
 {
-    echo -n -e "${@}"
+    echo -n -e "${BMPREFIX}${@}"
 
-    echo -n -e "${@}" >> ${BOOTLOG}
+    # Strip non-printable characters from log file
+    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
+    echo -n -e "${logmessage}" >> ${BOOTLOG}
     return 0
 }
 
diff -Naurp lfs-bootscripts-20111017-orig/lfs/sbin/ifup lfs-bootscripts-20111017/lfs/sbin/ifup
--- lfs-bootscripts-20111017-orig/lfs/sbin/ifup	2011-09-19 03:31:46.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/sbin/ifup	2011-11-05 19:55:29.000000000 +0000
@@ -55,7 +55,7 @@ file=/etc/sysconfig/ifconfig.${1}
 
 . /lib/lsb/init-functions
 
-log_info_msg "Bringing up the ${1} interface... "
+log_info_msg "Bringing up the ${1} interface:"
 
 if [ ! -r "${file}" ]; then
    log_warning_msg "\n${file} is missing or cannot be accessed." 
diff -Naurp lfs-bootscripts-20111017-orig/lfs/sysconfig/rc.site lfs-bootscripts-20111017/lfs/sysconfig/rc.site
--- lfs-bootscripts-20111017-orig/lfs/sysconfig/rc.site	2011-09-19 03:31:46.000000000 +0000
+++ lfs-bootscripts-20111017/lfs/sysconfig/rc.site	2011-11-05 20:01:13.000000000 +0000
@@ -6,18 +6,25 @@ DISTRO="Linux From Scratch" # The distro
 DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address
 DISTRO_MINI="LFS" # Short name used in filenames for distro config
 
-# Define custom colors used in messages printed to the screen
-# These values, if specified here, override the defaults
-#BRACKET="\\033[1;34m" # Blue
-#FAILURE="\\033[1;31m" # Red
-#INFO="\\033[1;36m"    # Cyan
-#NORMAL="\\033[0;39m"  # Grey
-#SUCCESS="\\033[1;32m" # Green
-#WARNING="\\033[1;33m" # Yellow
+
+## Set color commands, used via echo
+# Please consult `man console_codes for more information
+# under the "ECMA-48 Set Graphics Rendition" section
+#
+# Warning: when switching from a 8bit to a 9bit font,
+# the linux console will reinterpret the bold (1;) to
+# the top 256 glyphs of the 9bit font.  This does
+# not affect framebuffer consoles
+BRACKET="\\033[1;34m" # Blue
+FAILURE="\\033[1;31m" # Red
+INFO="\\033[1;36m"    # Cyan
+NORMAL="\\033[0;39m"  # Grey
+SUCCESS="\\033[1;32m" # Green
+WARNING="\\033[1;33m" # Yellow
 
 # Interactive startup
 #IPROMPT="yes" # Whether to display the interactive boot promp
-itime="10"    # The ammount of time (in seconds) to display the prompt
+itime="2"    # The ammount of time (in seconds) to display the prompt
 
 # The total length of the distro welcome string, without escape codes
 wlen=$(echo "Welcome to ${DISTRO}" | wc -c )
@@ -33,6 +40,12 @@ i_message="Press '${FAILURE}I${NORMAL}'
 # Skip reading from the console
 #HEADLESS=yes
 
+# Use a colored prefix
+#BMPREFIX="     "
+#SUCCESS_PREFIX="${SUCCESS}  *  ${NORMAL}"
+#FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
+#WARNING_PREFIX="${WARNING} *** ${NORMAL}"
+
 # Skip cleaning /tmp
 #SKIPTMPCLEAN=yes
 
diff -Naurp lfs-bootscripts-20111017-orig/Makefile lfs-bootscripts-20111017/Makefile
--- lfs-bootscripts-20111017-orig/Makefile	2011-10-08 16:25:33.000000000 +0000
+++ lfs-bootscripts-20111017/Makefile	2011-11-05 19:54:25.000000000 +0000
@@ -32,7 +32,6 @@ files: create-dirs
 	install -m ${MODE} lfs/init.d/cleanfs       ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/halt          ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/console       ${EXTDIR}/rc.d/init.d/
-	install -m ${MODE} lfs/init.d/consolelog    ${EXTDIR}/rc.d/init.d/
 	install -m ${CONFMODE} lfs/init.d/functions ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/localnet      ${EXTDIR}/rc.d/init.d/
 	install -m ${MODE} lfs/init.d/modules       ${EXTDIR}/rc.d/init.d/
@@ -76,7 +75,6 @@ links: rcS rc0 rc1 rc2 rc3 rc4 rc5 rc6
 
 rcS: files
 	ln -sf ../init.d/mountvirtfs ${EXTDIR}/rc.d/rcS.d/S00mountvirtfs
-	ln -sf ../init.d/consolelog  ${EXTDIR}/rc.d/rcS.d/S02consolelog
 	ln -sf ../init.d/modules     ${EXTDIR}/rc.d/rcS.d/S05modules
 	ln -sf ../init.d/localnet    ${EXTDIR}/rc.d/rcS.d/S08localnet
 	ln -sf ../init.d/udev        ${EXTDIR}/rc.d/rcS.d/S10udev
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to