1#!/bin/sh /etc/rc.common
2#
3# Copyright (c) 2015, The Linux Foundation. All rights reserved.
4#
5#  Permission to use, copy, modify, and/or distribute this software for any
6#  purpose with or without fee is hereby granted, provided that the above
7#  copyright notice and this permission notice appear in all copies.
8#
9#  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10#  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11#  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12#  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13#  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14#  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15#  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17START=
18SERVICE_DAEMONIZE=1
19SERVICE_WRITE_PID=1
20SERVICE_PATH="/usr/sbin/ssidsteering"
21
22start () {
23	config_load ssid-steering
24
25	local enable
26	config_get_bool enable global enable 0
27	[ "${enable}" -gt 0 ] || return
28
29	config_get private_vaps global private_vaps
30	config_get public_vaps global public_vaps
31
32	cat > /etc/config/ssid-steering.conf <<EOF
33	private=$private_vaps
34	public=$public_vaps
35EOF
36
37	service_start ${SERVICE_PATH} -C /etc/config/ssid-steering.conf
38}
39
40stop() {
41	service_stop /usr/sbin/ssidsteering
42
43	# Workaround, sometimes service_stop does not kill ssidsteering
44        start-stop-daemon -K -x ${SERVICE_PATH} -s SIGTERM > /dev/null
45}
46