1 #!/bin/bash 2 # postinst script for jitsi-meet-tokens 3 # 4 # see: dh_installdeb(1) 5 6 set -e 7 8 # summary of how this script can be called: 9 # * <postinst> `configure' <most-recently-configured-version> 10 # * <old-postinst> `abort-upgrade' <new version> 11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package> 12 # <new-version> 13 # * <postinst> `abort-remove' 14 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour' 15 # <failed-install-package> <version> `removing' 16 # <conflicting-package> <version> 17 # for details, see http://www.debian.org/doc/debian-policy/ or 18 # the debian-policy package 19 20 21 case "$1" in 22 configure) 23 24 # loading debconf 25 . /usr/share/debconf/confmodule 26 27 db_get jitsi-meet-prosody/jvb-hostname 28 JVB_HOSTNAME=$(echo "$RET" | xargs echo -n) 29 30 db_get jitsi-meet-tokens/appid 31 if [ "$RET" = "false" ] ; then 32 echo "Application ID is mandatory" 33 exit 1 34 fi 35 APP_ID=$RET 36 37 db_get jitsi-meet-tokens/appsecret 38 if [ "$RET" = "false" ] ; then 39 echo "Application secret is mandatory" 40 fi 41 APP_SECRET=$RET 42 43 PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JVB_HOSTNAME.cfg.lua" 44 45 # Store config filename for purge 46 db_set jitsi-meet-prosody/prosody_config "$PROSODY_HOST_CONFIG" 47 48 db_stop 49 50 if [ -f "$PROSODY_HOST_CONFIG" ] ; then 51 # search for the token auth, if this is not enabled this is the 52 # first time we install tokens package and needs a config change 53 if ! egrep -q '^\s*authentication\s*=\s*"token" -- do not delete me' "$PROSODY_HOST_CONFIG"; then 54 # enable tokens in prosody host config 55 sed -i 's/--plugin_paths/plugin_paths/g' $PROSODY_HOST_CONFIG 56 sed -i 's/authentication = "jitsi-anonymous" -- do not delete me/authentication = "token" -- do not delete me/g' $PROSODY_HOST_CONFIG 57 sed -i "s/ --app_id=\"example_app_id\"/ app_id=\"$APP_ID\"/g" $PROSODY_HOST_CONFIG 58 sed -i "s/ --app_secret=\"example_app_secret\"/ app_secret=\"$APP_SECRET\"/g" $PROSODY_HOST_CONFIG 59 sed -i 's/ --modules_enabled = { "token_verification" }/ modules_enabled = { "token_verification" }/g' $PROSODY_HOST_CONFIG 60 sed -i '/^\s*--\s*"token_verification"/ s/--\s*//' $PROSODY_HOST_CONFIG 61 62 if [ -x "/etc/init.d/prosody" ]; then 63 invoke-rc.d prosody restart || true 64 fi 65 fi 66 else 67 echo "Prosody config not found at $PROSODY_HOST_CONFIG - unable to auto-configure token authentication" 68 fi 69 70 ;; 71 72 abort-upgrade|abort-remove|abort-deconfigure) 73 ;; 74 75 *) 76 echo "postinst called with unknown argument \`$1'" >&2 77 exit 1 78 ;; 79 esac 80 81 # dh_installdeb will replace this with shell code automatically 82 # generated by other debhelper scripts. 83 84 #DEBHELPER# 85 86 exit 0