diff options
author | David Hendricks <dhendrix@chromium.org> | 2013-11-01 19:37:44 -0700 |
---|---|---|
committer | Ronald G. Minnich <rminnich@gmail.com> | 2013-11-04 17:11:35 +0100 |
commit | 6583a8108ca2cbcb2f363d50bd234e60bc3f4f3e (patch) | |
tree | 4d0560feb6644efdecc432057f672be0bbafd60f /util/status/status.sh | |
parent | d0299e4b5178ce8f8b986674cece3e07519f2dff (diff) |
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>
Diffstat (limited to 'util/status/status.sh')
-rw-r--r-- | util/status/status.sh | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/util/status/status.sh b/util/status/status.sh new file mode 100644 index 0000000000..0c0c714a5d --- /dev/null +++ b/util/status/status.sh @@ -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 |