bootscript fixes

2011-11-05 Thread DJ Lucas
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.0 +
+++ lfs-bootscripts-20111017/lfs/init.d/checkfs	2011-11-05 19:52:36.0 +
@@ -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.0 +
+++ lfs-bootscripts-20111017/lfs/init.d/cleanfs	2011-11-05 19:52:41.0 +
@@ -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.0 +
+++ lfs-bootscripts-20111017/lfs/init.d/consolelog	1970-01-01 00:00:00.0 +
@@ -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.0 +
+++ lfs-bootscripts-20111017/lfs/init.d/mountvirtfs	2011-11-05 19:53:19.0 +
@@ -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 

Re: bootscript fixes

2011-11-05 Thread Bruce Dubbs
DJ Lucas wrote:
 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.

I appreciate the fixes.  I'll review the diff in more detail, but note 
that I used = instead of == for string comparisons explicitly because 
the bash man page says:

string1 == string2
   True if the strings are equal.  = may be used in place of == for
   strict POSIX compliance.

I was trying to make the scripts Bourne/Posix compatible.

   -- Bruce

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


Re: bootscript fixes

2011-11-05 Thread DJ Lucas
On 11/05/2011 04:15 PM, Bruce Dubbs wrote:
 DJ Lucas wrote:
 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.
 I appreciate the fixes.  I'll review the diff in more detail, but note
 that I used = instead of == for string comparisons explicitly because
 the bash man page says:

 string1 == string2
 True if the strings are equal.  = may be used in place of == for
 strict POSIX compliance.

 I was trying to make the scripts Bourne/Posix compatible.

 -- Bruce

Although I hadn't actually noticed that init-functions used /bin/sh for 
the interpreter prior to your mention POSIX above, I fortunately only 
made the comparison and logical and/or changes in the rc script which 
uses /bin/bash for the schebang (it looks as if this is the only script 
to do this as well). The goal was consistency. You are correct, a single 
= character must be used for comparison tests in init-functions for 
POSIX compliance. I'll drop in a couple of random scripts using dash or 
ash as the interpreter tonight or tomorrow to make sure, but I believe 
all is well. It could be argued, however, that we should drop to /bin/sh 
for the interpreter used in the rc script and do the reverse. If agreed, 
just respond here and ignore the earlier patch (I'm pretty sure we 
should probably use sh syntax and avoid mixing the two for consistency). 
I'll reverse those specific changes and get a corrected one tested 
tomorrow or later tonight along with the proposed cosmetic changes. I'm 
going to build ash and symlink to /bin/sh now to get a thorough test 
done. I'll get to dash later in the week.

-- DJ Lucas


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

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


Re: bootscript fixes

2011-11-05 Thread Bruce Dubbs
DJ Lucas wrote:
 On 11/05/2011 04:15 PM, Bruce Dubbs wrote:
 DJ Lucas wrote:
 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.
 I appreciate the fixes.  I'll review the diff in more detail, but note
 that I used = instead of == for string comparisons explicitly because
 the bash man page says:

 string1 == string2
 True if the strings are equal.  = may be used in place of == for
 strict POSIX compliance.

 I was trying to make the scripts Bourne/Posix compatible.

 -- Bruce

 Although I hadn't actually noticed that init-functions used /bin/sh for 
 the interpreter prior to your mention POSIX above, I fortunately only 
 made the comparison and logical and/or changes in the rc script which 
 uses /bin/bash for the schebang (it looks as if this is the only script 
 to do this as well). The goal was consistency. You are correct, a single 
 = character must be used for comparison tests in init-functions for 
 POSIX compliance. I'll drop in a couple of random scripts using dash or 
 ash as the interpreter tonight or tomorrow to make sure, but I believe 
 all is well. It could be argued, however, that we should drop to /bin/sh 
 for the interpreter used in the rc script and do the reverse. If agreed, 
 just respond here and ignore the earlier patch (I'm pretty sure we 
 should probably use sh syntax and avoid mixing the two for consistency). 
 I'll reverse those specific changes and get a corrected one tested 
 tomorrow or later tonight along with the proposed cosmetic changes. I'm 
 going to build ash and symlink to /bin/sh now to get a thorough test 
 done. I'll get to dash later in the week.

