-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathuninstall.sh
executable file
·46 lines (37 loc) · 1.45 KB
/
uninstall.sh
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
#!/bin/sh
###########################################################################################
# This script removes the MBP application and un-registers the corresponding service. #
# It can also be used to uninstall mosquitto and MongoDB. #
###########################################################################################
# Config
TARGET_DIR="/usr/local/bin/MBP"
SERVICE_NAME="mbp"
echo "This will uninstall the MBP from your device."
read -n1 -p "Do you also want to uninstall MongoDB? [y,n]" un_mongo
echo ""
read -n1 -p "Do you also want to uninstall mosquitto? [y,n]" un_mosquitto
echo ""
echo "Stopping the MBP application..."
sudo systemctl stop $SERVICE_NAME
echo "Removing the MBP application..."
sudo rm -rf $TARGET_DIR
echo "Unregistering service..."
sudo rm /etc/systemd/system/${SERVICE_NAME}.service
sudo systemctl daemon-reload
# Uninstall MongoDB if desired
if [[ $un_mongo == "Y" || $un_mongo == "y" ]]; then
echo "Uninstalling MongoDB..."
sudo systemctl stop mongodb
sudo apt-get remove -qy mongodb-server
sudo apt purge -qy mongodb-server
sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb
fi
# Uninstall mosquitto if desired
if [[ $un_mosquitto == "Y" || $un_mosquitto == "y" ]]; then
echo "Uninstalling mosquitto..."
sudo systemctl stop mosquitto
sudo apt-get remove -qy mosquitto
sudo apt purge -qy mosquitto
fi
echo "Uninstalled the MBP and related components SUCCESSFULLY!"