1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 14:14:38 +02:00

Fix dmesg line filtering if uptime is too low

On Ubuntu 8.04.1 there can be spaces inside the initial bracketed
uptime number after a reboot.  These spaces disappear once the uptime
is large enough.  Therefore, use sed to filter out these spaces so
that the cut command that extracts SD card size will always work.

Signed-off-by: Christopher Hall <hsw@openmoko.com>
This commit is contained in:
Christopher Hall 2009-01-07 10:07:46 +00:00 committed by Andy Green
parent e08b518990
commit b98b8f5ea1

View File

@ -51,19 +51,23 @@ if [ ! -z "`grep $1 /proc/mounts`" ] ; then
fi fi
# set CUT_COLUMN for each OS # set CUT_COLUMN for each OS
# set USE_SED=some editing command
# default: use cat as a no-op
USE_SED='cat'
case "$(lsb_release --short --description)" in case "$(lsb_release --short --description)" in
Ubuntu\ 7*) Ubuntu\ 7*)
CUT_COLUMN=5 CUT_COLUMN=5
;; ;;
Ubuntu\ 8.04*) Ubuntu\ 8.04*)
CUT_COLUMN=5 CUT_COLUMN=5
USE_SED='sed s/^\[[[:space:]]*/[/'
;; ;;
*) *)
CUT_COLUMN=4 CUT_COLUMN=4
;; ;;
esac esac
DMESG_LINE=$(dmesg | grep "$1" | grep "512-byte hardware" | tail -n 1) DMESG_LINE=$(dmesg | ${USE_SED} | grep "$1" | grep "512-byte hardware" | tail -n 1)
SECTORS=$(echo "${DMESG_LINE}" | cut -d' ' -f"${CUT_COLUMN}") SECTORS=$(echo "${DMESG_LINE}" | cut -d' ' -f"${CUT_COLUMN}")
if ! echo "${SECTORS}" | grep '^[[:digit:]]\+$' if ! echo "${SECTORS}" | grep '^[[:digit:]]\+$'