bigbluebutton-Github/bigbluebutton-config/bin/bbb-setip
2009-06-09 17:47:39 +00:00

104 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "Usage $(basename $0) -h HOST [-p port]"
echo
echo "Current Parameters:"
IP=$(cat /var/www/bigbluebutton/client/conf/config.xml | sed -n '/porttest /{s/.*host="//;s/".*//;p}')
echo
echo "/var/www/bigbluebutton/client/conf/config.xml (configuration file for BigBlueButton Client)"
echo " IP for tunnel check: $IP"
IP=$(cat /var/www/bigbluebutton/client/conf/config.xml | sed -n '/uri.*ofla/{s/.*rtmp:\/\///;s/\/.*//;p}')
echo " IP for rtmp (red5): $IP"
HOST=$(cat /var/www/bigbluebutton/client/conf/config.xml | sed -n '/recordingHost/{s/.*recordingHost="http:\/\///;s/"//;p}')
echo " host for bbb-web interface: $HOST"
IP=$(cat /etc/nginx/sites-available/bigbluebutton | sed -n '/server_name/{s/.*name[ ]*//;s/;//;p}')
echo
echo "/etc/nginx/sites-available/bigbluebutton (configuration file for nginx)"
echo " server_name: $IP"
PORT=$(cat /etc/nginx/sites-available/bigbluebutton | sed -n '/listen/{s/.*listen[ ]*//;s/;//;p}')
echo " port: $PORT"
HOST=$(cat /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties | sed -n '/bigbluebutton.web.serverURL/{s/.*\///;p}')
echo
echo "/var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties (properties for BigblueButton Web apps)"
echo " host: $HOST"
exit 1
fi
while getopts "h:p:" flag
do
# echo "$flag" $OPTIND $OPTARG
case "$flag" in
h) # echo "Option \"h\" $OPTARG"
HOST=$OPTARG
;;
p) # echo "Option \"p\" $OPTARG"
PORT=$OPTARG
;;
*) break;;
esac
done
if [ ! $HOST ]; then
echo "Usage $0 -h HOST [-p port]"
exit 1
fi
#
# Just use the IP for port test in /var/www/bigbluebutton/client/conf/config.xml
#
echo "Assigning $HOST for testing for firewall in /var/www/bigbluebutton/client/conf/config.xml"
sudo sed -i "s/porttest host=\(\"[^\"]*\"\)/porttest host=\"$HOST\"/g" /var/www/bigbluebutton/client/conf/config.xml
echo "Assigning $HOST for rtmp:// in /var/www/bigbluebutton/client/conf/config.xml"
sudo sed -i "s/rtmp:\/\/\([^\"\/]*\)\([\"\/]\)/rtmp:\/\/$HOST\2/g" /var/www/bigbluebutton/client/conf/config.xml
echo "Assigning $HOST for servername in /etc/nginx/sites-available/bigbluebutton"
sudo sed -i "s/server_name .*/server_name $HOST;/g" /etc/nginx/sites-available/bigbluebutton
#
# Use port for remaining substitutions
#
if [ $PORT ]; then
HOST="$HOST:$PORT"
fi
#
# Update configuration for BigBlueButton client
#
echo "Assigning $HOST for http:// in /var/www/bigbluebutton/client/conf/config.xml"
sudo sed -i "s/http:\/\/\([^\"\/]*\)\([\"\/]\)/http:\/\/$HOST\2/g" /var/www/bigbluebutton/client/conf/config.xml
#
# Update configuration for BigBlueButton web app
#
echo "Assigning $HOST for web application URL in /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties"
sudo sed -i "s/bigbluebutton.web.serverURL=http:\/\/.*/bigbluebutton.web.serverURL=http:\/\/$HOST/g" \
/var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
# cat /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
#
# Update nginx
#
if [ $PORT ]; then
echo "Assigning $PORT for listen in /etc/nginx/sites-available/bigbluebutton"
sudo sed -i "s/listen .*/listen $PORT;/g" /etc/nginx/sites-available/bigbluebutton
fi
sudo /etc/init.d/tomcat6 restart
sudo /etc/init.d/nginx restart