Another pass at board status script

This reports relevant bits of information about a machine which is
running coreboot. This also includes a script to get revision info
from git, which we may want to split out into another patch.

A remote target can be specified since it is likely that the machine
used to develop the code is not the same machine being developed for.
The remote host must be set up for non-interactive root login.

Example: sh util/status/status.sh -r gizmoboard -u

Change-Id: Ief0a85faca2ec9ce2d270e1e5b09e74836ab0c97
Signed-off-by: David Hendricks <dhendrix@chromium.org>
Reviewed-on: http://review.coreboot.org/4021
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
David Hendricks
2013-11-01 19:37:44 -07:00
committed by Ronald G. Minnich
parent d0299e4b51
commit 6583a8108c
2 changed files with 365 additions and 0 deletions

137
util/status/status.sh Normal file
View File

@@ -0,0 +1,137 @@
#!/bin/sh
#
# This file is part of the coreboot project.
#
# Copyright (C) 2013 Google Inc.
#
EXIT_SUCCESS=0
EXIT_FAILURE=1
OUTDIR="status"
# Stuff from command-line switches
REMOTE_HOST=""
CLOBBER_OUTPUT=0
UPLOAD_RESULTS=0
show_help() {
echo "Usage:
${0} <option>
Options
-h
Show this message.
-c
Clobber output when finished.
-r <host>
Obtain machine information from remote host (using ssh).
-u
Upload results to coreboot.org.
"
}
# test a command
#
# $1: test command on remote host (0=no, 1=yes)
# $2: command to test
test_cmd()
{
local rc
if [ -e "$2" ]; then
return
fi
if [[ $1 -eq 1 && "$REMOTE_HOST" ]]; then
ssh root@${REMOTE_HOST} which "$2" >/dev/null
rc=$?
else
which "$2" >/dev/null
rc=$?
fi
if [ $rc -eq 0 ]; then
return
fi
echo "$2 not found"
exit $EXIT_FAILURE
}
# run a command
#
# $1: 0 to run command locally, 1 to run remotely if remote host defined
# $2: command
cmd()
{
if [ -e "$2" ]; then
return
fi
if [[ $1 -eq 1 && -n "$REMOTE_HOST" ]]; then
ssh root@${REMOTE_HOST} "$2"
else
$2
fi
if [ $? -eq 0 ]; then
return
fi
echo "Failed to run command: $2"
exit $EXIT_FAILURE
}
while getopts "chr:u" opt; do
case "$opt" in
h)
show_help
exit $EXIT_SUCCESS
;;
c)
CLOBBER_OUTPUT=1
;;
r)
REMOTE_HOST="$OPTARG"
;;
u)
UPLOAD_RESULTS=1
;;
esac
done
if [ -e "$OUTDIR" ]; then
echo "Output directory exists, aborting."
exit $EXIT_FAILURE
fi
mkdir "$OUTDIR"
getrevision="util/status/getrevision.sh"
test_cmd 0 $getrevision
touch ${OUTDIR}/revision.txt
printf "Local revision: %s\n" $($getrevision -l) >> ${OUTDIR}/revision.txt
printf "Upstream revision: %s\n" $($getrevision -u) >> ${OUTDIR}/revision.txt
printf "Upstream URL: %s\n" $($getrevision -U)>> ${OUTDIR}/revision.txt
printf "Timestamp: %s\n" $($getrevision -t) >> ${OUTDIR}/revision.txt
cbfstool_cmd="util/cbfstool/cbfstool"
test_cmd 0 "$cbfstool_cmd"
$cbfstool_cmd build/coreboot.rom extract -n config -f ${OUTDIR}/config.txt
test_cmd 1 "cbmem"
cmd 1 "cbmem -c" > ${OUTDIR}/coreboot_console.txt
cmd 1 "cbmem -t" > ${OUTDIR}/coreboot_timestamps.txt
cmd 1 "cbmem -C" > ${OUTDIR}/coreboot_coverage.txt
cmd 1 dmesg > ${OUTDIR}/kernel_log.txt
#if [ $UPLOAD_RESULTS -eq 1 ]; then
# FIXME: implement this part
#fi
if [ $CLOBBER_OUTPUT -eq 1 ]; then
rm -rf ${OUTDIR}
fi
exit $EXIT_SUCCESS