aboutsummaryrefslogtreecommitdiffstats
path: root/bootscripts
diff options
context:
space:
mode:
authorBruce Dubbs <bdubbs@linuxfromscratch.org>2011-11-14 20:40:06 +0000
committerBruce Dubbs <bdubbs@linuxfromscratch.org>2011-11-14 20:40:06 +0000
commit9813d5e3286943ca93588175603e1fec966d1e49 (patch)
treef834a21e5348010db129fad5690151fd3a43999a /bootscripts
parentb15d6da86b25c5d0b5423acf0ab4d91f589b01b9 (diff)
Updates to boot scripts:
general cleanup; move consolelog function to rc; clean up boot logging functions; fix interactive prompt between run level S and target run level. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9661 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'bootscripts')
-rw-r--r--bootscripts/ChangeLog8
-rw-r--r--bootscripts/Makefile8
-rw-r--r--bootscripts/lfs/init.d/checkfs2
-rw-r--r--bootscripts/lfs/init.d/cleanfs2
-rwxr-xr-xbootscripts/lfs/init.d/consolelog78
-rw-r--r--bootscripts/lfs/init.d/mountvirtfs6
-rw-r--r--bootscripts/lfs/init.d/rc44
-rw-r--r--bootscripts/lfs/init.d/udev2
-rw-r--r--bootscripts/lfs/init.d/udev_retry2
-rw-r--r--bootscripts/lfs/lib/services/init-functions98
-rw-r--r--bootscripts/lfs/sysconfig/rc.site25
11 files changed, 136 insertions, 139 deletions
diff --git a/bootscripts/ChangeLog b/bootscripts/ChangeLog
index 1937ca4b0..de1755ec2 100644
--- a/bootscripts/ChangeLog
+++ b/bootscripts/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-14 Bruce Dubbs <bdubbs@linuxfromscratch.org>
+
+ * The following are from suggestions by DJ Lucas
+ ** General cleanup of scripts
+ ** Move consolelog function to rc
+ ** Clean up boot logging functions
+ ** Fix interactive prompt between run level S and target run level
+
2011-10-06 Bryan Kadzban <bryan@linuxfromscratch.org>
* Add configuration for udev_retry, and remove --type=failed (which does
diff --git a/bootscripts/Makefile b/bootscripts/Makefile
index 5d31191b4..48a5f27c6 100644
--- a/bootscripts/Makefile
+++ b/bootscripts/Makefile
@@ -24,15 +24,14 @@ create-dirs:
install -d -m ${DIRMODE} ${LIBDIR}
install -d -m ${DIRMODE} ${MAN8}
install -d -m ${DIRMODE} ${SBIN}
- ln -svf services ${DESTDIR}/lib/lsb
- ln -sf rc.d/init.d ${EXTDIR}/init.d
+ ln -sfn services ${DESTDIR}/lib/lsb
+ ln -sfn rc.d/init.d ${EXTDIR}/init.d
files: create-dirs
install -m ${MODE} lfs/init.d/checkfs ${EXTDIR}/rc.d/init.d/
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/
@@ -52,7 +51,7 @@ files: create-dirs
install -m ${MODE} lfs/sbin/ifup ${SBIN}
install -m ${MODE} lfs/sbin/ifdown ${SBIN}
install -m ${MODE} lfs/sbin/ifup.8 ${MAN8}
- ln -sf ifup.8 ${MAN8}/ifdown.8
+ ln -sf ifup.8 ${MAN8}/ifdown.8
install -m ${MODE} lfs/lib/services/ipv4-static-route ${LIBDIR}
install -m ${MODE} lfs/lib/services/ipv4-static ${LIBDIR}
install -m ${CONFMODE} lfs/lib/services/init-functions ${LIBDIR}
@@ -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
diff --git a/bootscripts/lfs/init.d/checkfs b/bootscripts/lfs/init.d/checkfs
index abfd5a73c..ef96aaf0f 100644
--- a/bootscripts/lfs/init.d/checkfs
+++ b/bootscripts/lfs/init.d/checkfs
@@ -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 --git a/bootscripts/lfs/init.d/cleanfs b/bootscripts/lfs/init.d/cleanfs
index ea4c5f4b4..84485f1c0 100644
--- a/bootscripts/lfs/init.d/cleanfs
+++ b/bootscripts/lfs/init.d/cleanfs
@@ -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 --git a/bootscripts/lfs/init.d/consolelog b/bootscripts/lfs/init.d/consolelog
deleted file mode 100755
index bd8df09cc..000000000
--- a/bootscripts/lfs/init.d/consolelog
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/bin/sh
-########################################################################
-# Begin consolelog
-#
-# Description : Set the kernel log level for the console
-#
-# Authors : Dan Nicholson - dnicholson@linuxfromscratch.org
-# Gerard Beekmans - gerard@linuxfromscratch.org
-# DJ Lucas - dj@linuxfromscratch.org
-# Update : Bruce Dubbs - bdubbs@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 --git a/bootscripts/lfs/init.d/mountvirtfs b/bootscripts/lfs/init.d/mountvirtfs
index 34ae95bab..ea32563f1 100644
--- a/bootscripts/lfs/init.d/mountvirtfs
+++ b/bootscripts/lfs/init.d/mountvirtfs
@@ -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 --git a/bootscripts/lfs/init.d/rc b/bootscripts/lfs/init.d/rc
index febf80a85..aa1f7696b 100644
--- a/bootscripts/lfs/init.d/rc
+++ b/bootscripts/lfs/init.d/rc
@@ -93,20 +93,23 @@ 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
+
+# Note: In ${LOGLEVEL:-7}, it is ':' 'dash' '7', not minus 7
+if [ "$runlevel" == "S" ]; then dmesg -n "${LOGLEVEL:-7}"; fi
if [ "${IPROMPT}" == "yes" ]; then
# dcol and icol are spaces before the message to center the
@@ -115,16 +118,20 @@ if [ "${IPROMPT}" == "yes" ]; then
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 +143,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 +163,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 +176,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 +195,23 @@ 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 --git a/bootscripts/lfs/init.d/udev b/bootscripts/lfs/init.d/udev
index 6b7a79bc6..7e0e83ded 100644
--- a/bootscripts/lfs/init.d/udev
+++ b/bootscripts/lfs/init.d/udev
@@ -84,7 +84,7 @@ case "${1}" in
# Now wait for udevd to process the uevents we triggered
/sbin/udevadm settle
- log_success_msg2
+ #log_success_msg2
;;
*)
diff --git a/bootscripts/lfs/init.d/udev_retry b/bootscripts/lfs/init.d/udev_retry
index 4f258ac19..6d62adc40 100644
--- a/bootscripts/lfs/init.d/udev_retry
+++ b/bootscripts/lfs/init.d/udev_retry
@@ -56,7 +56,7 @@ case "${1}" in
# Now wait for udevd to process the uevents we triggered
/sbin/udevadm settle
- evaluate_retval
+ #evaluate_retval
;;
*)
diff --git a/bootscripts/lfs/lib/services/init-functions b/bootscripts/lfs/lib/services/init-functions
index a9afb18a5..9b200b414 100644
--- a/bootscripts/lfs/lib/services/init-functions
+++ b/bootscripts/lfs/lib/services/init-functions
@@ -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
@@ -60,6 +61,12 @@ FAILURE="\\033[1;31m" # Failures are red
INFO="\\033[1;36m" # Information is light cyan
BRACKET="\\033[1;34m" # Brackets are blue
+# Use a colored prefix
+BMPREFIX=" "
+SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}"
+FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
+WARNING_PREFIX="${WARNING} *** ${NORMAL}"
+
BOOTLOG=/run/var/bootlog
KILLDELAY=3
@@ -171,7 +178,6 @@ start_daemon()
fi
# Do the start!
-
nice -n "${nice}" "${@}"
}
@@ -470,31 +476,38 @@ pidofproc()
# Inputs: -p pidfile, use the specified pidfile instead of pidof #
# pathname, path to the specified program #
# #
-# Note: Output to stdout. Not logged. #
-# #
# Return values: #
# 0 - Status printed #
# 1 - Input error. The daemon to check was not specified. #
################################################################################
statusproc()
{
+ local pidfile
+ local pidlist
+
if [ "${#}" = "0" ]; then
- echo "Usage: statusproc {program}"
+ echo "Usage: [-p pidfle] statusproc {program}"
exit 1
fi
- local pidfile
- local pidlist
-
- # Process arguments
- while true; do
- case "${1}" in
-
- -p)
- pidfile="${2}"
- shift 2
- ;;
- esac
+ # Process arguments
+ while true; do
+ case "${1}" in
+
+ -p)
+ pidfile="${2}"
+ shift 2
+ ;;
+
+ *)
+ if [ -n "${2}" ]; then
+ echo "Too many arguments"
+ return 1
+ else
+ break
+ fi
+ ;;
+ esac
done
if [ -z "${pidfile}" ]; then
@@ -516,7 +529,7 @@ statusproc()
echo -e "${WARNING}${1} is not running but" \
"/var/run/${base}.pid exists.${NORMAL}"
else
- if [ -z "${pidlist}" -a -n "${pidfile}" ]; then
+ if [ -n "${pidfile}" -a -e "${pidfile}" ]; then
echo -e "${WARNING}${1} is not running" \
"but ${pidfile} exists.${NORMAL}"
else
@@ -553,20 +566,25 @@ 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,20 +601,25 @@ 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 +634,14 @@ log_failure_msg2()
################################################################################
log_warning_msg()
{
- echo -n -e "${@}"
- echo -e "${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]${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,10 +656,13 @@ 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
}
@@ -641,7 +670,10 @@ log_info_msg2()
{
echo -n -e "${@}"
- 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 --git a/bootscripts/lfs/sysconfig/rc.site b/bootscripts/lfs/sysconfig/rc.site
index b068d36c6..a897f9ddd 100644
--- a/bootscripts/lfs/sysconfig/rc.site
+++ b/bootscripts/lfs/sysconfig/rc.site
@@ -2,11 +2,21 @@
# Optional parameters for boot scripts.
# Distro Information
-DISTRO="Linux From Scratch" # The distro name
-DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address
-DISTRO_MINI="LFS" # Short name used in filenames for distro config
+# These values, if specified here, override the defaults
+#DISTRO="Linux From Scratch" # The distro name
+#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
+
+# 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
+
# These values, if specified here, override the defaults
#BRACKET="\\033[1;34m" # Blue
#FAILURE="\\033[1;31m" # Red
@@ -15,9 +25,16 @@ DISTRO_MINI="LFS" # Short name used in filenames for distro config
#SUCCESS="\\033[1;32m" # Green
#WARNING="\\033[1;33m" # Yellow
+# Use a colored prefix
+# These values, if specified here, override the defaults
+#BMPREFIX=" "
+#SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}"
+#FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
+#WARNING_PREFIX="${WARNING} *** ${NORMAL}"
+
# Interactive startup
#IPROMPT="yes" # Whether to display the interactive boot promp
-itime="10" # The ammount of time (in seconds) to display the prompt
+itime="3" # 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 )