#!/usr/bin/env bash script_name="$(basename $(realpath $0))" working_dir="$(dirname $(realpath $0))" #conf_file="${working_dir}/conf/${script_name%%.*}.conf" conf_file="${working_dir}/conf/bbb.conf" LOCK_DIR="/tmp/$(basename $0).$$.LOCK" log_file="${LOCK_DIR}/${script_name%%.*}.log" # ---------- # Base Function(s) # ---------- clean_up() { # Perform program exit housekeeping rm -rf "$LOCK_DIR" blank_line exit $1 } echononl(){ if $terminal ; then echo X\\c > /tmp/shprompt$$ if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then echo -e -n " $*\\c" 1>&2 else echo -e -n " $*" 1>&2 fi rm /tmp/shprompt$$ fi } fatal(){ echo "" if $terminal ; then echo -e " [ \033[31m\033[1mFatal\033[m ] $*" else echo -e " [ Fatal ] $*" fi echo "" if $terminal ; then echo -e " \033[1mScript terminated\033[m.." else echo -e " Script terminated.." fi echo "" rm -rf $LOCK_DIR exit 1 } error (){ echo "" if $terminal ; then echo -e " [ \033[31m\033[1mError\033[m ] $*" else echo " [ Error ] $*" fi echo "" } info () { if $terminal ; then echo "" echo -e " [ \033[32m\033[1minfo\033[m ] $*" echo "" fi } echo_ok() { if $terminal ; then echo -e "\033[85G[ \033[32mok\033[m ]" fi } echo_failed(){ if $terminal ; then echo -e "\033[85G[ \033[1;31mfailed\033[m ]" fi } echo_skipped() { if $terminal ; then echo -e "\033[85G[ \033[33m\033[1mskipped\033[m ]" fi } echo_wait(){ if $terminal ; then echo -en "\033[85G[ \033[5m\033[1m..\033[m ]" fi } trim() { local var="$*" var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters echo -n "$var" } blank_line() { if $terminal ; then echo "" fi } detect_os () { if $(which lsb_release > /dev/null 2>&1) ; then DIST="$(lsb_release -i | awk '{print tolower($3)}')" DIST_VERSION="$(lsb_release -r | awk '{print tolower($2)}')" DIST_CODENAME="$(lsb_release -c | awk '{print tolower($2)}')" if [[ "$DIST" = "debian" ]]; then if $(echo "$DIST_VERSION" | grep -q '\.') ; then DIST_VERSION=$(echo "$DIST_VERSION" | cut --delimiter='.' -f1) fi fi elif [[ -e "/etc/os-release" ]]; then . /etc/os-release DIST=$ID DIST_VERSION=${VERSION_ID} fi # remove whitespace from DIST and DIST_VERSION DIST="${DIST// /}" DIST_VERSION="${DIST_VERSION// /}" } # ---------- # - Jobhandling # ---------- # - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM # - trap clean_up SIGHUP SIGINT SIGTERM # - Create lock directory '$LOCK_DIR" # mkdir "$LOCK_DIR" # ---------- # - Some checks .. # ---------- # - Running in a terminal? # - if [[ -t 1 ]] ; then terminal=true else fatal "Script must run in a terminal." fi # ========== # - Begin Main Script # ========== # ---------- # - Headline # ---------- if $terminal ; then echo "" echo -e "\033[1m----------\033[m" echo -e "\033[32m\033[1mRunning script \033[m\033[1m$script_name\033[32m .. \033[m" echo -e "\033[1m----------\033[m" fi # ---------- # Read Configurations from $conf_file # ---------- # - Give your default values here # - DEFAULT_FQDN_HOSTNAME="$(hostname -f)" if [[ -f "$conf_file" ]]; then source "$conf_file" else warn "No configuration file '$conf_file' present.\n Loading default values.." fi [[ -n "$FQDN_HOSTNAME" ]] && DEFAULT_FQDN_HOSTNAME="$FQDN_HOSTNAME" blank_line echononl "Detect distribution/release of running OS.." detect_os > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi FQDN_HOSTNAME= echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert full qualified hostname for BigBlueButton Service" echo "" if [[ -n "$DEFAULT_FQDN_HOSTNAME" ]]; then while [[ "X${FQDN_HOSTNAME}" = "X" ]]; do echononl "Full qualified hostname [${DEFAULT_FQDN_HOSTNAME}]: " read FQDN_HOSTNAME if [[ "X${FQDN_HOSTNAME}" = "X" ]]; then FQDN_HOSTNAME=$DEFAULT_FQDN_HOSTNAME fi if [[ ! $FQDN_HOSTNAME =~ \. ]]; then echo -e "\n\tGiven Host \033[33m\033[1m$FQDN_HOSTNAME\033[m seems not to be a full qualified hostname.\n" FQDN_HOSTNAME="" fi done else while [[ "X${FQDN_HOSTNAME}" = "X" ]]; do echononl "Full qualified hostname: " read FQDN_HOSTNAME if [[ "X${FQDN_HOSTNAME}" = "X" ]]; then echo -e "\n\t\033[33m\033[1mFull qualified hostname is reqired\033[m\n" fi if [[ ! $FQDN_HOSTNAME =~ \. ]]; then echo -e "\n\tGiven Host \033[33m\033[1m$FQDN_HOSTNAME\033[m seems not to be a full qualified hostname.\n" FQDN_HOSTNAME="" fi done fi HOSTNAME="${FQDN_HOSTNAME%%.*}" echo "" echo "" echo -e "\t\033[32mStart pre-install script for BigBlueButton Service with the following parameters\033[m" echo "" echo -e "\tFull qualified Hostname..: $FQDN_HOSTNAME" echo -e "\tHostname.................: $HOSTNAME" echo "" echo -e "\tOS Distribution..........: $DIST" echo -e "\tDistribution's codename..: $DIST_CODENAME" echo "" echononl "einverstanden (yes/no): " read OK OK=${OK,,} while [ "X$OK" != "Xyes" -a "X$OK" != "Xno" ]; do echononl "Wrong entry! [yes/no]: " read OK OK=${OK,,} done [ $OK = "yes" ] || fatal Repeat with other settings.. echo "" echo "" # Make the HTML5 client default # if $terminal ; then echo "" echo -e " \033[1mMake the HTML5 client the default client\033[m (no longer load the Flash client)" echo "" fi echononl "Set 'attendeesJoinViaHTML5Client=true'.." if $(grep -q -E "^\s*attendeesJoinViaHTML5Client=true" \ /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties 2> /dev/null) ; then echo_skipped else perl -i -n -p -e "s/^(attendeesJoinViaHTML5Client=.*)/##!\1\nattendeesJoinViaHTML5Client=true/" \ /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi fi echononl "Set 'moderatorsJoinViaHTML5Client=true'.." if $(grep -q -E "^\s*moderatorsJoinViaHTML5Client=true" \ /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties 2> /dev/null) ; then echo_skipped else perl -i -n -p -e "s/^(moderatorsJoinViaHTML5Client=.*)/##!\1\nmoderatorsJoinViaHTML5Client=true/" \ /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties >> "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi fi blank_line # Assign the server a hostname # if $terminal ; then echo "" echo -e " \033[1mAssign the server a hostname '$FQDN_HOSTNAME'\033[m" echo "" fi echononl "Trigger command 'bbb-conf --setip $FQDN_HOSTNAME'" echo_wait bbb-conf --setip $FQDN_HOSTNAME > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok echo -e " \033[32m----------\033[m \033[1mOutput from assigning a hostname 'bbb-conf --setip $FQDN_HOSTNAME' was:\033[m $(cat "$log_file") \033[32m----------\033[m " fi # Configure FreeSWITCH for using SSL # # At file /etc/bigbluebutton/nginx/sip.nginx # # change: # # proxy_pass http://203.0.113.1:5066; # # to # proxy_pass https://203.0.113.1:7443; # ^ ^^^^ # if $terminal ; then echo "" echo -e " \033[1mConfigure FreeSWITCH for using SSL\033[m" echo "" fi echononl "Replace 'http://' with https:// (/etc/bigbluebutton/nginx/sip.nginx).." if $(grep -q -E "http://" /etc/bigbluebutton/nginx/sip.nginx 2> /dev/null) ; then perl -i -n -p -e "s#http://#https://#" /etc/bigbluebutton/nginx/sip.nginx > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi echononl "Replace port 5066 with 7443 (/etc/bigbluebutton/nginx/sip.nginx).." if $(grep -q -E ":5066\s*;" /etc/bigbluebutton/nginx/sip.nginx 2> /dev/null) ; then perl -i -n -p -e "s#:5066\s*;#:7443;#" /etc/bigbluebutton/nginx/sip.nginx > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi blank_line # Configure BigBlueButton to load session via HTTPS # if $terminal ; then echo "" echo -e " \033[1mConfigure BigBlueButton to load session via HTTPS\033[m" echo "" fi # file '/usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties' # # change: # # bigbluebutton.web.serverURL=http://${FQDN_HOSTNAME} # # to: # # bigbluebutton.web.serverURL=https://${FQDN_HOSTNAME} # ^ # echononl "Setup 'bigbluebutton.web.serverURL' (bigbluebutton.properties)" if $(grep -q -E "^\s*bigbluebutton.web.serverURL\s*=\s*http:" /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*bigbluebutton.web.serverURL=.*)#\#\#!\1\nbigbluebutton.web.serverURL=https://${FQDN_HOSTNAME}#" \ /usr/share/bbb-web/WEB-INF/classes/bigbluebutton.properties > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi # file: /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties # # change: # # JnlpUrl=https://${FQDN_HOSTNAME}/screenshare # # to: # # JnlpUrl=https://${FQDN_HOSTNAME}/screenshare # ^ # echononl "Setup 'jnlpUrl' (screenshare.properties)" if $(grep -q -E "^\s*jnlpUrl\s*=\s*http:" /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*jnlpUrl\s*=.*)#\#\#!\1\njnlpUrl=https://${FQDN_HOSTNAME}/screenshare#" \ /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi # file: /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties # # change: # # jnlpFile=https://${FQDN_HOSTNAME}/screenshare/screenshare.jnlp # # to: # # jnlpFile=https://${FQDN_HOSTNAME}/screenshare/screenshare.jnlp # ^ # echononl "Setup 'jnlpFile' (screenshare.properties)" if $(grep -q -E "^\s*jnlpFile\s*=\s*http:" /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*jnlpFile\s*=.*)#\#\#!\1\njnlpFile=https://${FQDN_HOSTNAME}/screenshare/screenshare.jnlp#" \ /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi # You must also update the file /var/www/bigbluebutton/client/conf/config.xml to # tell the BigBlueButton client to load components via HTTPS. You can do the update # with a single command # echononl "Change all 'http://' to 'https:/' (/var/www/bigbluebutton/client/conf/config.xml).." if $(grep -q -E "http://" /var/www/bigbluebutton/client/conf/config.xml 2> /dev/null) ; then sed -e 's|http://|https://|g' -i /var/www/bigbluebutton/client/conf/config.xml > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi blank_line # Adjust /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml # if $terminal ; then echo "" echo -e " \033[1mAdjust file /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml\033[m" echo "" fi # file: /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml # # Change: # # kurento: # wsUrl: ws://bbb.example.com/bbb-webrtc-sfu # #to # # kurento: # wsUrl: wss://bbb.example.com/bbb-webrtc-sfu # echononl "Change 'wsUrl: ws://' to 'wsUrl: wss://'.." if $(grep -q -E "wsUrl:\s*ws:" /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml 2> /dev/null) ; then perl -i -n -p -e "s#wsUrl:\s*ws:#wsUrl: wss:#" \ /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi # file: /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml # # Change: # # note: # enabled: true # url: http://bbb.example.com/pad # to # # note: # enabled: true # url: https://bbb.example.com/pad # echononl "Change 'url: http://' to 'url: https://'.." if $(grep -q -E "^\s*url: http:" /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*url:\s*)http:#\1https:#" \ /usr/share/meteor/bundle/programs/server/assets/app/config/settings.yml > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi blank_line # Modify the creation of recordings so they are served via HTTPS # if $terminal ; then echo "" echo -e " \033[1mModify the creation of recordings so they are served via HTTPS\033[m" echo "" fi # file: /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml # # Change: # # playback_protocol: http # # to: # # playback_protocol: https # echononl "Change 'playback_protocol' to use https.." if $(grep -q -E "^\s*playback_protocol:\s*http\s*$" /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml > "$log_file" 2>&1) ; then perl -i -n -p -e "s#^(\s*playback_protocol:\s*http.*)#\#\#!\1\nplayback_protocol: https#" \ /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi if [[ -f "/var/lib/tomcat7/webapps/demo/bbb_api_conf.jsp" ]] ; then blank_line # Also at 'API demo' Installation use SSL Protocol # if $terminal ; then echo "" echo -e " \033[1mUse SSL Protocoll for API demos\033[m" echo "" fi # file: /var/lib/tomcat7/webapps/demo/bbb_api_conf.jsp # # Change: # # String BigBlueButtonURL = "http://${FQDN_HOSTNAME}/bigbluebutton/"; # # To: # # String BigBlueButtonURL = "https://${FQDN_HOSTNAME}/bigbluebutton/"; # ^ # echononl "Change 'BigBlueButtonURL' to use SSL Protocil.." if $(grep -q -E "^\s*String\s+BigBlueButtonURL\s*=\s*\"http:" /var/lib/tomcat7/webapps/demo/bbb_api_conf.jsp 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*String\s+BigBlueButtonURL\s*=\s*\"http:.*)#//!\1\nString BigBlueButtonURL = \"https://${FQDN_HOSTNAME}/bigbluebutton/\";#" /var/lib/tomcat7/webapps/demo/bbb_api_conf.jsp > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok fi else echo_skipped fi fi blank_line # Restart BigBlueButton Service # if $terminal ; then echo "" echo -e " \033[1mRestart BigBlueButton Service\033[m" echo "" fi echononl "Restart BigBlueButton Service - 'bbb-conf --restart'" bbb-conf --restart > "$log_file" 2>&1 if [[ $? -ne 0 ]]; then echo_failed error "$(cat "$log_file")" else echo_ok echo -e " \033[32m----------\033[m \033[1mOutput from restarting BigBlueButton Service was:\033[m $(cat "$log_file") \033[32m----------\033[m " fi clean_up 0