"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-5186/debian/jitsi-meet-tokens.postinst" (30 Jul 2021, 4275 Bytes) of package /linux/misc/jitsi-meet-5186.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    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"' "$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 = "anonymous"/authentication = "token"/g' $PROSODY_HOST_CONFIG
   57                 sed -i 's/ --allow_unencrypted_plain_auth/ allow_unencrypted_plain_auth/g' $PROSODY_HOST_CONFIG
   58                 sed -i "s/ --app_id=\"example_app_id\"/ app_id=\"$APP_ID\"/g" $PROSODY_HOST_CONFIG
   59                 sed -i "s/ --app_secret=\"example_app_secret\"/ app_secret=\"$APP_SECRET\"/g" $PROSODY_HOST_CONFIG
   60                 sed -i 's/ --modules_enabled = { "token_verification" }/ modules_enabled = { "token_verification" }/g' $PROSODY_HOST_CONFIG
   61                 sed -i '/^\s*--\s*"token_verification"/ s/--\s*//' $PROSODY_HOST_CONFIG
   62 
   63                 # Install luajwt
   64                 if ! luarocks install luajwtjitsi; then
   65                    echo "Failed to install luajwtjitsi - try installing it manually"
   66                 fi
   67 
   68                 # Install basexx
   69                 if ! luarocks install basexx; then
   70                    echo "Failed to install basexx - try installing it manually"
   71                 fi
   72 
   73                 PR10_INSTALL_CHECK="$(dpkg-query -f '${Status}' -W 'prosody-0.10' 2>/dev/null | awk '{print $3}' || true)"
   74                 PRTRUNK_INSTALL_CHECK="$(dpkg-query -f '${Status}' -W 'prosody-trunk' 2>/dev/null | awk '{print $3}' || true)"
   75                 PR_VER_INSTALLED=$(dpkg-query -f='${Version}\n' --show prosody  2>/dev/null || true)
   76                 if [ "$PR10_INSTALL_CHECK" = "installed" ] \
   77                     || [ "$PR10_INSTALL_CHECK" = "unpacked" ] \
   78                     || [ "$PRTRUNK_INSTALL_CHECK" = "installed" ] \
   79                     || [ "$PRTRUNK_INSTALL_CHECK" = "unpacked" ] \
   80                     || dpkg --compare-versions "$PR_VER_INSTALLED" lt "0.11" ; then
   81                     sed -i 's/module:hook_global(/module:hook(/g' /usr/share/jitsi-meet/prosody-plugins/mod_auth_token.lua
   82                 fi
   83 
   84                 if [ -x "/etc/init.d/prosody" ]; then
   85                     invoke-rc.d prosody restart || true
   86                 fi
   87             fi
   88         else
   89             echo "Prosody config not found at $PROSODY_HOST_CONFIG - unable to auto-configure token authentication"
   90         fi
   91 
   92     ;;
   93 
   94     abort-upgrade|abort-remove|abort-deconfigure)
   95     ;;
   96 
   97     *)
   98         echo "postinst called with unknown argument \`$1'" >&2
   99         exit 1
  100     ;;
  101 esac
  102 
  103 # dh_installdeb will replace this with shell code automatically
  104 # generated by other debhelper scripts.
  105 
  106 #DEBHELPER#
  107 
  108 exit 0