diff options
author | Martin Roth <martinroth@google.com> | 2016-02-09 12:20:32 -0700 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2016-02-18 04:21:26 +0100 |
commit | f43e51d444a261055c954abf4d6565bc62d4a72f (patch) | |
tree | 5258a9167956e780bdc14e8195798bc40911bc13 /util | |
parent | 85a255fbd89aba7edea7ac1d09c39099d53f7c44 (diff) |
board_status: Add script that will set up a ubuntu live image
This is a pretty basic script that can be downloaded with wget to a
ubuntu-based live image, and will set it up so that the board_status
script can connect and run cbmem.
1) Verify that this is being run on a ubuntu-based live image by
checking for the installer.
2) Install and configure the ssh server.
3) Set a root password 'coreboot' so that root can log in.
4) download and build cbmem.
5) find and print the IP(s) that should be used to connect.
Change-Id: I068423c9f5501b156f25371d89559f4a206916b5
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/13648
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util')
-rwxr-xr-x | util/board_status/set_up_live_image.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/util/board_status/set_up_live_image.sh b/util/board_status/set_up_live_image.sh new file mode 100755 index 0000000000..d80434eb35 --- /dev/null +++ b/util/board_status/set_up_live_image.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# This script is used to set up a ubuntu-based live image to be used +# with coreboot's board_status script. It modifies the system so that +# board_status can connect over SSH and run cbmem. This script is NOT +# meant to be run on an installed system, and changes the configuration +# in ways that would be dangerous to security on an installed system. + +# Make sure we're on a ubuntu live image +if [ ! -e /usr/bin/ubiquity ]; then + echo "Error: This doesn't appear to be a ubuntu based live image. Exiting." + exit 1 +fi + +RED='\033[1;31m' +GREEN='\033[1;32m' +NC='\033[0m' # No Color + +# shellcheck disable=SC2059 +error () +{ + printf "${RED}ERROR: $1 ${NC}\n" >&2 + if [ -n "$2" ]; then printf "${RED}Removing $2 ${NC}\n"; rm -rf "./$2"; fi + exit 1 +} + +# shellcheck disable=SC2059 +status () +{ + printf "${GREEN}${1}${NC}" +} + +# Install and configure the ssh server for the board-status script to connect to. +status "Installing and configuring ssh server\n" +sudo rm -f /etc/apt/sources.list +sudo apt-get update || \ + error "Could not update packages" +sudo apt-get install -y openssh-server || \ + error "Could not install openssh-server" +sudo sed -i.bak 's/PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config || \ + error "Could not update sshd.config to allow root login." +sudo sudo service ssh restart || \ + error "Could not restart ssh server" + +# Set the root password so it can be used to log in +status "Setting root password to 'coreboot'\n" +echo -e "root:coreboot" | sudo chpasswd || \ + error "Could not reset root password" + +# Download the coreboot tree +status "Installing git and clone the coreboot repo\n" +sudo apt-get install -y git build-essential || \ + error "Could not install git" +git clone --depth 1 https://review.coreboot.org/coreboot || \ + error "Could not download coreboot repository" + +# Build and install cbmem +status "Building and installing cbmem\n" +make -C coreboot/util/cbmem || \ + error "Could not build cbmem" +sudo make -C coreboot/util/cbmem install || \ + error "Could not instll cbmem" +sudo cbmem || \ + error "cbmem did not run correctly" +rm -rf coreboot + +# Identify the ip address that board-status will connect to +IP_ADDR=$(ifconfig -a | grep 'inet addr' | grep -v '127.0.0.1' | \ + sed 's|.*inet addr:||' | sed 's|Bcast.*||') +status "\nAddress or addresses for this board: $IP_ADDR\n" |