blob: 00eea2b5149659f9285e877a15b2cbfb4f698b35 [file] [log] [blame]
# Copyright (c) 2012 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, the 'start on' line is modified by the chromeos-factoryinstall
# ebuild. Please do not change it without also changing that
# reference.
#
# This job's post-stop script depends on cryptohomed being running;
# cryptohomed in turn depends on chapsd and dbus-daemon. This job's
# stop condition uses a special stop job to keep those processes
# from terminating until after this job has cleaned up. See the
# pre-shutdown job for more details.
start on started boot-services
stop on starting pre-shutdown
respawn
# The limit used to be "6 60". However, even successful logouts are considered
# crashes - crosbug.com/33165. This makes it difficult for automated tests.
# TODO(nirnimesh): Revert to "6 60" when the bug is fixed.
respawn limit 10 60 # If the job respawns 10 times in a minute, stop trying.
# Enables chrome to renice background tabs (lower priority), and to boost the
# nice level of audio threads.
limit nice -10 -10
# 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_FILE=ui.LATEST
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
# Create the directory where the AppPack extensions are cached.
# These extensions are read and written by chronos.
mkdir -m 0700 -p /var/cache/app_pack
chown chronos:chronos /var/cache/app_pack
# 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
mkdir -p $CHROME_LOG_DIR
chown chronos:chronos $CHROME_LOG_DIR
mkdir -p $UI_LOG_DIR
ln -sf ui.$(date +%Y%m%d-%H%M%S) $UI_LOG_DIR/$UI_LOG_FILE
end script # pre-start
exec session_manager_setup.sh >$UI_LOG_DIR/$UI_LOG_FILE 2>&1
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 PKCS #11 services.
cryptohome --action=pkcs11_terminate
# 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.
# The loop is so that clever daemons can't evade the kill by
# racing us and killing us first; we'll just try over and over
# until we win the race, and kill with pid -1 is atomic with
# respect to process creation.
while ! sudo -u chronos kill -9 -1 ; do
sleep .1
done
bootstat other-processes-terminated
cryptohome --action=unmount
bootstat cryptohome-unmounted
end script