2015-01-12 22:13:39 +01:00
|
|
|
#!/bin/bash -e
|
2015-01-13 18:28:36 +01:00
|
|
|
# -e Causes bash script to exit if any of the steps
|
|
|
|
# return with a non-zero return value.
|
2015-01-12 22:13:39 +01:00
|
|
|
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "Please run as root user."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-01-13 18:28:36 +01:00
|
|
|
getStorDirFromDatabase() {
|
|
|
|
# here-doc to execute this block as postgres user
|
2015-01-13 21:50:01 +01:00
|
|
|
result=`su postgres <<'EOF'
|
2015-01-13 18:28:36 +01:00
|
|
|
set +e
|
2015-01-13 21:50:01 +01:00
|
|
|
echo $(psql -d airtime -tAc "SELECT directory FROM cc_music_dirs WHERE type='stor'")
|
2015-01-13 18:28:36 +01:00
|
|
|
set -e
|
|
|
|
# don't indent this!
|
2015-01-13 21:50:01 +01:00
|
|
|
EOF`
|
2015-01-13 18:28:36 +01:00
|
|
|
echo $result
|
|
|
|
}
|
|
|
|
|
|
|
|
dropAirtimeDatabase() {
|
|
|
|
# here-doc to execute this block as postgres user
|
|
|
|
su postgres <<'EOF'
|
|
|
|
set +e
|
2015-01-13 21:50:01 +01:00
|
|
|
# DROP DATABASE cannot be executed from a function or multi-command string
|
2015-06-24 01:02:55 +02:00
|
|
|
psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime_test"
|
2015-01-13 21:50:01 +01:00
|
|
|
psql -d postgres -tAc "DROP DATABASE IF EXISTS airtime"
|
|
|
|
psql -d postgres -tAc "DROP USER IF EXISTS airtime"
|
2015-01-13 18:28:36 +01:00
|
|
|
set -e
|
|
|
|
# don't indent this!
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2015-01-15 16:12:52 +01:00
|
|
|
removeRabbitmqAirtimeSettings() {
|
2015-01-15 23:33:47 +01: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
|
2015-01-15 16:12:52 +01:00
|
|
|
|
|
|
|
rabbitmqctl delete_vhost ${RMQ_VHOST}
|
|
|
|
rabbitmqctl delete_user ${RMQ_USER}
|
|
|
|
}
|
|
|
|
|
2015-01-12 22:13:39 +01:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
|
|
|
|
AIRTIMEROOT=${SCRIPT_DIR}
|
|
|
|
|
2015-01-13 18:28:36 +01:00
|
|
|
STOR_DIR=$(getStorDirFromDatabase)
|
|
|
|
|
2015-01-12 22:13:39 +01:00
|
|
|
FILES=(
|
|
|
|
"/etc/airtime"
|
|
|
|
"/var/log/airtime"
|
|
|
|
"/usr/lib/airtime"
|
|
|
|
"/usr/share/airtime"
|
|
|
|
"/etc/init/airtime*"
|
2015-02-24 17:05:28 +01:00
|
|
|
"/usr/local/bin/airtime-*"
|
2015-01-12 22:13:39 +01:00
|
|
|
"/usr/bin/airtime*"
|
|
|
|
"/etc/apache2/sites-available/airtime*"
|
2015-01-15 22:33:33 +01:00
|
|
|
"/etc/apache2/sites-enabled/airtime*"
|
2015-01-12 22:13:39 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
echo -e "The following files, directories, and services will be removed:\n"
|
|
|
|
for i in ${FILES[*]}; do
|
|
|
|
echo $i
|
|
|
|
done
|
2015-01-15 22:33:33 +01:00
|
|
|
echo "pip airtime-playout"
|
|
|
|
|
2015-01-14 22:53:19 +01:00
|
|
|
echo -e "\nIf your web root is not listed, you will need to manually remove it."
|
2015-01-12 22:13:39 +01:00
|
|
|
|
2015-01-13 18:28:36 +01:00
|
|
|
echo -e "\nThis will *permanently* remove Airtime and all related files from your computer. \
|
2015-03-25 17:03:01 +01:00
|
|
|
Any files in Airtime directories and subdirectories will be deleted. Are you sure you want to proceed? [y/N]: \c"
|
2015-01-12 22:13:39 +01:00
|
|
|
read IN
|
|
|
|
if [[ ! ( "$IN" = "y" || "$IN" = "Y" ) ]]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-01-15 19:52:12 +01:00
|
|
|
if [ -n "${STOR_DIR}" ]; then
|
2015-03-25 17:03:01 +01:00
|
|
|
echo -e "\nDo you want to remove your music storage directory ${STOR_DIR} and all of its subdirectories? [y/N]: \c"
|
2015-01-15 16:12:52 +01:00
|
|
|
read IN
|
2015-03-25 17:03:01 +01:00
|
|
|
if [[ ( "$IN" = "y" || "$IN" = "Y" ) ]]; then
|
2015-04-08 00:56:22 +02:00
|
|
|
rm -rf "${STOR_DIR}"
|
2015-01-15 16:12:52 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo -e "\nNo stor directory found, skipping..."
|
2015-01-13 18:28:36 +01:00
|
|
|
fi
|
|
|
|
|
2015-01-15 16:12:52 +01:00
|
|
|
echo -e "\nUninstalling Airtime..."
|
2015-06-24 01:02:55 +02:00
|
|
|
service airtime-celery stop
|
|
|
|
set +e
|
2015-01-15 23:33:47 +01:00
|
|
|
removeRabbitmqAirtimeSettings
|
2015-06-24 01:02:55 +02:00
|
|
|
set -e
|
2015-01-15 16:12:52 +01:00
|
|
|
|
2015-01-15 22:33:33 +01:00
|
|
|
for i in ${FILES[*]}; do
|
|
|
|
rm -rf $i
|
|
|
|
done
|
2015-01-12 22:13:39 +01:00
|
|
|
|
2015-03-25 17:03:01 +01:00
|
|
|
echo -e "\nDo you want to drop your current Airtime database? [y/N]: \c"
|
2015-01-15 22:33:33 +01:00
|
|
|
read IN
|
|
|
|
if [[ "$IN" = "y" || "$IN" = "Y" ]]; then
|
|
|
|
echo -e "\nDropping Airtime database..."
|
|
|
|
dropAirtimeDatabase
|
|
|
|
fi
|
2015-01-13 18:28:36 +01:00
|
|
|
|
2018-01-24 08:20:51 +01:00
|
|
|
pip uninstall -y airtime-playout airtime-media-monitor airtime-analyzer
|
2015-01-15 22:33:33 +01:00
|
|
|
service apache2 restart
|
2015-04-08 00:56:22 +02:00
|
|
|
echo "...Done"
|