quick-jibri-installer/tools/start-over.sh

145 lines
3.4 KiB
Bash
Raw Normal View History

#!/bin/bash
#Start over
2023-11-08 06:34:51 +00:00
# SwITNet Ltd © - 2023, https://switnet.net/
2021-05-04 05:37:08 +00:00
# GPLv3 or later.
while getopts m: option
do
case "${option}"
in
m) MODE=${OPTARG};;
\?) echo "Usage: sudo bash ./$0 [-m debug]" && exit;;
esac
done
#DEBUG
if [ "$MODE" = "debug" ]; then
set -x
fi
#Check if user is root
if ! [ "$(id -u)" = 0 ]; then
echo "You need to be root or have sudo privileges!"
exit 0
fi
wait_seconds() {
secs=$(($1))
while [ $secs -gt 0 ]; do
echo -ne "$secs\033[0K\r"
sleep 1
: $((secs--))
done
}
2021-05-06 06:08:25 +00:00
remove_residuals() {
if [ -d "$1" ]; then
rm -r "$1"
2021-05-06 06:08:25 +00:00
fi
}
purge_debconf() {
echo PURGE | debconf-communicate "$1"
}
2021-05-06 06:08:25 +00:00
remove_services() {
systemctl disable "$1"
systemctl stop "$1"
2021-05-06 06:08:25 +00:00
}
echo -e '
########################################################################
Welcome to the Start Over cleaner script
########################################################################
by Software, IT & Networks Ltd
\n'
SYNC_USER="$(find /home -maxdepth 1 -type d |awk '/jbsync/{print}')"
DOMAIN="$(find /etc/prosody/conf.d/ -name \*.lua|awk -F'.cfg' '!/localhost/{print $1}'|xargs basename)"
2021-05-22 20:50:42 +00:00
echo "We are about to remove and clean all the jitsi-meet platform bits and pieces...
Please make sure you have backed up anything you don't want to loose."
echo "
# WARGNING #: This is only recommended if you want to start over a failed installation,
or plain and simple remove jitsi from your system."
while [[ "$CONTINUE_PURGE1" != "yes" && "$CONTINUE_PURGE1" != "no" ]]
do
read -p "> Do you want to continue?: (yes or no)"$'\n' -r CONTINUE_PURGE1
if [ "$CONTINUE_PURGE1" = "no" ]; then
echo " Good, see you next time..."
exit
elif [ "$CONTINUE_PURGE1" = "yes" ]; then
echo ""
fi
done
echo "Let me ask just one more time..."
while [[ "$CONTINUE_PURGE2" != "yes" && "$CONTINUE_PURGE2" != "no" ]]
do
read -p "> Do you want to continue?: (yes or no)"$'\n' -r CONTINUE_PURGE2
if [ "$CONTINUE_PURGE2" = "no" ]; then
echo " Good, see you next time..."
exit
elif [ "$CONTINUE_PURGE2" = "yes" ]; then
echo "No going back, let's start..."
wait_seconds 10
fi
done
#Purging all jitsi meet packages
apt-get -y purge jibri \
jicofo \
jigasi \
jitsi-meet \
jitsi-meet-web \
jitsi-meet-web-config \
jitsi-meet-prosody \
jitsi-meet-turnserver \
jitsi-videobridge2 \
prosody
2021-06-28 09:53:01 +00:00
#Chome related packages
apt-get -y purge google-chrome-stable
rm /usr/local/bin/chromedriver
2021-05-06 06:08:25 +00:00
#Services stop
2021-05-06 20:19:12 +00:00
remove_services jibri
remove_services jibri-icewm
remove_services jibri-xorg
2021-05-06 06:08:25 +00:00
#Cleaning packages
apt-get -y autoremove
apt-get clean
#Removing residual files
2021-05-06 06:08:25 +00:00
remove_residuals /etc/jitsi
remove_residuals /opt/jitsi
remove_residuals /usr/share/jicofo
remove_residuals /usr/share/jitsi-*
2021-06-28 08:39:21 +00:00
#Clean /etc/hosts
sed -i "/$DOMAIN/d" /etc/hosts
echo "#Purging debconf db"
purge_debconf jicofo
purge_debconf jigasi
purge_debconf jitsi-meet
purge_debconf jitsi-meet-prosody
purge_debconf jitsi-meet-turnserver
purge_debconf jitsi-meet-web-config
purge_debconf jitsi-videobridge2
#Remove unused users & groups
if [ -n "$SYNC_USER" ]; then
deluser --remove-home "$SYNC_USER"
2021-05-06 06:08:25 +00:00
fi
if [ -d /home/jibri ]; then
deluser --remove-home jibri
rm -r /home/jibri
2021-05-06 06:08:25 +00:00
fi
groupdel jibri
2021-05-06 06:08:25 +00:00
#Remove crontab
crontab -l | grep -v '@weekly certbot renew --nginx' | crontab -
crontab -l
echo "We are done..."