#!/bin/sh
#
# Check kernel command line to see if a serial console has been
# configured with 9600 baud and, if that is the case print a message
# recommending a higher baud rate.
#
# There are several ways of configuring a serial console, only the
# common case of console=ttyS and console=ttyUSB are handled here.
# The more exotic forms of serial console configuration tend to be
# used for specific diagnostic tests so we don't want to inject log
# and and console messages for those.
#
# Note that each line is sent to /dev/kmsg separately to avoid a
# multiline entry in the kernel log.

grep -Eq 'console=tty(S|USB)[0-9]+(,9600|$)' /proc/cmdline || exit 0
for line in \
    "Serial console is set to the default of 9600 baud. This can" \
    "result in stalls or lockups in error conditions requiring a" \
    "large number of console system messages. Please increase the" \
    "rate to the highest your system will allow (for instance, 115200" \
    "or 57600). See Oracle KM Note 2648582.1 for more information."; do
    echo "$line" | tee /dev/kmsg
done
exit 1
