sintonia/uninstall

93 lines
2.5 KiB
Plaintext
Raw Normal View History

2021-08-16 17:44:19 +02:00
#!/usr/bin/env bash
set -e # Exit if any of the steps fails.
if [[ $EUID -ne 0 ]]; then
2021-08-16 13:45:32 +02:00
echo "Please run as root user."
exit 1
fi
getStorDirFromDatabase() {
2021-08-16 17:44:19 +02:00
sudo -u postgres psql -d airtime -tAc "SELECT directory FROM cc_music_dirs WHERE type='stor'"
}
2020-08-03 12:25:05 +02:00
dropLibreTimeDatabase() {
2021-08-16 17:44:19 +02:00
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"
}
2020-08-03 12:25:05 +02:00
removeRabbitmqLibreTimeSettings() {
2021-08-16 13:45:32 +02:00
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=(
2021-08-16 13:45:32 +02:00
"/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
2021-08-16 17:44:19 +02:00
echo "$i"
done
2020-01-16 15:32:51 +01:00
echo "pip3 airtime-playout"
echo -e "\nIf your web root is not listed, you will need to manually remove it."
2020-08-03 12:25:05 +02:00
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"
2021-08-16 17:44:19 +02:00
read -r IN
if [[ ! ($IN == "y" || $IN == "Y") ]]; then
2021-08-16 13:45:32 +02:00
exit 0
fi
2015-01-15 19:52:12 +01:00
if [ -n "${STOR_DIR}" ]; then
2021-08-16 13:45:32 +02:00
echo -e "\nDo you want to remove your music storage directory ${STOR_DIR} and all of its subdirectories? [y/N]: \c"
2021-08-16 17:44:19 +02:00
read -r IN
if [[ $IN == "y" || $IN == "Y" ]]; then
2021-08-16 13:45:32 +02:00
rm -rf "${STOR_DIR}"
fi
else
2021-08-16 13:45:32 +02:00
echo -e "\nNo stor directory found, skipping..."
fi
2020-08-03 12:25:05 +02:00
echo -e "\nUninstalling LibreTime..."
systemctl stop libretime-celery
set +e
2020-08-03 12:25:05 +02:00
removeRabbitmqLibreTimeSettings
set -e
for i in ${FILES[*]}; do
2021-08-16 17:44:19 +02:00
rm -rf "$i"
done
2020-08-03 12:25:05 +02:00
echo -e "\nDo you want to drop your current LibreTime database? [y/N]: \c"
2021-08-16 17:44:19 +02:00
read -r IN
if [[ $IN == "y" || $IN == "Y" ]]; then
2021-08-16 13:45:32 +02:00
echo -e "\nDropping LibreTime database..."
dropLibreTimeDatabase
fi
2020-01-16 15:32:51 +01:00
pip3 uninstall -y airtime-playout airtime-media-monitor airtime-analyzer
service apache2 restart
echo "...Done"