~bluetooth/bluez/vivid-phone-overlay

« back to all changes in this revision

Viewing changes to debian/bluez.bluetooth.init

  • Committer: Simon Fels
  • Date: 2015-09-11 09:01:46 UTC
  • Revision ID: morphis@gravedo.de-20150911090146-4c0ln9s7ec3xf0nx
Import package bluez_4.101-0ubuntu25.1~overlay4 from stable phone overlay PPA

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
### BEGIN INIT INFO
 
3
# Provides: bluetooth
 
4
# Required-Start:    $local_fs $syslog $remote_fs dbus
 
5
# Required-Stop:     $local_fs $syslog $remote_fs
 
6
# Default-Start:     2 3 4 5
 
7
# Default-Stop:      0 1 6
 
8
# Short-Description: Start bluetooth daemons
 
9
### END INIT INFO
 
10
#
 
11
# bluez    Bluetooth subsystem starting and stopping
 
12
#
 
13
# originally from bluez's scripts/bluetooth.init
 
14
#
 
15
# Edd Dumbill <ejad@debian.org>
 
16
# LSB 3.0 compilance and enhancements by Filippo Giunchedi <filippo@debian.org>
 
17
#
 
18
# Updated for bluez 4.7 by Mario Limonciello <mario_limonciello@dell.com>
 
19
#
 
20
# Note: older daemons like dund pand hidd are now shipped inside the
 
21
# bluez-compat package
 
22
 
 
23
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
24
DESC=bluetooth
 
25
 
 
26
DAEMON=/usr/sbin/bluetoothd
 
27
HCIATTACH=/usr/sbin/hciattach
 
28
 
 
29
HID2HCI_ENABLED=1
 
30
HID2HCI_UNDO=1
 
31
 
 
32
UART_CONF=/etc/bluetooth/uart
 
33
 
 
34
RFCOMM_NAME=rfcomm
 
35
RFCOMM=/usr/bin/$RFCOMM_NAME
 
36
RFCOMM_CONF=/etc/bluetooth/$RFCOMM_NAME.conf
 
37
SDPTOOL=/usr/bin/sdptool
 
38
 
 
39
SSD_OPTIONS="--oknodo --quiet --exec $DAEMON"
 
40
 
 
41
test -f $DAEMON || exit 0
 
42
 
 
43
# FIXME: any of the sourced files may fail if/with syntax errors
 
44
test -f /etc/default/bluetooth && . /etc/default/bluetooth
 
45
test -f /etc/default/rcS && . /etc/default/rcS
 
46
 
 
47
. /lib/lsb/init-functions
 
48
 
 
49
set -e
 
50
 
 
51
# FIXME: this function is possibly a no-op
 
52
run_sdptool()
 
53
{
 
54
        # declaring IFS local in this function, removes the need to
 
55
        # save/restore it
 
56
        local IFS o
 
57
 
 
58
        test -x $SDPTOOL || return 1
 
59
 
 
60
# FIXME: where does SDPTOOL_OPTIONS come from?
 
61
        if ! test -z "$SDPTOOL_OPTIONS" ; then
 
62
                IFS=";"
 
63
                for o in $SDPTOOL_OPTIONS ; do
 
64
                        #echo "execing $SDPTOOL $o"
 
65
                        IFS=" "
 
66
                        if [ "$VERBOSE" != no ]; then
 
67
                                $SDPTOOL $o
 
68
                        else
 
69
                                $SDPTOOL $o >/dev/null 2>&1
 
70
                        fi
 
71
                done
 
72
        fi
 
73
}
 
74
 
 
75
hci_input()
 
76
{
 
77
    log_progress_msg "switching to HID/HCI no longer done in init script, see /usr/share/doc/bluez/NEWS.Debian.gz" || :
 
78
}
 
79
alias enable_hci_input=hci_input
 
80
alias disable_hci_input=hci_input
 
81
 
 
82
start_uarts()
 
83
{
 
84
        [ -f $HCIATTACH ] && [ -f $UART_CONF ] || return
 
85
        grep -v '^#' $UART_CONF | while read i; do
 
86
               if [ "$VERBOSE" != no ]; then
 
87
                       $HCIATTACH $i
 
88
               else
 
89
                       $HCIATTACH $i >/dev/null 2>&1
 
90
               fi
 
91
        done
 
92
}
 
