Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

jitsi-meet-tokens.postinst 3.8KB

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