Yes, the init.d/rc file was explicitly bash and I'd like it to stay that 
way.  The others can be (probably should be) sh compatible.  Bash is an 
integral part of LFS and specifying that doesn't hurt anything.

Reviewing though, I see I wasn't consistent.

More comments in a bit.

   -- Bruce
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


Re: bootscript fixes

2011-11-05 Thread Bruce Dubbs
Bruce Dubbs wrote:
 DJ Lucas wrote:
 Mostly for Bruce, but sent to list for everyone's review:

I had left the definitions

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

in init-functions to handle the case when a user may have deleted them 
from rc.site.

Same for the DISTRO vars in init.d/rc

-

I'm not sure we want to set LOGLEVEL every time we change run level. 
Perhaps that should be wrapped in

if [ ${runlevel} == S ]; then dmesg -n ${LOGLEVEL:-7}; fi

-

The purpose of log_info_msg2 was to be able to put something in the middle:

log_info_msg  Start of message...
...
log_info_msg2 Something else
(exit $RET)
evalutate_retval

So it would come out as:

Start of message...Something else  [  OK  ]

Adding ${BMPREFIX} to log_info_msg2 would change that behavior.  See the 
modules script.

   -- Bruce
-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page


Re: bootscript fixes

2011-11-05 Thread DJ Lucas
On 11/05/2011 06:04 PM, Bruce Dubbs wrote:
 Bruce Dubbs wrote:
 DJ Lucas wrote:
 Mostly for Bruce, but sent to list for everyone's review:
 I had left the definitions

 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

 in init-functions to handle the case when a user may have deleted them
 from rc.site.

 Same for the DISTRO vars in init.d/rc
Ahh..okay, they should be left then as ones in rc.site take precedence.
 -

 I'm not sure we want to set LOGLEVEL every time we change run level.
 Perhaps that should be wrapped in

 if [ ${runlevel} == S ]; then dmesg -n ${LOGLEVEL:-7}; fi
Yes, there is no longer any need for the consolelog script as we do not 
change logging level in any of the scripts. It is not necessary to have 
/proc or /sys mounted to set the kernel log level when using dmesg. Note 
that this could also be set any number of other ways (including via 
sysctl). If you want a really clean look, it is important to set this as 
early as possible. With LOGLEVEL set to 4 in early rc, All boot messages 
show on screen, nothing out of place, including the welcome message for 
interactive prompt.
 -

 The purpose of log_info_msg2 was to be able to put something in the middle:

 log_info_msg  Start of message...
 ...
 log_info_msg2 Something else
 (exit $RET)
 evalutate_retval

 So it would come out as:

 Start of message...Something else  [  OK  ]

 Adding ${BMPREFIX} to log_info_msg2 would change that behavior.  See the
 modules script.
Opps that wasn't supposed to be left in there, added it by mistake when 
I added the removal of non-printable characters. I still have one issue 
with logging, a couple of OK messages out of place, but I'll post a fix 
back when I find the issue (was there before I started mucking around 
with them).

Thanks for the review...changing local copy with the above now. I'll be 
able to trudge through the rest of them tonight, but I'm pretty sure all 
is well. Everything changed above was simply for aesthetic purposes -- 
colon for lists instead of trailing dots (mountvirtfs and cleanfs), or 
lines without output (ifup), boot message prefixes, double welcome 
message... I'm still gonna revisit the added ifdown functionality and 
service functions, even if only for downstream users, but they look real 
good. Sorry I'm only now getting to review them. I also have a few 
scripts laying around for BLFS that are not in the contrib/lsb directory 
that should be suitable for the current scripts, I'll get to those when 
I get to building them.

-- DJ Lucas


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

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page