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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.