bluez-utils: sdpd is no longer a separate daemon.
[openwrt/svn-archive/archive.git] / utils / bluez-utils / files / bluez-utils.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2007 OpenWrt.org
3
4 #start after dbus (60)
5 START=62
6
7 append_bool() {
8 local section="$1"
9 local option="$2"
10 local value="$3"
11 local _val
12 config_get_bool _val "$section" "$option" '0'
13 [ "$_val" -gt 0 ] && append args "$3"
14 }
15
16 append_string() {
17 local section="$1"
18 local option="$2"
19 local value="$3"
20 local _val
21 config_get _val "$section" "$option"
22 [ -n "$_val" ] && append args "$3 $_val"
23 }
24
25 hcid_config() {
26 local cfg="$1"
27 args=""
28 append_bool "$cfg" nodaemon "-n"
29 append_string "$cfg" config "-f"
30 config_get_bool enabled "$cfg" "enabled" '1'
31 [ "$enabled" -gt 0 ] && /usr/sbin/hcid $args
32 }
33
34 rfcomm_config() {
35 local cfg="$1"
36 args=""
37 append_string "$cfg" config "-f"
38 config_get_bool enabled "$cfg" "enabled" '1'
39 [ "$enabled" -gt 0 ] && /usr/bin/rfcomm $args bind all
40 }
41
42 dund_config() {
43 local cfg="$1"
44 args=""
45 append_bool "$cfg" listen "--listen"
46 append_string "$cfg" connect "--connect"
47 append_string "$cfg" mrouter "--mrouter"
48 append_bool "$cfg" search "--search"
49 append_string "$cfg" channel "--channel"
50 append_string "$cfg" device "--device"
51 append_bool "$cfg" nosdp "--nosdp"
52 append_bool "$cfg" auth "--auth"
53 append_bool "$cfg" encrypt "--encrypt"
54 append_bool "$cfg" secure "--secure"
55 append_bool "$cfg" master "--master"
56 append_bool "$cfg" nodetach "--nodetach"
57 append_bool "$cfg" persist "--persist"
58 append_string "$cfg" pppd "--pppd"
59 append_bool "$cfg" msdun "--msdun"
60 append_bool "$cfg" activesync "--activesync"
61 append_bool "$cfg" cache "--cache"
62
63 append_string "$cfg" pppdopts ""
64 config_get_bool enabled "$cfg" "enabled" '1'
65 [ "$enabled" -gt 0 ] && /usr/bin/dund $args
66 }
67
68 pand_config() {
69 local cfg="$1"
70 args=""
71 append_bool "$cfg" listen "--listen"
72 append_string "$cfg" connect "--connect"
73 append_bool "$cfg" autozap "--autozap"
74 append_bool "$cfg" search "--search"
75 append_string "$cfg" role "--role"
76 append_string "$cfg" service "--service"
77 append_string "$cfg" ethernet "--ethernet"
78 append_string "$cfg" device "--device"
79 append_bool "$cfg" nosdp "-D"
80 append_bool "$cfg" auth "-A"
81 append_bool "$cfg" encrypt "-E"
82 append_bool "$cfg" secure "-S"
83 append_bool "$cfg" master "-M"
84 append_bool "$cfg" nodetach "-n"
85 append_bool "$cfg" persist "--persist"
86 append_bool "$cfg" cache "--cache"
87 append_string "$cfg" pidfile "--pidfile"
88 config_get_bool enabled "$cfg" "enabled" '1'
89 [ "$enabled" -gt 0 ] && /usr/bin/pand $args
90 }
91
92 start() {
93 include /lib/network
94 scan_interfaces
95 config_load bluetooth
96
97 config_foreach hcid_config hcid
98 config_foreach rfcomm_config rfcomm
99 config_foreach dund_config dund
100 config_foreach pand_config pand
101 }
102
103 stop() {
104 killall dund
105 killall pand
106 /usr/bin/rfcomm release all
107 killall hcid
108 }