forked from yesimxev/badbt
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathswapsvc
More file actions
executable file
·46 lines (36 loc) · 1023 Bytes
/
swapsvc
File metadata and controls
executable file
·46 lines (36 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
svc='/usr/lib/systemd/system/bluetooth.service'
CONF="/etc/bluetooth/main.conf"
PROP="JustWorksRepairing"
VALUE="always"
REGEX="^[[:space:]]*#?[[:space:]]*${PROP}[[:space:]]*="
[ `id -u` -ne 0 ] && echo '[!]Run as root' && exit
if [ -f bluetooth.service.bk ]
then
echo "[*]Restore stock ${svc} file"
mv bluetooth.service.bk $svc
else
echo "[*]Backup stock and place badbt ${svc} file"
cp $svc bluetooth.service.bk
cp bluetooth.service $svc
fi
# Fix JustWorksRepairing in /etc/bluetooth/main.conf
if [ -f main.conf.bk ]
then
echo "[*]Restore stock ${CONF} file"
mv main.conf.bk $CONF
else
echo "[*]Backup stock ${CONF} file"
cp $CONF main.conf.bk
if grep -Eq "$REGEX" "$CONF"
then
echo "[*]Replace ${PROP} as ${VALUE} in ${CONF} file"
sed -i -E "s|${REGEX}.*|${PROP} = ${VALUE}|" "$CONF"
else
echo "[*]${PROP} not found, appending at end…"
echo "${PROP} = ${VALUE}" >> "$CONF"
fi
fi
echo "[*]Daemon reload and restart ${svc}"
systemctl daemon-reload
systemctl restart bluetooth