libretime/install_minimal/airtime-uninstall

67 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
#Check if root user
if [[ $EUID -ne 0 ]]; then
echo "Please run as root user."
exit 1
fi
options=$(getopt -o p -l purge -- "$@")
if [ $? -ne 0 ]; then
echo "only -p or --purge parameter allowed"
exit 1
fi
eval set -- "$options"
purge='f'
while true
do
case "$1" in
-p|--purge) purge='t'; shift;;
--) shift 1; break ;;
*) break ;;
esac
done
#Make 'purge' env variable available to sub bash script
export purge
rabbitmq_uninstall () {
RABBITMQ_VHOST="/airtime"
RABBITMQ_USER="airtime"
rabbitmqctl delete_vhost $RABBITMQ_VHOST
rabbitmqctl delete_user $RABBITMQ_USER
}
echo -e "\n******************************* Uninstall Begin ********************************"
# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=`readlink -f $0`
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=`dirname $SCRIPT`
rabbitmq_uninstall
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
#Uninitialize Airtime
$SCRIPTPATH/include/airtime-uninitialize.sh
#Remove Airtime files
$SCRIPTPATH/include/airtime-remove-files.sh
#Remove pypo user
python $SCRIPTPATH/../python_apps/remove-pypo-user.py
#deactivate virtualenv
deactivate
echo -e "\n****************************** Uninstall Complete *******************************\n"
echo "NOTE: To fully remove all Airtime files, you will also have to manually delete"
echo " the directories '/srv/airtime'(default storage location of media files)"
echo -e " and '/etc/airtime'(where the config files are stored).\n"