1# 2# Copyright (C) 2012 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17description "Run the shill network connection manager" 18author "chromium-os-dev@chromium.org" 19 20# shill termination may take more than 5s (the default kill timeout) in some 21# cases (e.g. it needs to disconnect a cellular modem from the network). A 22# longer kill timeout is used to ensure that shill terminates properly in most 23# cases. Also, stop shill on "starting pre-shutdown" so its exiting blocks the 24# chromeos_shutdown script from running (jobs that "stop on stopping 25# boot-services" may still be running in parallel with chromeos_shutdown if 26# they do not exit quickly). 27start on @expected_started_services@ 28stop on starting pre-shutdown 29kill timeout 10 30respawn 31 32# Default parameters to be overridden by upstart configuration. 33env SHILL_LOG_LEVEL=0 34env SHILL_LOG_SCOPES= 35env SHILL_PASSIVE_MODE= 36env SHILL_PREPEND_DNS_SERVERS= 37env SHILL_ACCEPT_HOSTNAME_FROM= 38env SHILL_MINIMUM_MTU= 39env BLACKLISTED_DEVICES= 40env DHCPV6_ENABLED_DEVICES= 41env IGNORE_UNKNOWN_ETHERNET= 42 43# Hook for mod_for_test_scripts/100setupTestingInterface. 44env SHILL_TEST_DEVICES="" 45 46pre-start script 47 bootstat shill-start 48 49 # Create state directory 50 mkdir -p /var/run/shill 51 52 # Create storage for the shill global profile. 53 mkdir -p /var/cache/shill 54 55 # Use flimflam's default profile if shill doesn't have one. 56 if [ ! -f /var/cache/shill/default.profile -a \ 57 -f /var/cache/flimflam/default.profile ]; then 58 mv /var/cache/flimflam/default.profile /var/cache/shill/default.profile 59 chmod a+r /var/cache/shill/default.profile 60 fi 61 62 # Set up dhcpcd's /var/{lib|run} dirs to run as user 'dhcp'. 63 mkdir -m 0755 -p /var/lib/dhcpcd 64 mkdir -m 0755 -p /var/run/dhcpcd 65 chmod -R u+rwX,g+rX,o+rX /var/lib/dhcpcd 66 chown -R dhcp:dhcp /var/lib/dhcpcd 67 chown -R dhcp:dhcp /var/run/dhcpcd 68 69 # This option is no longer supported. 70 rm -f /home/chronos/.disable_shill 71end script 72 73post-stop script 74 bootstat shill-stop 75end script 76 77script 78 DAEMONBIN="shill" 79 ARGS="--log-level=${SHILL_LOG_LEVEL} --log-scopes=${SHILL_LOG_SCOPES}" 80 if [ -n "${BLACKLISTED_DEVICES}" ] && [ -n "${SHILL_TEST_DEVICES}" ]; then 81 ARGS="${ARGS} --device-black-list=${BLACKLISTED_DEVICES},${SHILL_TEST_DEVICES}" 82 elif [ -n "${BLACKLISTED_DEVICES}" ]; then 83 ARGS="${ARGS} --device-black-list=${BLACKLISTED_DEVICES}" 84 elif [ -n "${SHILL_TEST_DEVICES}" ]; then 85 ARGS="${ARGS} --device-black-list=${SHILL_TEST_DEVICES}" 86 fi 87 if [ -n "${SHILL_PASSIVE_MODE}" ]; then 88 ARGS="${ARGS} --passive-mode" 89 fi 90 if [ -n "${SHILL_PREPEND_DNS_SERVERS}" ]; then 91 ARGS="${ARGS} --prepend-dns-servers=${SHILL_PREPEND_DNS_SERVERS}" 92 fi 93 if [ -n "${SHILL_ACCEPT_HOSTNAME_FROM}" ]; then 94 ARGS="${ARGS} --accept-hostname-from=${SHILL_ACCEPT_HOSTNAME_FROM}" 95 fi 96 if [ -n "${SHILL_MINIMUM_MTU}" ]; then 97 ARGS="${ARGS} --minimum-mtu=${SHILL_MINIMUM_MTU}" 98 fi 99 if [ -n "${DHCPV6_ENABLED_DEVICES}" ]; then 100 ARGS="${ARGS} --dhcpv6-enabled-devices=${DHCPV6_ENABLED_DEVICES}" 101 fi 102 if [ -n "${IGNORE_UNKNOWN_ETHERNET}" ]; then 103 ARGS="${ARGS} --ignore-unknown-ethernet" 104 fi 105 ARGS="${ARGS} ${SHILL_TEST_ARGS}" 106 107 # If OOBE has not completed (i.e. EULA not agreed to), do not run 108 # portal checks. 109 if [ ! -f /home/chronos/.oobe_completed ]; then 110 ARGS="${ARGS} --portal-list=" 111 fi 112 113 exec ${DAEMONBIN} ${ARGS} 114end script 115