2015-11-02 21:02:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# postinst script for jitsi-meet-tokens
|
|
|
|
#
|
|
|
|
# see: dh_installdeb(1)
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# summary of how this script can be called:
|
|
|
|
# * <postinst> `configure' <most-recently-configured-version>
|
|
|
|
# * <old-postinst> `abort-upgrade' <new version>
|
|
|
|
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
|
|
|
|
# <new-version>
|
|
|
|
# * <postinst> `abort-remove'
|
|
|
|
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
|
|
|
|
# <failed-install-package> <version> `removing'
|
|
|
|
# <conflicting-package> <version>
|
|
|
|
# for details, see http://www.debian.org/doc/debian-policy/ or
|
|
|
|
# the debian-policy package
|
|
|
|
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
|
|
|
|
|
|
|
if [ -f "/etc/jitsi/videobridge/config" ] ; then
|
|
|
|
. /etc/jitsi/videobridge/config
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "/etc/jitsi/jicofo/config" ] ; then
|
|
|
|
. /etc/jitsi/jicofo/config
|
|
|
|
fi
|
|
|
|
|
|
|
|
# loading debconf
|
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
|
|
|
|
db_get jitsi-meet-tokens/appid
|
|
|
|
if [ "$RET" = "false" ] ; then
|
|
|
|
echo "Application ID is mandatory"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
APP_ID=$RET
|
|
|
|
|
|
|
|
db_get jitsi-meet-tokens/appsecret
|
|
|
|
if [ "$RET" = "false" ] ; then
|
|
|
|
echo "Application secret is mandatory"
|
|
|
|
fi
|
|
|
|
APP_SECRET=$RET
|
|
|
|
|
|
|
|
# We can adjust Prosody config only if there is Jvb or Jicofo domain configured
|
|
|
|
PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JVB_HOSTNAME.cfg.lua"
|
|
|
|
if [ ! -f "$PROSODY_HOST_CONFIG" ] ; then
|
|
|
|
PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JICOFO_HOSTNAME.cfg.lua"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Store config filename for purge
|
|
|
|
db_set jitsi-meet-prosody/prosody_config $PROSODY_HOST_CONFIG
|
|
|
|
|
|
|
|
db_stop
|
|
|
|
|
|
|
|
if [ -f "$PROSODY_HOST_CONFIG" ] ; then
|
2015-11-02 21:25:23 +00:00
|
|
|
if grep -q "plugin_paths" "$PROSODY_HOST_CONFIG"; then
|
2015-11-02 21:02:50 +00:00
|
|
|
# enable tokens in prosody host config
|
2015-11-03 17:11:54 +00:00
|
|
|
sed -i 's/--plugin_paths/plugin_paths/g' $PROSODY_HOST_CONFIG
|
2015-11-02 21:02:50 +00:00
|
|
|
sed -i 's/authentication = "anonymous"/authentication = "token"/g' $PROSODY_HOST_CONFIG
|
2015-11-03 17:11:54 +00:00
|
|
|
sed -i 's/ --allow_unencrypted_plain_auth/ allow_unencrypted_plain_auth/g' $PROSODY_HOST_CONFIG
|
|
|
|
sed -i "s/ --app_id=example_app_id/ app_id=$APP_ID/g" $PROSODY_HOST_CONFIG
|
|
|
|
sed -i "s/ --app_secret=example_app_secret/ app_secret=$APP_SECRET/g" $PROSODY_HOST_CONFIG
|
|
|
|
sed -i 's/ --modules_enabled = { "token_verification" }/ modules_enabled = { "token_verification" }/g' $PROSODY_HOST_CONFIG
|
2015-11-02 21:02:50 +00:00
|
|
|
|
2015-12-15 17:46:37 +00:00
|
|
|
# Configure Jicofo properties
|
|
|
|
JICOFO_CONFIG="/etc/jitsi/jicofo/sip-communicator.properties"
|
|
|
|
if ! grep -q "org.jitsi.jicofo.auth.jwt.APP_ID" $JICOFO_CONFIG && \
|
|
|
|
! grep -q "org.jitsi.jicofo.auth.jwt.APP_SECRET" $JICOFO_CONFIG; then
|
|
|
|
echo "org.jitsi.jicofo.auth.jwt.APP_ID=$APP_ID" >> $JICOFO_CONFIG
|
|
|
|
echo "org.jitsi.jicofo.auth.jwt.APP_SECRET=$APP_SECRET" >> $JICOFO_CONFIG
|
|
|
|
# Restart Jicofo
|
|
|
|
if [ -x "/etc/init.d/jicofo" ]; then
|
|
|
|
invoke-rc.d jicofo restart
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-11-03 17:14:01 +00:00
|
|
|
if [ -x "/etc/init.d/prosody" ]; then
|
|
|
|
invoke-rc.d prosody reload
|
|
|
|
fi
|
2015-11-02 21:02:50 +00:00
|
|
|
else
|
|
|
|
echo "Failed apply auto-config to $PROSODY_HOST_CONFIG which most likely comes from not supported version of jitsi-meet"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Prosody config not found at $PROSODY_HOST_CONFIG - unable to auto-configure token authentication"
|
|
|
|
fi
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
|
|
# generated by other debhelper scripts.
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
exit 0
|