| # Copyright 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 "Run a Chrome app" |
| author "chromium-os-dev@chromium.org" |
| |
| start on started boot-services |
| stop on starting pre-shutdown |
| |
| env SHARE_DIR=/usr/share/app_shell |
| env DATA_DIR=/home/chronos |
| env LOG_DIR=/var/log/ui |
| env LOG_FILE=ui.LATEST |
| |
| pre-start script |
| # Recursively copies the first path to the second path if the former exists |
| # and the latter doesn't. |
| copy_data() { |
| if [ -e "$1" ] && [ ! -e "$2" ]; then |
| cp -r "$1" "$2" |
| chown -R chronos:chronos "$2" |
| fi |
| } |
| |
| # Copy custom data installed at build time to the stateful partition if it |
| # isn't there already. |
| copy_data "${SHARE_DIR}/app_id" "${DATA_DIR}/app_id" |
| copy_data "${SHARE_DIR}/preferred_network" "${DATA_DIR}/preferred_network" |
| copy_data "${SHARE_DIR}/app" "${DATA_DIR}/app" |
| |
| mkdir -p "${LOG_DIR}" |
| ln -sf ui.$(date +%Y%m%d-%H%M%S) "${LOG_DIR}/${LOG_FILE}" |
| end script |
| |
| script |
| exec app_shell_launcher >"${LOG_DIR}/${LOG_FILE}" 2>&1 |
| end script # script |
| |
| post-stop script |
| set +e |
| . /sbin/killers |
| term_process '^X$' |
| bootstat x-terminated |
| end script |