op_bluetooth: Added security fixes
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_bluetooth.sh
1 #!/bin/sh
2 #
3 # Released under the GPL
4
5 INTERFACE="`hciconfig | grep "^hci" | cut -d ':' -f 1`"
6 LOCK="~/.op_btenabled"
7
8 if [ $1 = "startup" ]; then
9         [ -f "$LOCK" ] && sudo /usr/sbin/hciconfig "$INTERFACE" up pscan 1>/dev/null && sudo /usr/sbin/bluetoothd || echo "Bluetooth: User has not enabled Bluetooth." 
10
11 else
12         
13         # Figure out if Bluetooth is running or not
14         
15         if hciconfig "$INTERFACE" | grep UP &>/dev/null
16         then
17                 notify-send -u normal "Bluetooth" "Bluetooth is being disabled..." -i blueman -t 5000
18                 sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
19                 rm -f "$LOCK"
20         else
21                 pgrep bluetoothd
22                 echo $INTERFACE
23                 if [ $? -ne 1 ]; then
24                         notify-send -u normal "Bluetooth" "Bluetooth is being enabled..." -i blueman -t 5000
25                         sudo /usr/sbin/hciconfig ${INTERFACE} down 1>/dev/null
26                         sudo /usr/sbin/hciconfig ${INTERFACE} up pscan 1>/dev/null
27                         sudo /usr/sbin/bluetoothd 1>/dev/null
28                         touch "$LOCK"
29
30                 fi
31         fi
32 fi