"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7563/debian/jitsi-meet-tokens.postinst" (2 Oct 2023, 3252 Bytes) of package /linux/misc/jitsi-meet-7563.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. See also the last Fossies "Diffs" side-by-side code changes report for "jitsi-meet-tokens.postinst": 7547_vs_7550.

    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         # Not allowed unix special characters in secret: /, \, ", ', `
   42         if echo "$RET" | grep -q "[/\\\"\`\']" ; then
   43             echo "Application secret contains invalid characters: /, \\, \", ', \`"
   44             exit 1
   45         fi
   46         APP_SECRET=$RET
   47 
   48         PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JVB_HOSTNAME.cfg.lua"
   49 
   50         # Store config filename for purge
   51         db_set jitsi-meet-prosody/prosody_config "$PROSODY_HOST_CONFIG"
   52 
   53         db_stop
   54 
   55         if [ -f "$PROSODY_HOST_CONFIG" ] ; then
   56             # search for the token auth, if this is not enabled this is the
   57             # first time we install tokens package and needs a config change
   58             if ! egrep -q '^\s*authentication\s*=\s*"token" -- do not delete me' "$PROSODY_HOST_CONFIG"; then
   59                 # enable tokens in prosody host config
   60                 sed -i 's/--plugin_paths/plugin_paths/g' $PROSODY_HOST_CONFIG
   61                 sed -i 's/authentication = "jitsi-anonymous" -- do not delete me/authentication = "token" -- do not delete me/g' $PROSODY_HOST_CONFIG
   62                 sed -i "s/ --app_id=\"example_app_id\"/ app_id=\"$APP_ID\"/g" $PROSODY_HOST_CONFIG
   63                 sed -i "s/ --app_secret=\"example_app_secret\"/ app_secret=\"$APP_SECRET\"/g" $PROSODY_HOST_CONFIG
   64                 sed -i 's/ --modules_enabled = { "token_verification" }/ modules_enabled = { "token_verification" }/g' $PROSODY_HOST_CONFIG
   65                 sed -i '/^\s*--\s*"token_verification"/ s/--\s*//' $PROSODY_HOST_CONFIG
   66 
   67                 if [ -x "/etc/init.d/prosody" ]; then
   68                     invoke-rc.d prosody restart || true
   69                 fi
   70             fi
   71         else
   72             echo "Prosody config not found at $PROSODY_HOST_CONFIG - unable to auto-configure token authentication"
   73         fi
   74 
   75     ;;
   76 
   77     abort-upgrade|abort-remove|abort-deconfigure)
   78     ;;
   79 
   80     *)
   81         echo "postinst called with unknown argument \`$1'" >&2
   82         exit 1
   83     ;;
   84 esac
   85 
   86 # dh_installdeb will replace this with shell code automatically
   87 # generated by other debhelper scripts.
   88 
   89 #DEBHELPER#
   90 
   91 exit 0