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 6SCRIPT_DIR=$(dirname $(readlink -f $0)) 7cd ${SCRIPT_DIR}/.. 8 9LOGDIR=logs/stable-version 10ASSIGN_STABLE=site_utils/stable_images/assign_stable_images.py 11 12mkdir -p ${LOGDIR} 13NOTIFY=( 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# 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 31$ASSIGN_STABLE --web localhost 2>&1 | tee ${TMPFILE} 32echo 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 44