93
 
 
94
stop_uarts()
 
95
{
 
96
        killall ${HCIATTACH##*/} >/dev/null 2>&1 || :
 
97
}
 
98
 
 
99
start_rfcomm()
 
100
{
 
101
        if [ -x $RFCOMM ] && [ -f $RFCOMM_CONF ] ; then
 
102
                # rfcomm must always succeed for now: users
 
103
                # may not yet have an rfcomm-enabled kernel
 
104
                if [ "$VERBOSE" != no ]; then
 
105
                       log_progress_msg "${RFCOMM##*/}"
 
106
                       $RFCOMM -f $RFCOMM_CONF bind all || :
 
107
                else
 
108
                       $RFCOMM -f $RFCOMM_CONF bind all >/dev/null 2>&1 || :
 
109
                fi
 
110
        fi
 
111
}
 
112
 
 
113
stop_rfcomm()
 
114
{
 
115
        if [ -x $RFCOMM ] ; then
 
116
               if [ "$VERBOSE" != no ]; then
 
117
                       log_progress_msg "${RFCOMM##*/}"
 
118
                       $RFCOMM unbind all || :
 
119
               else
 
120
                       $RFCOMM unbind all >/dev/null 2>&1 || :
 
121
               fi
 
122
        fi
 
123
}
 
124
 
 
125
restart_rfcomm()
 
126
{
 
127
        if [ -x $RFCOMM ] && [ -f $RFCOMM_CONF ] ; then
 
128
               if [ "$VERBOSE" != no ]; then
 
129
                       log_progress_msg  "${RFCOMM##*/}"
 
130
                       $RFCOMM unbind all || :
 
131
                       $RFCOMM -f $RFCOMM_CONF bind all || :
 
132
               else
 
133
                       $RFCOMM unbind all >/dev/null 2>&1|| :
 
134
                       $RFCOMM -f $RFCOMM_CONF bind all >/dev/null 2>&1 || :
 
135
               fi
 
136
        fi
 
137
}
 
138
 
 
139
case $1 in
 
140
  start)
 
141
        log_daemon_msg "Starting $DESC"
 
142
 
 
143
        if test "$BLUETOOTH_ENABLED" = 0; then
 
144
                log_progress_msg "disabled. see /etc/default/bluetooth"
 
145
                log_end_msg 0
 
146
                exit 0
 
147
        fi
 
148
 
 
149
        start-stop-daemon --start $SSD_OPTIONS
 
150
        log_progress_msg "${DAEMON##*/}"
 
151
 
 
152
        run_sdptool || :
 
153
 
 
154
        start_uarts || :
 
155
 
 
156
        if test "$HID2HCI_ENABLED" = 1; then
 
157
                enable_hci_input
 
158
        fi
 
159
        start_rfcomm || :
 
160
 
 
161
        if test "$HIDD_ENABLED" = 1 ||
 
162
                test "$PAND_ENABLED" = 1 || test "$DUND_ENABLED" = 1; then
 
163
                log_progress_msg "compatibily daemons not started, see bluez-compat package"
 
164
        fi
 
165
 
 
166
        log_end_msg 0
 
167
  ;;
 
168
  stop)
 
169
        log_daemon_msg "Stopping $DESC"
 
170
        if test "$BLUETOOTH_ENABLED" = 0; then
 
171
                log_progress_msg "disabled."
 
172
                log_end_msg 0
 
173
                exit 0
 
174
        fi
 
175
        stop_rfcomm || :
 
176
        if test "$HID2HCI_UNDO" = 1; then
 
177
                disable_hci_input
 
178
        fi
 
179
        start-stop-daemon --stop $SSD_OPTIONS
 
180
        log_progress_msg "${DAEMON}"
 
181
        stop_uarts || :
 
182
        log_end_msg 0
 
183
  ;;
 
184
  restart|force-reload)
 
185
        $0 stop
 
186
        sleep 1
 
187
        $0 start
 
188
  ;;
 
189
  status)
 
190
        status_of_proc "$DAEMON" "$DESC" && exit 0 || exit $?
 
191
  ;;
 
192
  *)
 
193
        N=/etc/init.d/bluetooth
 
194
        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
 
195
        exit 1
 
196
        ;;
 
197
esac
 
198
 
 
199
exit 0
 
200
 
 
201
# vim:noet