Skip to content
Snippets Groups Projects
Commit c2faf55d authored by Mikhail Novosyolov's avatar Mikhail Novosyolov
Browse files

Dynamically detect is sudo is needed

Fixes #6281
parent 2e7a2aed
No related branches found
No related tags found
No related merge requests found
......@@ -56,12 +56,20 @@
# 2016-08-15 GTR Archive more logs with zip option and show more applications with status
# 2016-10-17 GTR Added redis to checked server components & added ownership check for video and freeswitch recording directories
# 2017-04-08 FFD Cleanup for 1.1-beta
# 2018-11-22 MNE Dynamically detect if sudo is needed
#set -x
#set -e
PATH=$PATH:/sbin
if [ "$(id -u)" != "0" ]
then if [ -x "$(which sudo)" ]
then SUDO="$(which sudo)"
else echo "bbb-conf must be ran as root!" && exit 1
fi
fi
source /etc/bigbluebutton/bigbluebutton-release
#
......@@ -136,7 +144,7 @@ fi
#
if [ -f $SERVLET_DIR/bigbluebutton/WEB-INF/classes/bigbluebutton.properties ]; then
if cat $SERVLET_DIR/bigbluebutton/WEB-INF/classes/bigbluebutton.properties | grep -q ^bigbluebutton.web.logoutURL=$; then
sudo sed -i s/^bigbluebutton.web.logoutURL=$/bigbluebutton.web.logoutURL=default/g $SERVLET_DIR/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
"$SUDO" sed -i s/^bigbluebutton.web.logoutURL=$/bigbluebutton.web.logoutURL=default/g $SERVLET_DIR/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
fi
fi
......@@ -530,7 +538,7 @@ enable_webrtc(){
echo
echo "WebRTC audio enabled. To apply settings to your server, do"
echo
echo " sudo bbb-conf --clean"
echo " $SUDO bbb-conf --clean"
echo
}
......@@ -554,7 +562,7 @@ disable_webrtc(){
echo
echo "WebRTC audio disabled. To apply settings to your server, do"
echo
echo " sudo bbb-conf --clean"
echo " $SUDO bbb-conf --clean"
echo
}
......@@ -730,7 +738,7 @@ if [ $SECRET ]; then
echo "Changed BigBlueButton's shared secret to $SECRET"
echo
echo "You must restart BigBlueButton for the changes to take effect"
echo " sudo bbb-conf --restart"
echo " $SUDO bbb-conf --restart"
echo
fi
......@@ -745,7 +753,7 @@ if [ $SAMBA ]; then
# Instal Samba
#
if ! dpkg-query -s samba > /dev/null 2>&1; then
sudo apt-get install -y --force-yes samba ant
"$SUDO" apt-get install -y --force-yes samba ant
fi
#
......@@ -764,9 +772,9 @@ if [ $SAMBA ]; then
directory mask = 0775
guest ok = yes
force user = $USER
" | sudo tee -a /etc/samba/smb.conf > /dev/null 2>&1
" | "$SUDO" tee -a /etc/samba/smb.conf > /dev/null 2>&1
sudo /etc/init.d/smbd restart
"$SUDO" /etc/init.d/smbd restart
echo "
You can now access your development folder through:
......@@ -1220,10 +1228,10 @@ check_state() {
echo "# Warning: The installed ffmpeg version '${FFMPEG_VERSION}' is not recommended."
echo "# Recommend you update to the 4.0.x version of ffmpeg. To upgrade, do the following"
echo "#"
echo "# sudo apt-get install software-properties-common"
echo "# sudo add-apt-repository ppa:jonathonf/ffmpeg-4"
echo "# sudo apt-get update"
echo "# sudo apt-get dist-upgrade"
echo "# $SUDO apt-get install software-properties-common"
echo "# $SUDO add-apt-repository ppa:jonathonf/ffmpeg-4"
echo "# $SUDO apt-get update"
echo "# $SUDO apt-get dist-upgrade"
echo "#"
echo
;;
......@@ -1238,7 +1246,7 @@ check_state() {
echo "# Warning: The voice application may not have registered with the sip server."
echo "# Try running: "
echo "#"
echo "# sudo bbb-conf --clean"
echo "# $SUDO bbb-conf --clean"
echo "#"
echo
fi
......@@ -1383,7 +1391,7 @@ check_state() {
if test ${SERVLET_DIR}/lti.war -nt ${SERVLET_DIR}/lti; then
echo "# Error: The updated lti.war did not deploy. To manually deploy:"
echo "#"
echo "# sudo touch ${SERVLET_DIR}/lti.war"
echo "# $SUDO touch ${SERVLET_DIR}/lti.war"
echo "#"
echo
fi
......@@ -1393,7 +1401,7 @@ check_state() {
if test ${SERVLET_DIR}/demo.war -nt ${SERVLET_DIR}/demo; then
echo "# Error: The updated demo.war did not deploy. To manually deploy:"
echo "#"
echo "# sudo touch ${SERVLET_DIR}/demo.war"
echo "# $SUDO touch ${SERVLET_DIR}/demo.war"
echo "#"
echo
fi
......@@ -1415,7 +1423,7 @@ check_state() {
echo "# to create/manage meetings and recordings. They are for testing purposes only."
echo "# If you are running a production system, remove them by running:"
echo "#"
echo "# sudo apt-get purge bbb-demo"
echo "# $SUDO apt-get purge bbb-demo"
echo
fi
......@@ -1492,7 +1500,7 @@ check_state() {
echo "# Error: Detected that /usr/share/bbb-apps-akka/conf/application.conf has the default"
echo "# configuration values. To update, run"
echo "#"
echo "# sudo bbb-conf --setip $BBB_WEB_IP"
echo "# $SUDO bbb-conf --setip $BBB_WEB_IP"
echo "#"
fi
......@@ -1555,10 +1563,10 @@ if [ $CHECK ]; then
echo " useWebrtcIfAvailable: $WEBRTC_ENABLED_CLIENT"
if grep -q ws-binding $FREESWITCH_EXTERNAL; then
WEBRTC_SOCKET=$(sudo cat $FREESWITCH_EXTERNAL | sed -n '/ws-binding/{s/.*value="//;s/".*//;p}')
WEBRTC_SOCKET=$("$SUDO" cat $FREESWITCH_EXTERNAL | sed -n '/ws-binding/{s/.*value="//;s/".*//;p}')
fi
if grep -q wss-binding $FREESWITCH_EXTERNAL; then
WEBRTC_SOCKET=$(sudo cat $FREESWITCH_EXTERNAL | sed -n '/wss-binding/{s/.*value="//;s/".*//;p}')
WEBRTC_SOCKET=$("$SUDO" cat $FREESWITCH_EXTERNAL | sed -n '/wss-binding/{s/.*value="//;s/".*//;p}')
fi
echo
echo "$FREESWITCH_EXTERNAL (FreeSWITCH)"
......@@ -1723,7 +1731,7 @@ if [ $DEBUG ]; then
rm -rf /tmp/t
sudo grep --directories=skip Exception $SERVLET_LOGS/* | grep -v CacheExceptionHandlerFactory > /tmp/t
"$SUDO" grep --directories=skip Exception $SERVLET_LOGS/* | grep -v CacheExceptionHandlerFactory > /tmp/t
if [ -s /tmp/t ]; then
echo " -- Exceptions found in $SERVLET_LOGS/ -- "
cat /tmp/t
......@@ -1742,7 +1750,7 @@ if [ $DEBUG ]; then
if [ $DISTRIB_ID == "Ubuntu" ]; then
rm -rf /tmp/t
sudo grep --directories=skip -i exception /var/log/syslog > /tmp/t
"$SUDO" grep --directories=skip -i exception /var/log/syslog > /tmp/t
if [ -s /tmp/t ]; then
echo " -- Errors found in /var/log/syslog -- "
cat /tmp/t
......@@ -1752,7 +1760,7 @@ if [ $DEBUG ]; then
rm -rf /tmp/t
if [ -d /var/log/bigbluebutton ]; then
sudo grep --directories=skip ERROR /var/log/bigbluebutton/* > /tmp/t
"$SUDO" grep --directories=skip ERROR /var/log/bigbluebutton/* > /tmp/t
if [ -s /tmp/t ]; then
echo " -- Errors found in /var/log/bigbluebutton -- "
cat /tmp/t
......@@ -1762,7 +1770,7 @@ if [ $DEBUG ]; then
rm -rf /tmp/t
if [ -d /var/log/bigbluebutton ]; then
sudo grep --directories=skip -i exception /var/log/bigbluebutton/* > /tmp/t
"$SUDO" grep --directories=skip -i exception /var/log/bigbluebutton/* > /tmp/t
if [ -s /tmp/t ]; then
echo " -- Exceptions found in /var/log/bigbluebutton -- "
cat /tmp/t
......@@ -1789,13 +1797,13 @@ if [ -n "$HOST" ]; then
# 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=\"$PROTOCOL_RTMP:\/\/$HOST\"/g" /var/www/bigbluebutton/client/conf/config.xml
"$SUDO" sed -i "s/porttest host=\(\"[^\"]*\"\)/porttest host=\"$PROTOCOL_RTMP:\/\/$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[s]*:\/\/\([^\"\/]*\)\([\"\/]\)/$PROTOCOL_RTMP:\/\/$HOST\2/g" /var/www/bigbluebutton/client/conf/config.xml
"$SUDO" sed -i "s/rtmp[s]*:\/\/\([^\"\/]*\)\([\"\/]\)/$PROTOCOL_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
"$SUDO" sed -i "s/server_name .*/server_name $HOST;/g" /etc/nginx/sites-available/bigbluebutton
#
# Update configuration for BigBlueButton client (and preserve hostname for chromeExtensionLink if exists)
......@@ -1805,26 +1813,26 @@ if [ -n "$HOST" ]; then
chromeExtensionLinkURL=$(cat /var/www/bigbluebutton/client/conf/config.xml | sed -n '/chromeExtensionLink/{s/.*https*:\/\///;s/\/.*//;p}')
echo "Assigning $HOST for http[s]:// in /var/www/bigbluebutton/client/conf/config.xml"
sudo sed -i "s/http[s]*:\/\/\([^\"\/]*\)\([\"\/]\)/$PROTOCOL_HTTP:\/\/$HOST\2/g" \
"$SUDO" sed -i "s/http[s]*:\/\/\([^\"\/]*\)\([\"\/]\)/$PROTOCOL_HTTP:\/\/$HOST\2/g" \
/var/www/bigbluebutton/client/conf/config.xml
if ! echo "$chromeExtensionLinkURL" | grep -q '""'; then
sudo sed -i "s/chromeExtensionLink=\"https:\/\/[^\/]*/chromeExtensionLink=\"https:\/\/$chromeExtensionLinkURL/g" \
"$SUDO" sed -i "s/chromeExtensionLink=\"https:\/\/[^\/]*/chromeExtensionLink=\"https:\/\/$chromeExtensionLinkURL/g" \
/var/www/bigbluebutton/client/conf/config.xml
fi
echo "Assigning $HOST for publishURI in /var/www/bigbluebutton/client/conf/config.xml"
sudo sed -i "s/publishURI=\"[^\"]*\"/publishURI=\"$HOST\"/" /var/www/bigbluebutton/client/conf/config.xml
"$SUDO" sed -i "s/publishURI=\"[^\"]*\"/publishURI=\"$HOST\"/" /var/www/bigbluebutton/client/conf/config.xml
#
# Update configuration for BigBlueButton web app
#
echo "Assigning $HOST for web application URL in ${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties"
sudo sed -i "s/bigbluebutton.web.serverURL=http[s]*:\/\/.*/bigbluebutton.web.serverURL=$PROTOCOL_HTTP:\/\/$HOST/g" \
"$SUDO" sed -i "s/bigbluebutton.web.serverURL=http[s]*:\/\/.*/bigbluebutton.web.serverURL=$PROTOCOL_HTTP:\/\/$HOST/g" \
${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
sudo sed -i "s/screenshareRtmpServer=.*/screenshareRtmpServer=$HOST/g" \
"$SUDO" sed -i "s/screenshareRtmpServer=.*/screenshareRtmpServer=$HOST/g" \
${SERVLET_DIR}/bigbluebutton/WEB-INF/classes/bigbluebutton.properties
change_var_value /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties streamBaseUrl rtmp://$HOST/screenshare
......@@ -1832,7 +1840,7 @@ if [ -n "$HOST" ]; then
change_var_value /usr/share/red5/webapps/screenshare/WEB-INF/screenshare.properties jnlpFile $PROTOCOL_HTTP://$HOST/screenshare/screenshare.jnlp
if ! grep -q server_names_hash_bucket_size /etc/nginx/nginx.conf; then
sudo sed -i "s/gzip on;/gzip on;\n server_names_hash_bucket_size 64;/g" /etc/nginx/nginx.conf
"$SUDO" sed -i "s/gzip on;/gzip on;\n server_names_hash_bucket_size 64;/g" /etc/nginx/nginx.conf
fi
#
......@@ -1857,7 +1865,7 @@ if [ -n "$HOST" ]; then
if [ -f ${SERVLET_DIR}/demo/bbb_api_conf.jsp ]; then
echo "Assigning $HOST for api demos in ${SERVLET_DIR}/demo/bbb_api_conf.jsp"
sudo sed -i "s/BigBlueButtonURL = \"http[s]*:\/\/\([^\"\/]*\)\([\"\/]\)/BigBlueButtonURL = \"$PROTOCOL_HTTP:\/\/$HOST\2/g" \
"$SUDO" sed -i "s/BigBlueButtonURL = \"http[s]*:\/\/\([^\"\/]*\)\([\"\/]\)/BigBlueButtonURL = \"$PROTOCOL_HTTP:\/\/$HOST\2/g" \
${SERVLET_DIR}/demo/bbb_api_conf.jsp
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment