forked from Nachtzuster/BirdNET-Pi
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·60 lines (54 loc) · 1.65 KB
/
uninstall.sh
File metadata and controls
executable file
·60 lines (54 loc) · 1.65 KB
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
#!/usr/bin/env bash
# Uninstall script to remove everything
#set -x # Uncomment to debug
trap 'rm -f ${TMPFILE}' EXIT
my_dir=$HOME/BirdNET-Pi/scripts
source /etc/birdnet/birdnet.conf &> /dev/null
SCRIPTS=($(ls -1 ${my_dir}) ${HOME}/.gotty)
set -x
TMP_MOUNT=$(systemd-escape -p --suffix=mount "$RECS_DIR/StreamData")
services=($(awk '/service/ && /systemctl/ && !/php/ {print $3}' ${my_dir}/install_services.sh | sort) custom_recording.service avahi-alias@.service $TMP_MOUNT)
remove_services() {
for i in "${services[@]}"; do
if [ -L /etc/systemd/system/multi-user.target.wants/"${i}" ];then
sudo systemctl disable --now "${i}"
fi
if [ -L /lib/systemd/system/"${i}" ];then
sudo rm -f /lib/systemd/system/$i
fi
if [ -f /etc/systemd/system/"${i}" ];then
sudo rm /etc/systemd/system/"${i}"
fi
if [ -d /etc/systemd/system/"${i}" ];then
sudo rm -drf /etc/systemd/system/"${i}"
fi
done
set +x
remove_icecast
remove_crons
remove_avahi_services
}
remove_avahi_services() {
sudo rm -v "/etc/avahi/services/http.service"
}
remove_crons() {
sudo sed -i '/birdnet/,+1d' /etc/crontab
}
remove_icecast() {
if [ -f /etc/init.d/icecast2 ];then
sudo /etc/init.d/icecast2 stop
sudo systemctl disable --now icecast2
fi
}
remove_scripts() {
for i in "${SCRIPTS[@]}";do
if [ -L "/usr/local/bin/${i}" ];then
sudo rm -v "/usr/local/bin/${i}"
fi
done
}
remove_services
remove_scripts
if [ -d /etc/birdnet ];then sudo rm -drf /etc/birdnet;fi
if [ -f ${HOME}/BirdNET-Pi/birdnet.conf ];then sudo rm -f ${HOME}/BirdNET-Pi/birdnet.conf;fi
echo "Uninstall finished. Remove this directory with 'rm -drfv' to finish."