1326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu#
2326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# Copyright (C) 2014 The Android Open Source Project
3326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu#
4326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# Licensed under the Apache License, Version 2.0 (the "License");
5326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# you may not use this file except in compliance with the License.
6326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# You may obtain a copy of the License at
7326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu#
8326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu#      http://www.apache.org/licenses/LICENSE-2.0
9326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu#
10326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# Unless required by applicable law or agreed to in writing, software
11326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# distributed under the License is distributed on an "AS IS" BASIS,
12326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# See the License for the specific language governing permissions and
14326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu# limitations under the License.
15326b6cfba5ab73c9e41a7585d1bc95871631122aPeter Qiu#
161d047e7719ad36c8f0311780045f29654f0de275Peter Qiu
171d047e7719ad36c8f0311780045f29654f0de275Peter Qiudescription   "Run the access point manager daemon"
181d047e7719ad36c8f0311780045f29654f0de275Peter Qiuauthor        "chromium-os-dev@chromium.org"
191d047e7719ad36c8f0311780045f29654f0de275Peter Qiu
20ab53a1f85d1166d8d799e29886a16b1fff5acb6cAlex Vakulenkostart on stopped iptables and stopped ip6tables and started shill
211d047e7719ad36c8f0311780045f29654f0de275Peter Qiustop on stopping system-services
221d047e7719ad36c8f0311780045f29654f0de275Peter Qiu
231d047e7719ad36c8f0311780045f29654f0de275Peter Qiuenv APMANAGER_LOG_LEVEL=0
241d047e7719ad36c8f0311780045f29654f0de275Peter Qiu
25775173013ee886be244417eba0a3b302c4da11e0Peter Qiupre-start script
26020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu  # Load the module that provides the WiFi configuration API, since
27020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu  # apmanager will abort if that API is not available. In most cases,
28020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu  # cfg80211 will be loaded implicitly when the device driver is
29020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu  # loaded (in preload-network).  However, this deals with the
30020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu  # first-boot case, in case apmanager starts before the device driver is
31020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu  # loaded.
32020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu  modprobe cfg80211 ||
33020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu    logger -p err -t "$UPSTART_JOB" "Failed to load cfg80211"
34020e250642dcfc6e26b88b36dcdb382ed0148ce2Peter Qiu
35775173013ee886be244417eba0a3b302c4da11e0Peter Qiu  # Create directory for storing config files.
36775173013ee886be244417eba0a3b302c4da11e0Peter Qiu  mkdir -m 0755 -p /var/run/apmanager/hostapd
37775173013ee886be244417eba0a3b302c4da11e0Peter Qiu  mkdir -m 0755 -p /var/run/apmanager/dnsmasq
38775173013ee886be244417eba0a3b302c4da11e0Peter Qiu  chown -R apmanager:apmanager /var/run/apmanager/hostapd
39775173013ee886be244417eba0a3b302c4da11e0Peter Qiu  chown -R apmanager:apmanager /var/run/apmanager/dnsmasq
40775173013ee886be244417eba0a3b302c4da11e0Peter Qiuend script
41775173013ee886be244417eba0a3b302c4da11e0Peter Qiu
421d047e7719ad36c8f0311780045f29654f0de275Peter Qiuexec /usr/bin/apmanager --v="${APMANAGER_LOG_LEVEL}"
43