forked from respeaker/seeed-voicecard
-
Notifications
You must be signed in to change notification settings - Fork 7
/
uninstall.sh
executable file
·89 lines (75 loc) · 2.23 KB
/
uninstall.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (use sudo)" 1>&2
exit 1
fi
is_Raspberry=$(cat /proc/device-tree/model | awk '{print $1}')
if [ "x${is_Raspberry}" != "xRaspberry" ] ; then
echo "Sorry, this drivers only works on raspberry pi"
exit 1
fi
uname_r=$(uname -r)
CONFIG=/boot/config.txt
get_overlay() {
ov=$1
if grep -q -E "^dtoverlay=$ov" $CONFIG; then
echo 0
else
echo 1
fi
}
do_overlay() {
ov=$1
RET=$2
DEFAULT=--defaultno
CURRENT=0
if [ $(get_overlay $ov) -eq 0 ]; then
DEFAULT=
CURRENT=1
fi
if [ $RET -eq $CURRENT ]; then
ASK_TO_REBOOT=1
fi
if [ $RET -eq 0 ]; then
sed $CONFIG -i -e "s/^#dtoverlay=$ov/dtoverlay=$ov/"
if ! grep -q -E "^dtoverlay=$ov" $CONFIG; then
printf "dtoverlay=$ov\n" >> $CONFIG
fi
STATUS=enabled
elif [ $RET -eq 1 ]; then
sed $CONFIG -i -e "s/^dtoverlay=$ov/#dtoverlay=$ov/"
STATUS=disabled
else
return $RET
fi
}
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
echo "remove dtbos"
for i in $RPI_HATS; do
dtoverlay -r $i
done
rm /boot/overlays/seeed-2mic-voicecard.dtbo || true
rm /boot/overlays/seeed-4mic-voicecard.dtbo || true
rm /boot/overlays/seeed-8mic-voicecard.dtbo || true
echo "remove alsa configs"
rm -rf /etc/voicecard/ || true
echo "disabled seeed-voicecard.service "
systemctl disable seeed-voicecard.service
echo "remove seeed-voicecard"
rm /usr/bin/seeed-voicecard || true
rm /lib/systemd/system/seeed-voicecard.service || true
echo "remove dkms"
rm -rf /var/lib/dkms/seeed-voicecard || true
echo "remove kernel modules"
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-wm8960.ko || true
rm /lib/modules/${uname_r}/kernel/sound/soc/codecs/snd-soc-ac108.ko || true
rm /lib/modules/${uname_r}/kernel/sound/soc/bcm/snd-soc-seeed-voicecard.ko || true
echo "remove $CONFIG configuration"
for i in $RPI_HATS; do
echo Uninstall $i ...
do_overlay $i 1
done
echo "------------------------------------------------------"
echo "Please reboot your raspberry pi to apply all settings"
echo "Thank you!"
echo "------------------------------------------------------"