blob: 29d5cd53ec79c30b77216d49fc6faeffbc2aa720 [file] [log] [blame]
Ruchi Jahagirdar032ff212017-09-20 15:03:43 -07001#!/bin/sh
2
3# Copyright 2017 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7# This script updates chameleon boards and cle in the audioboxes
8# and atlantis labs. This script takes about 15-30s per board.
9
10HOSTS="chromeos9-audiobox1-host2
11 chromeos9-audiobox2-host1"
12
13# NOTE: May need to update based on where test_rsa is located.
14SSH_OPTIONS="-q -i ~/.ssh/.test_rsa \
15 -o UserKnownHostsFile=/dev/null \
16 -o StrictHostKeyChecking=no"
17
18PROBE_RESULT_DIR="/tmp/chameleon_update_result"
19
20SEP_LINE="--------------------------------------------------------------------------------"
21
22
23function disp_result {
24 test "$1" -eq "0" && echo ok || echo "-"
25}
26
27function probe_chameleon {
28 chameleon="$1-chameleon.cros"
29
30 # ping test
31 ping -q -w 10 -c1 "${chameleon}" > /dev/null 2>&1
32 ping_result="$(disp_result $?)"
33
34 # Check if chameleond is running.
35 test $(ssh ${SSH_OPTIONS} root@"$chameleon" \
36 ps | awk '$5~"run_chameleond"' | wc -l) -gt "0"
37 chameleond_result="$(disp_result $?)"
38
39 # clear /dev/root space
40 ssh $SSH_OPTIONS root@"$chameleon" "echo "" > /www/logs/lighttpd.error.log"
41 root_result="$(disp_result $?)"
42
43 # run update command
44 ssh $SSH_OPTIONS root@"$chameleon" "/etc/init.d/chameleon-updater start >/dev/null 2>&1"
45 update_result="$(disp_result $?)"
46
47 # Print the result
48 printf "$1-chameleon %5s %10s %10s %s\n" "${ping_result}" \
49 "${chameleond_result}" "${root_result}" "${update_result}" \
50 > "${PROBE_RESULT_DIR}/${chameleon}"
51}
52
53function probe_chameleons {
54 # Fork parallel processes to probe the chameleon boards.
55 for host in $HOSTS; do
56 probe_chameleon $host &
57 chameleon_pids="${chameleon_pids} $!"
58 done
59}
60
61function create_ping_result_dir {
62 dut_pids=""
63 chameleon_pids=""
64
65 mkdir -p "${PROBE_RESULT_DIR}"
66 rm -fr "${PROBE_RESULT_DIR}"/*
67}
68
69function print_chameleon_status {
70 echo "Chameleon ping chameleond root update"
71 echo "${SEP_LINE}"
72
73 # Wait for all probing children processes to terminate.
74 for pid in ${chameleon_pids}; do
75 wait ${pid}
76 done
77
78 # Sort and print the results.
79 cat "${PROBE_RESULT_DIR}"/*-chameleon.cros | sort
80 echo; echo
81}
82
83create_ping_result_dir
84probe_chameleons
85print_chameleon_status