Colourful boot messages

By | 5 Aug 2008

The functions used for the status messages upon boot are defined in /lib/lsb/init-functions and may be overwritten in /etc/lsb-base-logging.sh.

To add colours, in that init-functions file find the function log_use_fancy_output() and below the fi add the lines

else
    FANCYTTY=0
fi
# BEGIN --- colour definition
if [ -n "$TERM" ]; then
    NORMAL=`$TPUT sgr0`
    BOLD=`$TPUT bold`
    BLINK=`$TPUT blink`
    BLACK=`$TPUT setaf 0`
    RED=`$TPUT setaf 1`
    GREEN=`$TPUT setaf 2`
    YELLOW=`$TPUT setaf 3`
    BLUE=`$TPUT setaf 4`
    MAGENTA=`$TPUT setaf 5`
    CYAN=`$TPUT setaf 6`
    WHITE=`$TPUT setaf 7`
fi
# END --- colour definition
case "$FANCYTTY" in
    1|Y|yes|true)   true;;
    …Code language: PHP (php)

After that, edit the lsb-base-logging.sh and change e.g. the output of log_end_msg():

if [ "$COL" ] && [ -x "$TPUT" ]; then
        printf "\r"
        $TPUT hpa $COL
        if [ "$1" -eq 0 ]; then
            echo "${BOLD}${BLUE}[${GREEN} OK ${BLUE}]${NORMAL}"
        else
            echo "${BOLD}${BLUE}[${RED}fail${BLUE}]${NORMAL}"
        fi
    elseCode language: PHP (php)

Your next boot will look like this:

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)