bluetooth/bluez/bluetooth

Tue, 06 Aug 2019 20:34:00 +0200

author
David Demelier <markand@malikania.fr>
date
Tue, 06 Aug 2019 20:34:00 +0200
changeset 737
24249b89d047
child 1026
3dfef64b81c1
permissions
-rwxr-xr-x

bluetooth/bluez: initial import, closes #1216

737
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 #!/bin/sh
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 #
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 # /etc/rc.d/bluetooth -- run control script for bluetooth
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 #
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 # Copyright (c) 2019 David Demelier <markand@malikania.fr>
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 #
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 # Permission to use, copy, modify, and/or distribute this software for any
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 # purpose with or without fee is hereby granted, provided that the above
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 # copyright notice and this permission notice appear in all copies.
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 #
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
18 #
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
19
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
20 if [ -f /etc/rc.conf ]; then
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
21 . /etc/rc.conf
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 fi
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
23
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
24 : ${BLUETOOTH_CMD:=/libexec/bluetooth/bluetoothd}
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
25 : ${BLUETOOTH_ARGS:=}
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
26 : ${BLUETOOTH_PID:=/var/run/bluetooth.pid}
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
27
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
28 bluetooth_start()
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
29 {
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
30 if [ -s $BLUETOOTH_PID ]; then
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
31 echo "bluetooth is already running with pid: $(cat $BLUETOOTH_PID)"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
32 exit 1
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
33 fi
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
34
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 echo "Starting bluetooth: $BLUETOOTH_CMD $BLUETOOTH_ARGS"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 start-stop-daemon -Sbvp $BLUETOOTH_PID -x $BLUETOOTH_CMD -- $BLUETOOTH_ARGS
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 }
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
38
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 bluetooth_status()
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 {
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 if [ -s $BLUETOOTH_PID ]; then
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 echo "bluetooth is running with pid: $(cat $BLUETOOTH_PID)"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 else
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 echo "bluetooth is not running"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
45 fi
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
46 }
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
47
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 bluetooth_stop()
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 {
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 if [ -s $BLUETOOTH_PID ]; then
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 echo "Stopping bluetooth."
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 start-stop-daemon -Kp $BLUETOOTH_PID
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 fi
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 }
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
55
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 bluetooth_restart()
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 {
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
58 bluetooth_stop
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 sleep 3
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
60 bluetooth_start
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
61 }
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
62
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
63 case $1 in
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 start)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
65 bluetooth_start
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 status)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
68 bluetooth_status
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
70 stop)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
71 bluetooth_stop
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 restart)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 bluetooth_restart
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
75 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 *)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 echo "usage: $(basename $0) restart|start|status|stop"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
79 esac

mercurial