bigbluebutton-Github/build/packages-template/bbb-web/after-install.sh
2021-08-13 12:53:18 +02:00

129 lines
4.0 KiB
Bash
Executable File

#!/bin/bash -e
escape_quotes() {
cat <<EOF | sed -e "s/'/\\\\'/g"
$1
EOF
}
bbb_new_properties() {
#
# Setup bigbluebutton.properties for bbb-web
#
sed -i "s/bigbluebutton.web.serverURL=http:\/\/.*/bigbluebutton.web.serverURL=http:\/\/$IP/g" \
$SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
sed -i "s/screenshareRtmpServer=.*/screenshareRtmpServer=$IP/g" \
$SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
}
bbb_config() {
if [ -f /tmp/bigbluebutton.properties ]; then
VARS=$(cat /tmp/bigbluebutton.properties | grep = | grep -v \# | sed -e "s/ //g" -e "s/=.*/ /g" | tr -d '\n')
for v in $VARS ; do
old_val=$(cat /tmp/bigbluebutton.properties | tr -d '\r' | sed -n "/^${v}[# ]*=[ ]*/{s/${v}[ ]*=[ ]*//;p}" )
sed -i "s|^$v=.*|$v=$old_val|" $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
done
else
bbb_new_properties
fi
#
# Now update the API examples
#
SECRET=$(openssl rand -base64 32 | sed 's/=//g' | sed 's/+//g' | sed 's/\///g')
HOST=$(cat $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties | sed -n '/^bigbluebutton.web.serverURL/{s/.*\///;p}')
if [ -f /tmp/bigbluebutton.properties ]; then
if grep -q securitySalt /tmp/bigbluebutton.properties; then
# Use existing salt in bigbluebutton.properties
SECRET=$(cat /tmp/bigbluebutton.properties | tr -d '\r' | sed -n '/securitySalt/{s/.*=//;p}')
fi
fi
sed -i "s/securitySalt=.*/securitySalt=$SECRET/g" \
$SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
# XXX
sed -i "s/^swfToolsDir=\/bin$/swfToolsDir=\/usr\/bin/g" \
$SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
#
# XXX
if id meteor > /dev/null 2>&1 ; then
if [ -d /var/log/bigbluebutton/html5 ]; then
chown -R meteor:meteor /var/log/bigbluebutton/html5
fi
fi
#
# Update the placementsThreshold and imageTagThreshold
sed -i 's/placementsThreshold=8000/placementsThreshold=800/g' $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
sed -i 's/imageTagThreshold=8000/imageTagThreshold=800/g' $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
#
# Update the API version to 2.0
sed -i 's/apiVersion=1.1/apiVersion=2.0/g' $SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
#
# Propagate settings for TURN server
if [ -f /tmp/turn-stun-servers.xml ]; then
cp /tmp/turn-stun-servers.xml $SERVLET_DIR/WEB-INF/classes/spring
mv /tmp/turn-stun-servers.xml /tmp/turn-stun-servers.xml_
fi
#
# Fix links in welcome text
sed -i 's#<a href="event:http://www.bigbluebutton.org/html5">#<a href="https://www.bigbluebutton.org/html5" target="_blank">#g' \
$SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
sed -i 's#<a href="http://docs.bigbluebutton.org/" target="_blank">#<a href="https://docs.bigbluebutton.org/" target="_blank">#g' \
$SERVLET_DIR/WEB-INF/classes/bigbluebutton.properties
if [ -f /tmp/bigbluebutton.properties ]; then
mv /tmp/bigbluebutton.properties /tmp/bigbluebutton.properties_
fi
if [ ! -L /etc/bigbluebutton/nginx/web.nginx ]; then
ln -s /etc/bigbluebutton/nginx/web /etc/bigbluebutton/nginx/web.nginx
fi
if [[ ! -L /usr/share/bbb-web/logs && -d /usr/share/bbb-web/logs ]]; then # remove old directory (if exists)
rm -rf /usr/share/bbb-web/logs
fi
if [ ! -L /usr/share/bbb-web/logs ]; then # create symbolic link
ln -s /var/log/bigbluebutton /usr/share/bbb-web/logs
fi
chown bigbluebutton:bigbluebutton /var/log/bigbluebutton
touch /var/log/bigbluebutton/bbb-web.log
chown bigbluebutton:bigbluebutton /var/log/bigbluebutton/bbb-web.log
# Restart bbb-web to deploy new
startService bbb-web.service || echo "bbb-web.service could not be registered or started"
# sed -i 's/8080/8090/g' /etc/bigbluebutton/nginx/web
}
case "$1" in
configure|upgrade|1|2)
bbb_config
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "## postinst called with unknown argument \`$1'" >&2
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
exit 0