J. Richard Barnette | c1efd43 | 2015-11-12 09:12:53 -0800 | [diff] [blame] | 1 | #!/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 | |
| 6 | SCRIPT_DIR=$(dirname $(readlink -f $0)) |
| 7 | cd ${SCRIPT_DIR}/.. |
| 8 | |
| 9 | LOGDIR=logs/stable-version |
Richard Barnette | 56844c0 | 2016-10-04 14:24:05 -0700 | [diff] [blame] | 10 | ASSIGN_STABLE=site_utils/stable_images/assign_stable_images.py |
J. Richard Barnette | c1efd43 | 2015-11-12 09:12:53 -0800 | [diff] [blame] | 11 | |
Prathmesh Prabhu | 3761f76 | 2019-02-15 15:23:37 -0800 | [diff] [blame] | 12 | mkdir -p ${LOGDIR} |
| 13 | NOTIFY=( |
| 14 | chromeos-test-monitors@google.com |
| 15 | ) |
J. Richard Barnette | c1efd43 | 2015-11-12 09:12:53 -0800 | [diff] [blame] | 16 | |
| 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 | # |
| 21 | TAG=$(date '+%Y-%W') |
| 22 | if [ $# -eq 0 -a -d ${LOGDIR} ]; then |
| 23 | LOGFILE="update-${TAG}.log" |
| 24 | exec >>${LOGDIR}/${LOGFILE} 2>&1 |
| 25 | fi |
| 26 | |
| 27 | trap 'rm -f ${TMPFILE}' EXIT |
| 28 | TMPFILE=$(mktemp) |
| 29 | |
| 30 | date |
Prathmesh Prabhu | 285fb31 | 2019-02-25 08:41:47 -0800 | [diff] [blame] | 31 | $ASSIGN_STABLE --web localhost 2>&1 | tee ${TMPFILE} |
J. Richard Barnette | c1efd43 | 2015-11-12 09:12:53 -0800 | [diff] [blame] | 32 | echo |
| 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 | # |
| 39 | if [ -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') |
| 43 | fi |