Home | History | Annotate | Download | only in contrib
      1 # By default, we're invoked without arguments.  This is how the cron
      2 # job does it, and means we should generate output and mail it to
      3 # the default mail alias.
      4 #
      5 # Invoking with arguments is for testing:  It allows running through
      6 # the full logic and output generation, without spamming the alert
      7 # aliases.
      8 
      9 OPTIONS=""
     10 if [ $# -eq 0 ]; then
     11   # TODO(jrbarnette):  Really, this feels like a hack.  The cron job
     12   # that invokes the inventory scripts is installed and enabled on
     13   # both a primary and backup server, meaning the e-mail will be
     14   # generated twice.  We don't want that, so unless this is the
     15   # primary server, quash this job.
     16   if ! cli/atest server list $(hostname) 2>&1 |
     17       grep -q '^Status *: *primary'; then
     18     exit 0
     19   fi
     20 
     21   POOL_INTEREST=(
     22     chromeos-infra-eng (a] grotations.appspotmail.com
     23     chromeos-lab-alerts (a] google.com
     24   )
     25   BOARD_INTEREST=(
     26     englab-sys-cros (a] google.com
     27     chromeos-lab-alerts (a] google.com
     28   )
     29 else
     30   BOARD_INTEREST=( "$@" )
     31   POOL_INTEREST=( "$@" )
     32   OPTIONS=--print
     33 fi
     34 
     35 BOARD_NOTIFY=(
     36   --board-notify
     37   $(echo "${BOARD_INTEREST[@]}" | sed 's/ /,/g')
     38 )
     39 POOL_NOTIFY=(
     40   --recommend=20
     41   --pool-notify
     42   $(echo "${POOL_INTEREST[@]}" | sed 's/ /,/g')
     43 )
     44