| # Copyright (c) 2009 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 user interface" |
| author "chromium-os-dev@chromium.org" |
| |
| # Note, this line is modified by chromeos-factoryinstall.ebuild |
| # and mod_for_factory. Please do not change without also changing |
| # those references. |
| start on stopping startup |
| stop on starting halt or starting reboot |
| |
| respawn |
| respawn limit 3 10 # if the job respawns 3 times in 10 seconds, stop trying. |
| |
| limit nice 20 20 # Enables chrome to renice background tabs |
| |
| # Uncomment line below to output to VT02 |
| #console output |
| |
| # Directory where Chrome logs are written and prefix of files there. |
| env CHROME_LOG_DIR=/var/log/chrome |
| env CHROME_LOG_PREFIX=chrome |
| |
| # Directory where session manager logs are written and prefix of files there. |
| env UI_LOG_DIR=/var/log/ui |
| env UI_LOG_PREFIX=ui |
| |
| pre-start script |
| |
| X_SOCKET_DIR=/tmp/.X11-unix |
| X_ICE_DIR=/tmp/.ICE-unix |
| mkdir -p "$X_SOCKET_DIR" "$X_ICE_DIR" |
| chown root:root "$X_SOCKET_DIR" "$X_ICE_DIR" |
| chmod 1777 "$X_SOCKET_DIR" "$X_ICE_DIR" |
| |
| # XKB writes keymaps here; otherwise things like Ctrl-Alt-Fx VT switching |
| # don't work. |
| mkdir -p /var/lib/xkb |
| |
| # Make sure we we can easily track UI state. |
| rm -rf /var/run/state/ |
| mkdir -p /var/run/state |
| |
| # Ensure the existence of the directory in which the whitelist and other |
| # Ownership-related state will live. Yes, it should be owned by root. |
| # The permissions are set such that the chronos user can see the content |
| # of known files inside whitelist, but not anything else. |
| mkdir -m 0710 -p /var/lib/whitelist |
| chown root:chronos /var/lib/whitelist |
| |
| # Enable us to keep track of the user's chosen TZ. |
| # Default to Pacific timezone if we don't have one set |
| TIMEZONE_DIR=/var/lib/timezone |
| TIMEZONE_FILE=${TIMEZONE_DIR}/localtime |
| if [ ! -f "${TIMEZONE_FILE}" ]; then |
| mkdir -p ${TIMEZONE_DIR} |
| ln -sf /usr/share/zoneinfo/US/Pacific ${TIMEZONE_FILE} |
| chown -R chronos:chronos ${TIMEZONE_DIR} |
| fi |
| |
| # Create a directory that the window manager (running as "chronos") can |
| # write to. |
| mkdir -p /var/run/state/windowmanager |
| chown chronos:chronos /var/run/state/windowmanager |
| |
| end script # pre-start |
| |
| script |
| mkdir -p "${CHROME_LOG_DIR}" |
| chown chronos:chronos "${CHROME_LOG_DIR}" |
| |
| mkdir -p "${UI_LOG_DIR}" |
| UI_LOG_FILE="${UI_LOG_DIR}/${UI_LOG_PREFIX}.$(date +%Y%m%d-%H%M%S)" |
| ln -sf $(basename "${UI_LOG_FILE}") "${UI_LOG_DIR}/${UI_LOG_PREFIX}.LATEST" |
| exec /sbin/session_manager_setup.sh >"${UI_LOG_FILE}" 2>&1 |
| end script |
| |
| post-stop script |
| |
| bootstat ui-post-stop |
| set +e |
| . /sbin/killers |
| |
| # Kill X first; we want the window manager to be running up until the point |
| # where X dies (see http://crosbug.com/7901). |
| term_process "^X$" |
| bootstat x-terminated |
| |
| # Terminate any processes with files open on the mount point |
| # TODO(wad) parallelize with VFS/PID namespaces. |
| kill_with_open_files_on /home/chronos/user |
| |
| # Make sure everything is going down. No exceptions. |
| pkill -9 -U chronos |
| pkill -9 -u chronos |
| bootstat other-processes-terminated |
| |
| /usr/sbin/cryptohome --action=unmount |
| bootstat cryptohome-unmounted |
| |
| # Copy boot/logout stats since /tmp will be deleted at machine shutdown. |
| # TODO(satorux): Fix this code not to rely on the implementation details |
| # of bootstat and boot_times_loader.cc. Ignore errors in copying files. |
| mkdir -p /home/chronos/prev_stats |
| cp -f /tmp/uptime-* /tmp/*-times-* /home/chronos/prev_stats || true |
| |
| end script |