| # Copyright (c) 2014 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| description "Clean up the devserver static directory daily." |
| author "chromium-os-dev@chromium.org" |
| |
| start on (started moblab-devserver-init and |
| stopped moblab-external-storage-init RESULT=ok) |
| |
| env STATIC_DIR=/mnt/moblab/static |
| |
| normal exit TERM |
| |
| script |
| mkdir -p /var/log/bootup/ |
| exec >>/var/log/bootup/${UPSTART_JOB}.log 2>&1 |
| set -x |
| set -e |
| logger -t "${UPSTART_JOB}" "Starting." |
| if [ -z "${STATIC_DIR}" ] ; then |
| logger -t "${UPSTART_JOB}" "No static directory param passed." |
| exit 1 |
| fi |
| logger -t "${UPSTART_JOB}" "Delaying first cleanup task.." |
| sleep 900 # 15 minutes |
| while true; do |
| logger -t "${UPSTART_JOB}" "Running devserver clean up." |
| sudo -u moblab \ |
| /usr/local/autotest/site_utils/admin/clean_staged_images.py \ |
| -v -a 168 -p 168 "${STATIC_DIR}" || true |
| logger -t "${UPSTART_JOB}" "Cleaned staged images. Sleeping..." |
| sleep 86400 |
| done |
| end script |