forked from libretime/libretime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall
executable file
·92 lines (76 loc) · 2.49 KB
/
uninstall
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
90
91
92
#!/usr/bin/env bash
set -e # Exit if any of the steps fails.
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
fi
getStorDirFromDatabase() {
sudo -u postgres psql -d airtime -tAc "SELECT directory FROM cc_music_dirs WHERE type='stor'"
}
dropLibreTimeDatabase() {
sudo -u postgres psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime_test"
sudo -u postgres psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime"
sudo -u postgres psql -d postgres -tAc "DROP USER IF EXISTS airtime"
}
removeRabbitmqLibreTimeSettings() {
if [ -f /etc/airtime/airtime.conf ]; then
RMQ_VHOST=$(awk -F ' = ' '{if (! ($0 ~ /^;/) && $0 ~ /^vhost/ ) print $2}' /etc/airtime/airtime.conf)
RMQ_USER=$(awk -F ' = ' '{if (! ($0 ~ /^;/) && $0 ~ /^user/ ) print $2}' /etc/airtime/airtime.conf)
else
RMQ_VHOST=/airtime
RMQ_USER=airtime
fi
rabbitmqctl delete_vhost ${RMQ_VHOST}
rabbitmqctl delete_user ${RMQ_USER}
}
STOR_DIR=$(getStorDirFromDatabase)
FILES=(
"/etc/airtime"
"/var/log/airtime"
"/usr/lib/airtime"
"/usr/share/airtime"
"/etc/init/airtime*"
"/etc/systemd/system/libretime*"
"/usr/local/bin/airtime-*"
"/usr/bin/airtime*"
"/etc/apache2/sites-available/airtime*"
"/etc/apache2/sites-enabled/airtime*"
)
echo -e "The following files, directories, and services will be removed:\n"
for i in "${FILES[@]}"; do
echo "$i"
done
echo "pip3 libretime-playout"
echo -e "\nIf your web root is not listed, you will need to manually remove it."
echo -e "\nThis will *permanently* remove LibreTime and all related files from your computer. \
Any files in LibreTime directories and subdirectories will be deleted. Are you sure you want to proceed? [y/N]: \c"
read -r IN
if [[ ! ($IN == "y" || $IN == "Y") ]]; then
exit 0
fi
if [ -n "${STOR_DIR}" ]; then
echo -e "\nDo you want to remove your music storage directory ${STOR_DIR} and all of its subdirectories? [y/N]: \c"
read -r IN
if [[ $IN == "y" || $IN == "Y" ]]; then
rm -rf "${STOR_DIR}"
fi
else
echo -e "\nNo stor directory found, skipping..."
fi
echo -e "\nUninstalling LibreTime..."
systemctl stop libretime-celery
set +e
removeRabbitmqLibreTimeSettings
set -e
for i in "${FILES[@]}"; do
rm -rf "$i"
done
echo -e "\nDo you want to drop your current LibreTime database? [y/N]: \c"
read -r IN
if [[ $IN == "y" || $IN == "Y" ]]; then
echo -e "\nDropping LibreTime database..."
dropLibreTimeDatabase
fi
pip3 uninstall -y libretime-playout airtime-media-monitor airtime-analyzer
service apache2 restart
echo "...Done"