blob: 6ad760bad75231f62c283218ccceb078fc543779 [file] [log] [blame]
# Copyright 2017 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 "Install payloads for Chrome OS test and factory software"
author "chromium-os-dev@chromium.org"
# `cros_payload` is a system to maintain and install file or block device
# resources, especially for Chrome OS factory software.
# This upstart job will run and clean the installer stubs prepared by
# cros_payload. Read go/cros_payload for more details.
start on stopping startup
task
script
PAYLOADS="/usr/local/opt/cros_payloads"
INSTALL_DIR="${PAYLOADS}/install"
# To make sure the log is always read-able (i.e., not in encrypted stateful
# partition) for debugging, use a separate log file.
LOG_FILE="${INSTALL_DIR}/log"
if [ ! -d "${INSTALL_DIR}" ]; then
exit
fi
cd "${PAYLOADS}"
for script in "${INSTALL_DIR}"/*.sh; do
if [ ! -f "${script}" ]; then
continue
fi
echo "$(date): Installing [${script}]..." >>"${LOG_FILE}"
if ! sh "${script}" >>"${LOG_FILE}" 2>&1; then
continue
fi
# Unstable system may crash and reboot unexpectedly so we have to sync
# and wait for a while, make sure the installation was completed, before
# being able to remove the installation stubs safely.
(sync && sleep 3 && rm -f "${script}") &
done
# Wait for all background process to complete.
wait
end script