| # 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 started boot-services and started wpasupplicant |
| stop on starting pre-shutdown |
| kill timeout 10 |
| respawn |
| |
| # Default log level and scopes for shill. |
| env SHILL_LOG_LEVEL=0 |
| env SHILL_LOG_SCOPES= |
| env BLACKLISTED_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" |
| # Hook for mod_for_test_scripts/100setupTestingInterface. |
| SHILL_TEST_ARGS="" |
| ARGS="--log-level=${SHILL_LOG_LEVEL} --log-scopes=${SHILL_LOG_SCOPES}" |
| if [ -n "${BLACKLISTED_DEVICES}" ]; then |
| ARGS="${ARGS} --device-black-list=${BLACKLISTED_DEVICES}" |
| 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 |