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)
|
|
|
|
|
|
|
|
# loading debconf
|
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
|
2016-11-21 21:16:37 +00:00
|
|
|
db_get jitsi-meet-prosody/jvb-hostname
|
|
|
|
JVB_HOSTNAME="$RET"
|
|
|
|
|
2015-11-02 21:02:50 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JVB_HOSTNAME.cfg.lua"
|
|
|
|
|
|
|
|
# Store config filename for purge
|
2016-11-21 21:16:37 +00:00
|
|
|
db_set jitsi-meet-prosody/prosody_config "$PROSODY_HOST_CONFIG"
|
2015-11-02 21:02:50 +00:00
|
|
|
|
|
|
|
db_stop
|
|
|
|
|
|
|
|
if [ -f "$PROSODY_HOST_CONFIG" ] ; then
|
2020-09-02 16:46:32 +00:00
|
|
|
# search for the token auth, if this is not enabled this is the
|
2017-05-12 19:32:38 +00:00
|
|
|
# first time we install tokens package and needs a config change
|
2020-09-02 16:46:32 +00:00
|
|
|
if ! egrep -q '^\s*authentication\s*=\s*"token"' "$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
|
2015-12-22 18:51:43 +00:00
|
|
|
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
|
2015-11-03 17:11:54 +00:00
|
|
|
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-22 18:51:43 +00:00
|
|
|
# Install luajwt
|
2016-08-02 17:34:32 +00:00
|
|
|
if ! luarocks install luajwtjitsi; then
|
|
|
|
echo "Failed to install luajwtjitsi - try installing it manually"
|
2015-12-15 17:46:37 +00:00
|
|
|
fi
|
|
|
|
|
2017-08-08 13:48:18 +00:00
|
|
|
# Install basexx
|
|
|
|
if ! luarocks install basexx; then
|
|
|
|
echo "Failed to install basexx - try installing it manually"
|
|
|
|
fi
|
|
|
|
|
2020-04-08 18:06:49 +00:00
|
|
|
PR10_INSTALL_CHECK="$(dpkg-query -f '${Status}' -W 'prosody-0.10' 2>/dev/null | awk '{print $3}' || true)"
|
|
|
|
PRTRUNK_INSTALL_CHECK="$(dpkg-query -f '${Status}' -W 'prosody-trunk' 2>/dev/null | awk '{print $3}' || true)"
|
2019-04-04 23:18:53 +00:00
|
|
|
PR_VER_INSTALLED=$(dpkg-query -f='${Version}\n' --show prosody 2>/dev/null || true)
|
2020-04-08 18:06:49 +00:00
|
|
|
if [ "$PR10_INSTALL_CHECK" = "installed" ] \
|
2020-05-21 13:18:22 +00:00
|
|
|
|| [ "$PR10_INSTALL_CHECK" = "unpacked" ] \
|
|
|
|
|| [ "$PRTRUNK_INSTALL_CHECK" = "installed" ] \
|
|
|
|
|| [ "$PRTRUNK_INSTALL_CHECK" = "unpacked" ] \
|
2020-04-08 18:06:49 +00:00
|
|
|
|| dpkg --compare-versions "$PR_VER_INSTALLED" lt "0.11" ; then
|
|
|
|
sed -i 's/module:hook_global(/module:hook(/g' /usr/share/jitsi-meet/prosody-plugins/mod_auth_token.lua
|
2019-04-04 23:18:53 +00:00
|
|
|
fi
|
|
|
|
|
2015-11-03 17:14:01 +00:00
|
|
|
if [ -x "/etc/init.d/prosody" ]; then
|
2019-12-02 13:33:35 +00:00
|
|
|
invoke-rc.d prosody restart || true
|
2015-11-03 17:14:01 +00:00
|
|
|
fi
|
2015-11-02 21:02:50 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Prosody config not found at $PROSODY_HOST_CONFIG - unable to auto-configure token authentication"
|
|
|
|
fi
|
2016-06-13 21:11:44 +00:00
|
|
|
|
2015-11-02 21:02:50 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
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
|