blob: 25f8b31b63d4961811943a8fc937b83a638d1c15 [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 "Run the shill network connection manager"
author "chromium-os-dev@chromium.org"
# shill termination may take more than 5s (the default kill timeout) in some
# cases (e.g. it needs to disconnect a cellular modem from the network). A
# longer kill timeout is used to ensure that shill terminates properly in most
# cases. Also, stop shill on "starting pre-shutdown" so its exiting blocks the
# chromeos_shutdown script from running (jobs that "stop on stopping
# boot-services" may still be running in parallel with chromeos_shutdown if
# they do not exit quickly).
start on @expected_started_services@
stop on starting pre-shutdown
kill timeout 10
respawn
# Default parameters to be overridden by upstart configuration.
env SHILL_LOG_LEVEL=0
env SHILL_LOG_SCOPES=
env SHILL_PASSIVE_MODE=
env SHILL_PREPEND_DNS_SERVERS=
env SHILL_ACCEPT_HOSTNAME_FROM=
env SHILL_MINIMUM_MTU=
env BLACKLISTED_DEVICES=
# Hook for mod_for_test_scripts/100setupTestingInterface.
env SHILL_TEST_DEVICES=""
pre-start script
bootstat shill-start
# Load the module that provides the WiFi configuration API, since
# shill will abort if that API is not available. In most cases,
# cfg80211 will be loaded implicitly when the device driver is
# loaded (in preload-network). However, this deals with the
# first-boot case, in case shill starts before the device driver is
# loaded.
modprobe cfg80211 ||
logger -p err -t "$UPSTART_JOB" "Failed to load cfg80211"
# Create state directory
mkdir -p /var/run/shill
# Create storage for the shill global profile.
mkdir -p /var/cache/shill
# Use flimflam's default profile if shill doesn't have one.
if [ ! -f /var/cache/shill/default.profile -a \
-f /var/cache/flimflam/default.profile ]; then
mv /var/cache/flimflam/default.profile /var/cache/shill/default.profile
chmod a+r /var/cache/shill/default.profile
fi
# Set up dhcpcd's /var/{lib|run} dirs to run as user 'dhcp'.
mkdir -m 0755 -p /var/lib/dhcpcd
mkdir -m 0755 -p /var/run/dhcpcd
chmod -R u+rwX,g+rX,o+rX /var/lib/dhcpcd
chown -R dhcp:dhcp /var/lib/dhcpcd
chown -R dhcp:dhcp /var/run/dhcpcd
# This option is no longer supported.
rm -f /home/chronos/.disable_shill
end script
post-stop script
bootstat shill-stop
end script
# HEADS UP! 'expect fork' is usually a loser when used with
# 'script'. Unfortunately, shill needs 'expect fork', and
# we need a script to figure out command arguments at run time.
#
# To avoid confusing Upstart, the script below can use only shell
# built-in operations until it gets to the 'exec' at the end. Any
# command that causes the shell to fork/exec a subprocess is a
# no-no.
expect fork
script
DAEMONBIN="shill"
ARGS="--log-level=${SHILL_LOG_LEVEL} --log-scopes=${SHILL_LOG_SCOPES}"
if [ -n "${BLACKLISTED_DEVICES}" ] && [ -n "${SHILL_TEST_DEVICES}" ]; then
ARGS="${ARGS} --device-black-list=${BLACKLISTED_DEVICES},${SHILL_TEST_DEVICES}"
elif [ -n "${BLACKLISTED_DEVICES}" ]; then
ARGS="${ARGS} --device-black-list=${BLACKLISTED_DEVICES}"
elif [ -n "${SHILL_TEST_DEVICES}" ]; then
ARGS="${ARGS} --device-black-list=${SHILL_TEST_DEVICES}"
fi
if [ -n "${SHILL_PASSIVE_MODE}" ]; then
ARGS="${ARGS} --passive-mode"
fi
if [ -n "${SHILL_PREPEND_DNS_SERVERS}" ]; then
ARGS="${ARGS} --prepend-dns-servers=${SHILL_PREPEND_DNS_SERVERS}"
fi
if [ -n "${SHILL_ACCEPT_HOSTNAME_FROM}" ]; then
ARGS="${ARGS} --accept-hostname-from=${SHILL_ACCEPT_HOSTNAME_FROM}"
fi
if [ -n "${SHILL_MINIMUM_MTU}" ]; then
ARGS="${ARGS} --minimum-mtu=${SHILL_MINIMUM_MTU}"
fi
ARGS="${ARGS} ${SHILL_TEST_ARGS}"
# If OOBE has not completed (i.e. EULA not agreed to), do not run
# portal checks.
if [ ! -f /home/chronos/.oobe_completed ]; then
ARGS="${ARGS} --portal-list="
fi
exec ${DAEMONBIN} ${ARGS}
end script