You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jitsi-meet-prosody.postinst 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. # postinst script for jitsi-meet-prosody
  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. . /etc/jitsi/videobridge/config
  20. . /etc/jitsi/jicofo/config
  21. # loading debconf
  22. . /usr/share/debconf/confmodule
  23. # stores the hostname so we will reuse it later, like in purge
  24. db_set jitsi-meet-prosody/jvb-hostname $JVB_HOSTNAME
  25. # and we're done with debconf
  26. db_stop
  27. PROSODY_CONFIG_PRESENT="true"
  28. PROSODY_CREATE_JICOFO_USER="false"
  29. PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JVB_HOSTNAME.cfg.lua"
  30. PROSODY_CONFIG_OLD="/etc/prosody/prosody.cfg.lua"
  31. # if there is no prosody config extract our template
  32. # check for config in conf.avail or check whether it wasn't already configured in main config
  33. if [ ! -f $PROSODY_HOST_CONFIG ] && ! grep -q "VirtualHost \"$JVB_HOSTNAME\"" $PROSODY_CONFIG_OLD; then
  34. PROSODY_CONFIG_PRESENT="false"
  35. mkdir -p /etc/prosody/conf.avail/
  36. cp /usr/share/doc/jitsi-meet-prosody/prosody.cfg.lua-jvb.example $PROSODY_HOST_CONFIG
  37. sed -i "s/jitmeet.example.com/$JVB_HOSTNAME/g" $PROSODY_HOST_CONFIG
  38. sed -i "s/jitmeetSecret/$JVB_SECRET/g" $PROSODY_HOST_CONFIG
  39. sed -i "s/focusSecret/$JICOFO_SECRET/g" $PROSODY_HOST_CONFIG
  40. sed -i "s/focusUser/$JICOFO_AUTH_USER/g" $PROSODY_HOST_CONFIG
  41. if [ ! -f /etc/prosody/conf.d/$JVB_HOSTNAME.cfg.lua ]; then
  42. ln -s $PROSODY_HOST_CONFIG /etc/prosody/conf.d/$JVB_HOSTNAME.cfg.lua
  43. fi
  44. PROSODY_CREATE_JICOFO_USER="true"
  45. # on some distributions main prosody config doesn't include configs
  46. # from conf.d folder enable it as this where we put our config by default
  47. if ! grep -q "Include \"conf\.d\/\*\.cfg.lua\"" $PROSODY_CONFIG_OLD; then
  48. echo -e "\nInclude \"conf.d/*.cfg.lua\"" >> $PROSODY_CONFIG_OLD
  49. fi
  50. fi
  51. # UPGRADE to server side focus check if focus is configured
  52. if [ -f $PROSODY_HOST_CONFIG ] && ! grep -q "VirtualHost \"auth.$JVB_HOSTNAME\"" $PROSODY_HOST_CONFIG; then
  53. echo -e "\nVirtualHost \"auth.$JVB_HOSTNAME\"" >> $PROSODY_HOST_CONFIG
  54. echo -e " authentication = \"internal_plain\"\n" >> $PROSODY_HOST_CONFIG
  55. sed -i "s/Component \"conference.$JVB_HOSTNAME\" \"muc\"/Component \"conference.$JVB_HOSTNAME\" \"muc\"\nadmins = { \"$JICOFO_AUTH_USER@auth.$JVB_HOSTNAME\" }\n/g" $PROSODY_HOST_CONFIG
  56. echo -e "Component \"focus.$JVB_HOSTNAME\"" >> $PROSODY_HOST_CONFIG
  57. echo -e " component_secret=\"$JICOFO_SECRET\"\n" >> $PROSODY_HOST_CONFIG
  58. PROSODY_CREATE_JICOFO_USER="true"
  59. # UPGRADE to server side focus on old config(/etc/prosody/prosody.cfg.lua)
  60. elif [ ! -f $PROSODY_HOST_CONFIG ] && ! grep -q "VirtualHost \"auth.$JVB_HOSTNAME\"" $PROSODY_CONFIG_OLD; then
  61. echo -e "\nVirtualHost \"auth.$JVB_HOSTNAME\"" >> $PROSODY_CONFIG_OLD
  62. echo -e " authentication = \"internal_plain\"\n" >> $PROSODY_CONFIG_OLD
  63. if ! grep -q "admins = { }" $PROSODY_CONFIG_OLD; then
  64. echo -e "admins = { \"$JICOFO_AUTH_USER@auth.$JVB_HOSTNAME\" }\n" >> $PROSODY_CONFIG_OLD
  65. else
  66. sed -i "s/admins = { }/admins = { \"$JICOFO_AUTH_USER@auth.$JVB_HOSTNAME\" }\n/g" $PROSODY_CONFIG_OLD
  67. fi
  68. echo -e "Component \"focus.$JVB_HOSTNAME\"" >> $PROSODY_CONFIG_OLD
  69. echo -e " component_secret=\"$JICOFO_SECRET\"\n" >> $PROSODY_CONFIG_OLD
  70. PROSODY_CREATE_JICOFO_USER="true"
  71. fi
  72. if [ "$PROSODY_CREATE_JICOFO_USER" = "true" ]; then
  73. # create 'focus@auth.domain' prosody user
  74. prosodyctl register $JICOFO_AUTH_USER $JICOFO_AUTH_DOMAIN $JICOFO_AUTH_PASSWORD
  75. # trigger a restart
  76. PROSODY_CONFIG_PRESENT="false"
  77. fi
  78. if [ ! -f /var/lib/prosody/$JVB_HOSTNAME.crt ]; then
  79. HOST="$( (hostname -s; echo localhost) | head -n 1)"
  80. DOMAIN="$( (hostname -d; echo localdomain) | head -n 1)"
  81. openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 -subj \
  82. "/O=$DOMAIN/OU=$HOST/CN=$JVB_HOSTNAME/emailAddress=webmaster@$HOST.$DOMAIN" \
  83. -keyout /var/lib/prosody/$JVB_HOSTNAME.key \
  84. -out /var/lib/prosody/$JVB_HOSTNAME.crt
  85. fi
  86. ln -sf /var/lib/prosody/$JVB_HOSTNAME.key /etc/prosody/certs/$JVB_HOSTNAME.key
  87. ln -sf /var/lib/prosody/$JVB_HOSTNAME.crt /etc/prosody/certs/$JVB_HOSTNAME.crt
  88. if [ "$PROSODY_CONFIG_PRESENT" = "false" ]; then
  89. invoke-rc.d prosody restart
  90. invoke-rc.d jitsi-videobridge restart
  91. invoke-rc.d jicofo restart
  92. fi
  93. ;;
  94. abort-upgrade|abort-remove|abort-deconfigure)
  95. ;;
  96. *)
  97. echo "postinst called with unknown argument \`$1'" >&2
  98. exit 1
  99. ;;
  100. esac
  101. # dh_installdeb will replace this with shell code automatically
  102. # generated by other debhelper scripts.
  103. #DEBHELPER#
  104. exit 0