blob: f4b3b36d89c893f603c5c96f40480786ca6e05e7 [file] [log] [blame]
J. Richard Barnettec1efd432015-11-12 09:12:53 -08001#!/bin/bash
2# Copyright (c) 2015 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6SCRIPT_DIR=$(dirname $(readlink -f $0))
7cd ${SCRIPT_DIR}/..
8
9LOGDIR=logs/stable-version
Richard Barnette56844c02016-10-04 14:24:05 -070010ASSIGN_STABLE=site_utils/stable_images/assign_stable_images.py
J. Richard Barnettec1efd432015-11-12 09:12:53 -080011
Prathmesh Prabhu3761f762019-02-15 15:23:37 -080012mkdir -p ${LOGDIR}
13NOTIFY=(
14 chromeos-test-monitors@google.com
15)
J. Richard Barnettec1efd432015-11-12 09:12:53 -080016
17# Redirect onto a log file. For debug purposes, skip redirection if
18# there's a command line argument (we ignore what the argument is), or
19# if there's no log directory.
20#
21TAG=$(date '+%Y-%W')
22if [ $# -eq 0 -a -d ${LOGDIR} ]; then
23 LOGFILE="update-${TAG}.log"
24 exec >>${LOGDIR}/${LOGFILE} 2>&1
25fi
26
27trap 'rm -f ${TMPFILE}' EXIT
28TMPFILE=$(mktemp)
29
30date
Prathmesh Prabhu285fb312019-02-25 08:41:47 -080031$ASSIGN_STABLE --web localhost 2>&1 | tee ${TMPFILE}
J. Richard Barnettec1efd432015-11-12 09:12:53 -080032echo
33
34# If we have a log directory, clean it up, and send e-mail notification.
35# The log files change name each week, so by throwing out all but the
36# most recent 14 files, we keep about 3 months of history, plus this
37# week's log.
38#
39if [ -d ${LOGDIR} ]; then
40 SUBJECT="Stable version update summary ${TAG}"
41 site_utils/gmail_lib.py -s "${SUBJECT}" "${NOTIFY[@]}" <${TMPFILE}
42 rm -f $(ls -r ${LOGDIR}/update-*.log | sed '1,14 d')
43fi