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 10 ASSIGN_STABLE=site_utils/stable_images/assign_stable_images.py 11 12 mkdir -p ${LOGDIR} 13 NOTIFY=( 14 chromeos-test-monitors@google.com 15 ) 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 31 $ASSIGN_STABLE --web localhost 2>&1 | tee ${TMPFILE} 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 44