blob: 89802263c9d0ebfc8b6ba562d5e9f5968d06a4bb [file] [log] [blame]
Simran Basie0479af2014-12-02 17:09:49 -08001#!/bin/bash
2
3SCRIPT_DIR=$(dirname $(readlink -f $0))
Simran Basie0479af2014-12-02 17:09:49 -08004
J. Richard Barnette96db3492015-03-27 17:23:52 -07005# By default, we're invoked without arguments. This is how the cron
6# job does it, and means we should generate output and mail it to
J. Richard Barnette3d6877c2015-02-27 13:34:26 -08007# the default mail alias.
8#
9# Invoking with arguments is for testing: It allows running through
10# the full logic and output generation, without spamming the alert
11# aliases.
12
13cd $SCRIPT_DIR
J. Richard Barnette96db3492015-03-27 17:23:52 -070014OPTIONS=""
J. Richard Barnette3d6877c2015-02-27 13:34:26 -080015if [ $# -eq 0 ]; then
16 # TODO(jrbarnette): Really, this feels like a hack. The cron job
17 # that invokes this script is installed and enabled on both a
18 # primary and backup server, meaning the e-mail will be generated
19 # twice. We don't want that, so unless this is the primary server,
20 # quash this job.
21 if ! ../cli/atest server list $(hostname) 2>&1 |
22 grep -q '^Status *: *primary'; then
23 exit 0
24 fi
25
J. Richard Barnette96db3492015-03-27 17:23:52 -070026 POOL_INTEREST=(
J. Richard Barnette7fd04502015-04-02 12:29:02 -070027 chromeos-infra-eng@grotations.appspotmail.com
J. Richard Barnette3d6877c2015-02-27 13:34:26 -080028 chromeos-lab-alerts@google.com
29 )
J. Richard Barnette96db3492015-03-27 17:23:52 -070030 BOARD_INTEREST=(
31 skc-fireteam@google.com
32 "${POOL_INTEREST[@]}"
33 )
J. Richard Barnette3d6877c2015-02-27 13:34:26 -080034else
J. Richard Barnette96db3492015-03-27 17:23:52 -070035 BOARD_INTEREST=( "$@" )
36 POOL_INTEREST=( "$@" )
37 OPTIONS=--print
J. Richard Barnette3d6877c2015-02-27 13:34:26 -080038fi
39
J. Richard Barnette96db3492015-03-27 17:23:52 -070040cd ..
41BOARD_NOTIFY=(
42 --board-notify
43 $(echo "${BOARD_INTEREST[@]}" | sed 's/ /,/g')
44)
45POOL_NOTIFY=(
46 --pool-notify
47 $(echo "${POOL_INTEREST[@]}" | sed 's/ /,/g')
48)
49site_utils/lab_inventory.py $OPTIONS "${BOARD_NOTIFY[@]}" "${POOL_NOTIFY[@]}"