bluetooth/bluez/bluetooth

Fri, 15 Nov 2019 20:11:00 +0100

author
David Demelier <markand@malikania.fr>
date
Fri, 15 Nov 2019 20:11:00 +0100
changeset 1210
422313c3fcbd
parent 1026
3dfef64b81c1
permissions
-rwxr-xr-x

text/rarian: initial import, closes #2311

1026
3dfef64b81c1 vanilla: update all init scripts
David Demelier <markand@malikania.fr>
parents: 737
diff changeset
1 #!/bin/busybox sh
737
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)"
1026
3dfef64b81c1 vanilla: update all init scripts
David Demelier <markand@malikania.fr>
parents: 737
diff changeset
32 else
3dfef64b81c1 vanilla: update all init scripts
David Demelier <markand@malikania.fr>
parents: 737
diff changeset
33 echo "Starting bluetooth: $BLUETOOTH_CMD $BLUETOOTH_ARGS"
3dfef64b81c1 vanilla: update all init scripts
David Demelier <markand@malikania.fr>
parents: 737
diff changeset
34 start-stop-daemon -Sbvp $BLUETOOTH_PID -x $BLUETOOTH_CMD -- $BLUETOOTH_ARGS
737
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 fi
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 }
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 bluetooth_status()
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 {
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 if [ -s $BLUETOOTH_PID ]; then
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 echo "bluetooth is running with pid: $(cat $BLUETOOTH_PID)"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 else
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 echo "bluetooth is not running"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 fi
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
45 }
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 bluetooth_stop()
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
48 {
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 if [ -s $BLUETOOTH_PID ]; then
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 echo "Stopping bluetooth."
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 start-stop-daemon -Kp $BLUETOOTH_PID
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 fi
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 }
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 bluetooth_restart()
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 {
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 bluetooth_stop
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
58 sleep 3
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 bluetooth_start
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
60 }
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 case $1 in
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
63 start)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 bluetooth_start
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
65 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 status)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 bluetooth_status
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
68 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 stop)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
70 bluetooth_stop
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
71 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 restart)
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 bluetooth_restart
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 ;;
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 echo "usage: $(basename $0) restart|start|status|stop"
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
77 ;;
24249b89d047 bluetooth/bluez: initial import, closes #1216
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 esac

mercurial