Updates BigBlueButton and backs up relevant files beforehand
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
6.8 KiB

#!/bin/bash
set -o nounset # set -u : exit the script if you try to use an uninitialised variable
set -o errexit # set -e : exit the script if any statement returns a non-true return value
# #
# _______ ________ ______ _______ _____ ____ ____ _____ #
# / ____\ \ / / ____| ____|__ __/ ____|/ __ \ / __ \| __ \ #
# | (___ \ \ /\ / /| |__ | |__ | | | | _| | | | | | | | | | #
# \___ \ \ \/ \/ / | __| | __| | | | | | | | | | | | | | | | #
# ____) | \ /\ / | |____| |____ | | | |__| | |__| | |__| | |__| | #
# |_____/ \/ \/ |______|______| |_| \_____|\____/ \____/|_____/ #
# #
# IT-Beratung mit Fokus auf Datensicherheit #
# #
# www.sweetgood.de #
# #
# Copyright : All rights reserved!
# Repository url : codeberg.org/SWEETGOOD/andersgood-update-bbb-script
# Author : codiflow @ SWEETGOOD
# Filename : update-bbb.sh
# Created at : 17.08.2020
# Last changed at : 05.03.2022
# Description : Updates BigBlueButton and backs up configurations and
# files beforehand
# ---
# PLEASE CHANGE THE VALUES BELOW THIS LINE
# ---
BBBIP="my.server.de"
LETSENCRYPTEMAIL="mail@server.de"
BACKUPROOTFOLDER="/root/bigbluebutton-sg/backups"
# The following string is empty by default, so this script will update BigBlueButton using "apt upgrade".
# You can enter your bbb-install.sh string here which will be executed instead if entered.
# You find the details on this string here: https://github.com/bigbluebutton/bbb-install#command-options
# Example: wget -qO- https://ubuntu.bigbluebutton.org/bbb-install.sh | bash -s -- -w -v bionic-240 -s ${BBBIP} -e ${LETSENCRYPTEMAIL} -g
BBBINSTALLSCRIPTSTRING=""
# ---
# DON'T CHANGE ANYTHING BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
# ---
VERSION='1.3'
RED='\e[31m'
BLUE='\e[36m'
NC='\e[39m' # No Color
BACKUPFOLDER="$(date +%Y%m%d_%H%M%S)_$(hostname)"
BACKUPPATH="${BACKUPROOTFOLDER}/${BACKUPFOLDER}"
# root check
if [ $(id -u) -ne 0 ]
then echo "Please start the script as user ${RED}root${NC}."
exit
fi
# Create backup root folder if it doesn't exist
if [ ! -d "${BACKUPROOTFOLDER}" ]; then
mkdir -p ${BACKUPROOTFOLDER}
fi
echo -e "${BLUE}#####################################${NC}"
echo -e "${BLUE}# BigBlueButton upgrade script v${VERSION} #${NC}"
echo -e "${BLUE}# www.sweetgood.de #${NC}"
echo -e "${BLUE}#####################################${NC}"
echo " "
echo -e "${BLUE}This script is configured for server: ${RED}${BBBIP}${NC}"
echo " "
echo "---"
echo " "
read -n 1 -r -s -p $'Do you want to start the update of BigBlueButton now?\n'
echo " "
echo "---"
echo " "
echo -e "${BLUE}Starting the configuration backup${NC}"
echo " "
cd ${BACKUPROOTFOLDER}
echo "> Creating backup folder"
mkdir ${BACKUPFOLDER}
echo "> Creating backup of the STUN/TURN server configuration"
cp /usr/share/bbb-web/WEB-INF/classes/spring/turn-stun-servers.xml ${BACKUPPATH}
echo "> Creating backup of the BBB configuration"
cp /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties ${BACKUPPATH}
echo "> Creating backup of the default presentation"
cp /var/www/bigbluebutton-default/default* ${BACKUPPATH}
echo "> Creating backup of meteor settings"
cp /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml ${BACKUPPATH}
echo "> Creating backup of freeswitch settings"
cp /opt/freeswitch/etc/freeswitch/autoload_configs/conference.conf.xml ${BACKUPPATH}
cp /opt/freeswitch/conf/sip_profiles/external.xml ${BACKUPPATH}
cp /opt/freeswitch/conf/vars.xml ${BACKUPPATH}
echo "> Creating backup of kurento settings"
cp /usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml ${BACKUPPATH}
cp /etc/kurento/modules/kurento/WebRtcEndpoint.conf.ini ${BACKUPPATH}
echo "> Creating backup of nginx settings"
cp /etc/bigbluebutton/nginx/sip.nginx ${BACKUPPATH}
echo "> Creating backup of apply-config.sh"
cp /etc/bigbluebutton/bbb-conf/apply-config.sh ${BACKUPPATH}
echo "> Get current settings and write them into a backup file"
bbb-conf --check > ${BACKUPPATH}/config-pre-update.log
echo " "
echo -e "${BLUE}Backup of configurations done.${NC}"
echo " "
echo "---"
echo " "
read -n 1 -r -s -p $'Press any key to proceed with the update of BigBlueButton...\n'
echo " "
if [ "${BBBINSTALLSCRIPTSTRING}" == "" ]; then
echo -e "${BLUE}Update process ${RED}using apt${BLUE} started.${NC}"
echo " "
echo "> Renew apt-cache"
echo " "
apt update
echo " "
echo -e "> ${RED}The following packages are getting updated. Please confirm manually or abort the process by pressing [STRG] + [C]...${NC}"
echo " "
apt upgrade
echo " "
echo -e "${BLUE}Update process ${RED}using apt${BLUE} finished.${NC}"
else
echo -e "${BLUE}Update process ${RED}using bbb-install.sh${BLUE} started.${NC}"
echo " "
echo "> Running bbb-install.sh string"
echo " "
/bin/bash -c "${BBBINSTALLSCRIPTSTRING}"
echo " "
echo -e "${BLUE}Update process ${RED}using bbb-install.sh${BLUE} finished.${NC}"
fi
echo " "
echo "---"
echo " "
read -n 1 -r -s -p $'Press any key to copy some files back from backup to production...\n'
echo " "
echo -e "${BLUE}Copying of configuration backups started.${NC}"
echo " "
echo "> Copy STUN/TURN server configuration from backup to production"
mv /usr/share/bbb-web/WEB-INF/classes/spring/turn-stun-servers.xml /usr/share/bbb-web/WEB-INF/classes/spring/turn-stun-servers.xml.dist
cp ${BACKUPPATH}/turn-stun-servers.xml /usr/share/bbb-web/WEB-INF/classes/spring/turn-stun-servers.xml
echo "> Copy default presentation as pptx file from backup to production"
mv /var/www/bigbluebutton-default/default.pptx /var/www/bigbluebutton-default/default.pptx.dist
cp ${BACKUPPATH}/default.pptx /var/www/bigbluebutton-default/default.pptx
echo "> Copy default presentation as pdf file from backup to production"
mv /var/www/bigbluebutton-default/default.pdf /var/www/bigbluebutton-default/default.pdf.dist
cp ${BACKUPPATH}/default.pdf /var/www/bigbluebutton-default/default.pdf
if [ "${BBBINSTALLSCRIPTSTRING}" == "" ]; then
echo "> Running setip command with bbb-conf"
echo " "
bbb-conf --setip ${BBBIP}
echo " "
fi
echo -e "${BLUE}Copying of configuration backups finished.${NC}"
echo " "
echo "---"
echo " "
echo -e "${BLUE}Compare new configuration to the configuration from the backup${NC}"
echo " "
bbb-conf --check > ${BACKUPPATH}/config-post-update.log
echo " "
diff ${BACKUPPATH}/config-pre-update.log ${BACKUPPATH}/config-post-update.log
echo " "
echo -e "${BLUE}Script finished.${NC} You'll find the backups and logs at ${BLUE}${BACKUPPATH}${NC}"
echo " "