Changeset 9813d5e3 for bootscripts


Ignore:
Timestamp:
11/14/2011 08:40:06 PM (12 years ago)
Author:
Bruce Dubbs <bdubbs@…>
Branches:
10.0, 10.0-rc1, 10.1, 10.1-rc1, 11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, 7.1, 7.2, 7.3, 7.4, 7.5, 7.5-systemd, 7.6, 7.6-systemd, 7.7, 7.7-systemd, 7.8, 7.8-systemd, 7.9, 7.9-systemd, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
Children:
a64fd5a
Parents:
b15d6da
Message:

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

Location:
bootscripts
Files:
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • bootscripts/ChangeLog

    rb15d6da r9813d5e3  
     12011-11-14  Bruce Dubbs <bdubbs@linuxfromscratch.org>
     2
     3   * The following are from suggestions by DJ Lucas
     4   ** General cleanup of scripts
     5   ** Move consolelog function to rc
     6   ** Clean up boot logging functions
     7   ** Fix interactive prompt between run level S and target run level
     8
    192011-10-06  Bryan Kadzban <bryan@linuxfromscratch.org>
    210
  • bootscripts/Makefile

    rb15d6da r9813d5e3  
    2525        install -d -m ${DIRMODE}  ${MAN8}
    2626        install -d -m ${DIRMODE}  ${SBIN}
    27         ln -svf       services    ${DESTDIR}/lib/lsb
    28         ln -sf        rc.d/init.d ${EXTDIR}/init.d
     27        ln -sfn       services    ${DESTDIR}/lib/lsb
     28        ln -sfn       rc.d/init.d ${EXTDIR}/init.d
    2929
    3030files: create-dirs
     
    3333        install -m ${MODE} lfs/init.d/halt          ${EXTDIR}/rc.d/init.d/
    3434        install -m ${MODE} lfs/init.d/console       ${EXTDIR}/rc.d/init.d/
    35         install -m ${MODE} lfs/init.d/consolelog    ${EXTDIR}/rc.d/init.d/
    3635        install -m ${CONFMODE} lfs/init.d/functions ${EXTDIR}/rc.d/init.d/
    3736        install -m ${MODE} lfs/init.d/localnet      ${EXTDIR}/rc.d/init.d/
     
    5352        install -m ${MODE} lfs/sbin/ifdown          ${SBIN}
    5453        install -m ${MODE} lfs/sbin/ifup.8          ${MAN8}
    55         ln -sf ifup.8                               ${MAN8}/ifdown.8
     54        ln -sf  ifup.8                              ${MAN8}/ifdown.8
    5655        install -m ${MODE} lfs/lib/services/ipv4-static-route  ${LIBDIR}
    5756        install -m ${MODE} lfs/lib/services/ipv4-static        ${LIBDIR}
     
    7776rcS: files
    7877        ln -sf ../init.d/mountvirtfs ${EXTDIR}/rc.d/rcS.d/S00mountvirtfs
    79         ln -sf ../init.d/consolelog  ${EXTDIR}/rc.d/rcS.d/S02consolelog
    8078        ln -sf ../init.d/modules     ${EXTDIR}/rc.d/rcS.d/S05modules
    8179        ln -sf ../init.d/localnet    ${EXTDIR}/rc.d/rcS.d/S08localnet
  • bootscripts/lfs/init.d/checkfs

    rb15d6da r9813d5e3  
    8080      log_info_msg "Checking file systems..."
    8181      # Note: -a option used to be -p; but this fails e.g. on fsck.minix
    82       fsck ${options} -a -A -C -T
     82      fsck ${options} -a -A -C -T >/dev/null
    8383      error_value=${?}
    8484
  • bootscripts/lfs/init.d/cleanfs

    rb15d6da r9813d5e3  
    9191
    9292      if [ "${SKIPTMPCLEAN}" = "" ]; then
    93          log_info_msg2 "\n /tmp"
     93         log_info_msg2 " /tmp"
    9494         cd /tmp &&
    9595         find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1
  • bootscripts/lfs/init.d/mountvirtfs

    rb15d6da r9813d5e3  
    3737      mkdir -p /run/{var,lock,shm}
    3838
    39       log_info_msg "Mounting virtual file systems: /run"
     39      log_info_msg "Mounting virtual file systems:     ${INFO}/run"
    4040
    4141      if ! mountpoint /proc >/dev/null; then
    42          log_info_msg2 " /proc"
     42         log_info_msg2 " ${INFO}/proc"
    4343         mount -n /proc || failed=1
    4444      fi
    4545
    4646      if ! mountpoint /sys >/dev/null; then
    47          log_info_msg2 " /sys"
     47         log_info_msg2 " ${INFO}/sys"
    4848         mount -n /sys || failed=1
    4949      fi
  • bootscripts/lfs/init.d/rc

    rb15d6da r9813d5e3  
    9494[ "${1}" != "" ] && runlevel=${1}
    9595
    96 if [ "${runlevel}" = "" ]; then
     96if [ "${runlevel}" == "" ]; then
    9797   echo "Usage: ${0} <runlevel>" >&2
    9898   exit 1
     
    100100
    101101previous=${PREVLEVEL}
    102 [ "${previous}" = "" ] && previous=N
     102[ "${previous}" == "" ] && previous=N
    103103
    104104if [ ! -d /etc/rc.d/rc${runlevel}.d ]; then
     
    107107fi
    108108
    109 if [ "$runlevel" == "6" ] || [ "$runlevel" == "0" ]; then IPROMPT="no"; fi
     109if [ "$runlevel" == "6" -o "$runlevel" == "0" ]; then IPROMPT="no"; fi
     110
     111# Note: In ${LOGLEVEL:-7}, it is ':' 'dash' '7', not minus 7
     112if [ "$runlevel" == "S" ]; then dmesg -n "${LOGLEVEL:-7}"; fi
    110113
    111114if [ "${IPROMPT}" == "yes" ]; then
     
    116119   icol=$(( ( ${COLUMNS} - ${ilen} ) / 2 ))
    117120
     121   echo -e "\n\n"
    118122   echo -e "\\033[${wcol}G${welcome_message}"
    119123   echo -e "\\033[${icol}G${i_message}${NORMAL}"
    120124   echo ""
    121125   read -t "${itime}" -n 1 interactive 2>&1 > /dev/null
    122 
    123    # Make lower case
    124    [ "${interactive}" == "I" ] && interactive="i"
    125    [ "${interactive}" != "i" ] && interactive=""
    126 fi
     126fi
     127
     128# Make lower case
     129[ "${interactive}" == "I" ] && interactive="i"
     130[ "${interactive}" != "i" ] && interactive=""
     131
     132# Read the state file if it exists from runlevel S
     133[ -r /var/run/interactive ] && source /var/run/interactive
    127134
    128135# Attempt to stop all services started by the previous runlevel,
     
    137144      sysinit_start=/etc/rc.d/rcS.d/S[0-9][0-9]$suffix
    138145
    139       if [ "${runlevel}" != "0" ]  && [ "${runlevel}" != "6" ]; then
    140          if [ ! -f ${prev_start} ] && [ ! -f ${sysinit_start} ]; then
     146      if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then
     147         if [ ! -f ${prev_start} -a ! -f ${sysinit_start} ]; then
    141148            MSG="WARNING:\n\n${i} can't be "
    142149            MSG="${MSG}executed because it was not "
     
    157164if [ "${previous}" == "N" ]; then export IN_BOOT=1; fi
    158165
    159 if [ "$runlevel" == "6" ] && [ -n "${FASTBOOT}" ]; then
     166if [ "$runlevel" == "6" -a -n "${FASTBOOT}" ]; then
    160167   touch /fastboot
    161168fi
     
    170177      prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
    171178
    172       [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue
     179      [ -f ${prev_start} -a ! -f ${stop} ] && continue
    173180   fi
    174181
     
    189196done
    190197
     198# Store interactive variable on switch from runlevel S and remove if not
     199if [ "${runlevel}" == "S" -a "${interactive}" == "i" ]; then
     200    echo "interactive=\"i\"" > /var/run/interactive
     201else
     202    rm -f /var/run/interactive 2> /dev/null
     203fi
     204
    191205# Copy the boot log on initial boot only
    192206if [ "${previous}" == "N" ]; then
    193207   cat /run/var/bootlog >> /var/log/boot.log
    194    echo "--------" >> /var/log/boot.log  # Mark the end of boot
     208
     209   if [ "${runlevel}" != "S" ]; then
     210      # Mark the end of boot
     211      echo "--------" >> /var/log/boot.log
     212      # Remove the temporary file
     213      rm -f /run/var/bootlog 2> /dev/null
     214   fi
    195215fi
    196216
  • bootscripts/lfs/init.d/udev

    rb15d6da r9813d5e3  
    8585      # Now wait for udevd to process the uevents we triggered
    8686      /sbin/udevadm settle
    87       log_success_msg2
     87      #log_success_msg2
    8888      ;;
    8989
  • bootscripts/lfs/init.d/udev_retry

    rb15d6da r9813d5e3  
    5757      # Now wait for udevd to process the uevents we triggered
    5858      /sbin/udevadm settle
    59       evaluate_retval
     59      #evaluate_retval
    6060      ;;
    6161
  • bootscripts/lfs/lib/services/init-functions

    rb15d6da r9813d5e3  
    4444SET_WCOL="\\033[${WCOL}G"    # at the $WCOL char
    4545CURS_UP="\\033[1A\\033[0G"   # Up one line, at the 0'th char
     46CURS_ZERO="\\033[0G"
    4647
    4748## Set color commands, used via echo
     
    6061INFO="\\033[1;36m"           # Information is light cyan
    6162BRACKET="\\033[1;34m"        # Brackets are blue
     63
     64# Use a colored prefix
     65BMPREFIX="     "
     66SUCCESS_PREFIX="${SUCCESS}  *  ${NORMAL}"
     67FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
     68WARNING_PREFIX="${WARNING} *** ${NORMAL}"
    6269
    6370BOOTLOG=/run/var/bootlog
     
    172179
    173180    # Do the start!
    174 
    175181    nice -n "${nice}" "${@}"
    176182}
     
    471477#         pathname, path to the specified program                              #
    472478#                                                                              #
    473 # Note: Output to stdout.  Not logged.                                         #
    474 #                                                                              #
    475479# Return values:                                                               #
    476480#       0 - Status printed                                                     #
     
    479483statusproc()
    480484{
     485   local pidfile
     486   local pidlist
     487
    481488   if [ "${#}" = "0" ]; then
    482       echo "Usage: statusproc {program}"
     489      echo "Usage: [-p pidfle] statusproc {program}"
    483490      exit 1
    484491   fi
    485492
    486     local pidfile
    487     local pidlist
    488 
    489     # Process arguments
    490     while true; do
    491       case "${1}" in
    492 
    493           -p)
    494               pidfile="${2}"
    495               shift 2
    496               ;;
    497       esac
     493   # Process arguments
     494   while true; do
     495       case "${1}" in
     496
     497           -p)
     498               pidfile="${2}"
     499               shift 2
     500               ;;
     501
     502           *)
     503               if [ -n "${2}" ]; then
     504                   echo "Too many arguments"
     505                   return 1
     506               else
     507                   break
     508               fi
     509               ;;
     510       esac
    498511   done
    499512
     
    517530            "/var/run/${base}.pid exists.${NORMAL}"
    518531      else
    519          if [ -z "${pidlist}" -a -n "${pidfile}" ]; then
     532         if [ -n "${pidfile}" -a -e "${pidfile}" ]; then
    520533            echo -e "${WARNING}${1} is not running" \
    521534               "but ${pidfile} exists.${NORMAL}"
     
    554567log_success_msg()
    555568{
    556     echo -n -e "${@}"
    557     echo -e "${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
     569    echo -n -e "${BMPREFIX}${@}"
     570    echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
     571
     572    # Strip non-printable characters from log file
     573    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
    558574
    559575    timespec
    560     echo -e "${STAMP} ${@} OK" >> ${BOOTLOG}
     576    echo -e "${STAMP} ${logmessage} OK" >> ${BOOTLOG}
     577   
    561578    return 0
    562579}
     
    564581log_success_msg2()
    565582{
    566     echo -n -e "${@}"
    567     echo -e "${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
     583    echo -n -e "${BMPREFIX}${@}"
     584    echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${BRACKET}[${SUCCESS}  OK  ${BRACKET}]${NORMAL}"
    568585
    569586    echo " OK" >> ${BOOTLOG}
     587   
    570588    return 0
    571589}
     
    584602log_failure_msg()
    585603{
    586     echo -n -e "${@}"
    587     echo -e "${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
     604    echo -n -e "${BMPREFIX}${@}"
     605    echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
     606
     607    # Strip non-printable characters from log file
    588608
    589609    timespec
    590     echo -e "${STAMP} ${@} FAIL" >> ${BOOTLOG}
     610    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
     611    echo -e "${STAMP} ${logmessage} FAIL" >> ${BOOTLOG}
     612   
    591613    return 0
    592614}
     
    594616log_failure_msg2()
    595617{
    596     echo -n -e "${@}"
    597     echo -e "${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
     618    echo -n -e "${BMPREFIX}${@}"
     619    echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
    598620
    599621    echo "FAIL" >> ${BOOTLOG}
     622   
    600623    return 0
    601624}
     
    612635log_warning_msg()
    613636{
    614     echo -n -e "${@}"
    615     echo -e "${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}"
    616 
     637    echo -n -e "${BMPREFIX}${@}"
     638    echo -e "${CURS_ZERO}${WARNING_PREFIX}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}"
     639
     640    # Strip non-printable characters from log file
     641    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
    617642    timespec
    618     echo -e "${STAMP} ${@} WARN" >> ${BOOTLOG}
     643    echo -e "${STAMP} ${logmessage} WARN" >> ${BOOTLOG}
     644   
    619645    return 0
    620646}
     
    631657log_info_msg()
    632658{
     659    echo -n -e "${BMPREFIX}${@}"
     660
     661    # Strip non-printable characters from log file
     662    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
     663    timespec
     664    echo -n -e "${STAMP} ${logmessage}" >> ${BOOTLOG}
     665   
     666    return 0
     667}
     668
     669log_info_msg2()
     670{
    633671    echo -n -e "${@}"
    634672
    635     timespec
    636     echo -n -e "${STAMP} ${@}" >> ${BOOTLOG}
    637     return 0
    638 }
    639 
    640 log_info_msg2()
    641 {
    642     echo -n -e "${@}"
    643 
    644     echo -n -e "${@}" >> ${BOOTLOG}
     673    # Strip non-printable characters from log file
     674    local logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
     675    echo -n -e "${logmessage}" >> ${BOOTLOG}
     676   
    645677    return 0
    646678}
  • bootscripts/lfs/sysconfig/rc.site

    rb15d6da r9813d5e3  
    33
    44# Distro Information
    5 DISTRO="Linux From Scratch" # The distro name
    6 DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address
    7 DISTRO_MINI="LFS" # Short name used in filenames for distro config
     5# These values, if specified here, override the defaults
     6#DISTRO="Linux From Scratch" # The distro name
     7#DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address
     8#DISTRO_MINI="LFS" # Short name used in filenames for distro config
    89
    910# Define custom colors used in messages printed to the screen
     11
     12# Please consult `man console_codes` for more information
     13# under the "ECMA-48 Set Graphics Rendition" section
     14#
     15# Warning: when switching from a 8bit to a 9bit font,
     16# the linux console will reinterpret the bold (1;) to
     17# the top 256 glyphs of the 9bit font.  This does
     18# not affect framebuffer consoles
     19
    1020# These values, if specified here, override the defaults
    1121#BRACKET="\\033[1;34m" # Blue
     
    1626#WARNING="\\033[1;33m" # Yellow
    1727
     28# Use a colored prefix
     29# These values, if specified here, override the defaults
     30#BMPREFIX="     "
     31#SUCCESS_PREFIX="${SUCCESS}  *  ${NORMAL}"
     32#FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
     33#WARNING_PREFIX="${WARNING} *** ${NORMAL}"
     34
    1835# Interactive startup
    1936#IPROMPT="yes" # Whether to display the interactive boot promp
    20 itime="10"    # The ammount of time (in seconds) to display the prompt
     37itime="3"    # The ammount of time (in seconds) to display the prompt
    2138
    2239# The total length of the distro welcome string, without escape codes
Note: See TracChangeset for help on using the changeset viewer.