blob: 6811fcd2bb54512866592855a22e6e711e65d6a7 [file] [log] [blame]
# Copyright (c) 2013 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 "Chrome OS post-mount-encrypted import data."
author "chromium-os-dev@chromium.org"
# This job handles delayed copying of CRX files into the CRX cache in a
# validated way. This is normally only performed on first boot, and so
# will be a nearly null operation after that.
start on started system-services
script
# If this is a factory installer image, don't run at all.
if [ -f /root/.factory_installer ]; then
exit 0
fi
FROM=/mnt/stateful_partition/unencrypted/import_extensions
TO=/var/cache/external_cache
VALIDATION=/usr/share/import_extensions/validation
if [ ! -d "${TO}" ]; then
mkdir -m 700 "${TO}"
# If the source directory exists, and we can validate it... import.
if [ -d "${FROM}" ]; then
for val in "${VALIDATION}"/*; do
# If the import fails, we want to just keep going.
logger -t "${UPSTART_JOB}" "Performing CRX import for: ${val}"
encrypted_import "${FROM}" "${val}" "${TO}" 2>&1 | \
logger -t "${UPSTART_JOB}"
done
else
logger -t "${UPSTART_JOB}" "CRX Source not present. No import performed."
fi
chown -R chronos:chronos "${TO}"
else
logger -t "${UPSTART_JOB}" "CRX Cache exists. No import performed."
fi
# This .dot file tells the cache manager in Chrome that the import process
# has finished. It should be created, even if we weren't actually able to
# import anything.
touch "${TO}/.initialized"
# Success or failure, we remove the source files. However, if we are on
# removable media, we want to leave them around so they'll be there for
# chromeos-install to use.
ROOT_DEV="$(basename "$(rootdev -s -d)")"
REMOVABLE="$(cat "/sys/block/${ROOT_DEV}/removable")" || :
if [ ${REMOVABLE:-0} -eq 0 ]; then
rm -rf "${FROM}"
fi
end script