#!/bin/sh # # This file is part of the coreboot project. # # Copyright (C) 2013 Google Inc. # EXIT_SUCCESS=0 EXIT_FAILURE=1 # Stuff from command-line switches REMOTE_HOST="" CLOBBER_OUTPUT=0 UPLOAD_RESULTS=0 # Used to specify whether a command should always be run locally or # if command should be run remoteley when a remote host is specified. LOCAL=0 REMOTE=1 # 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 $REMOTE && -n "$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 $REMOTE && -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 } show_help() { echo "Usage: ${0}