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-prosody.postinst 8.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. # loading debconf
  20. . /usr/share/debconf/confmodule
  21. # try to get host from jitsi-videobridge
  22. db_get jitsi-videobridge/jvb-hostname
  23. if [ -z "$RET" ] ; then
  24. # server hostname
  25. db_set jitsi-videobridge/jvb-hostname "localhost"
  26. db_input critical jitsi-videobridge/jvb-hostname || true
  27. db_go
  28. fi
  29. JVB_HOSTNAME="$RET"
  30. db_get jitsi-videobridge/jvbsecret
  31. if [ -z "$RET" ] ; then
  32. db_input critical jitsi-videobridge/jvbsecret || true
  33. db_go
  34. fi
  35. JVB_SECRET="$RET"
  36. db_get jicofo/jicofo-authuser
  37. if [ -z "$RET" ] ; then
  38. db_input critical jicofo/jicofo-authuser || true
  39. db_go
  40. fi
  41. JICOFO_AUTH_USER="$RET"
  42. db_get jicofo/jicofo-authpassword
  43. if [ -z "$RET" ] ; then
  44. # if password is missing generate it, and store it
  45. JICOFO_AUTH_PASSWORD=`head -c 8 /dev/urandom | tr '\0-\377' 'a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9@@@@####'`
  46. db_set jicofo/jicofo-authpassword "$JICOFO_AUTH_PASSWORD"
  47. else
  48. JICOFO_AUTH_PASSWORD="$RET"
  49. fi
  50. db_get jicofo/jicofosecret
  51. if [ -z "$RET" ] ; then
  52. # if secret is missing generate it, and store it
  53. JICOFO_SECRET=`head -c 8 /dev/urandom | tr '\0-\377' 'a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9a-zA-Z0-9@@@@####'`
  54. db_set jicofo/jicofosecret "$JICOFO_SECRET"
  55. else
  56. JICOFO_SECRET="$RET"
  57. fi
  58. JICOFO_AUTH_DOMAIN="auth.$JVB_HOSTNAME"
  59. # detect dpkg-reconfigure, just delete old links
  60. db_get jitsi-meet-prosody/jvb-hostname
  61. JVB_HOSTNAME_OLD=$RET
  62. if [ -n "$RET" ] && [ ! "$JVB_HOSTNAME_OLD" = "$JVB_HOSTNAME" ] ; then
  63. rm -f /etc/prosody/conf.d/$JVB_HOSTNAME_OLD.cfg.lua
  64. rm -f /etc/prosody/certs/$JVB_HOSTNAME_OLD.key
  65. rm -f /etc/prosody/certs/$JVB_HOSTNAME_OLD.crt
  66. fi
  67. # stores the hostname so we will reuse it later, like in purge
  68. db_set jitsi-meet-prosody/jvb-hostname "$JVB_HOSTNAME"
  69. # and we're done with debconf
  70. db_stop
  71. PROSODY_CONFIG_PRESENT="true"
  72. PROSODY_CREATE_JICOFO_USER="false"
  73. PROSODY_HOST_CONFIG="/etc/prosody/conf.avail/$JVB_HOSTNAME.cfg.lua"
  74. PROSODY_CONFIG_OLD="/etc/prosody/prosody.cfg.lua"
  75. # if there is no prosody config extract our template
  76. # check for config in conf.avail or check whether it wasn't already configured in main config
  77. if [ ! -f $PROSODY_HOST_CONFIG ] && ! grep -q "VirtualHost \"$JVB_HOSTNAME\"" $PROSODY_CONFIG_OLD; then
  78. PROSODY_CONFIG_PRESENT="false"
  79. mkdir -p /etc/prosody/conf.avail/
  80. mkdir -p /etc/prosody/conf.d/
  81. cp /usr/share/doc/jitsi-meet-prosody/prosody.cfg.lua-jvb.example $PROSODY_HOST_CONFIG
  82. sed -i "s/jitmeet.example.com/$JVB_HOSTNAME/g" $PROSODY_HOST_CONFIG
  83. sed -i "s/jitmeetSecret/$JVB_SECRET/g" $PROSODY_HOST_CONFIG
  84. sed -i "s/focusSecret/$JICOFO_SECRET/g" $PROSODY_HOST_CONFIG
  85. sed -i "s/focusUser/$JICOFO_AUTH_USER/g" $PROSODY_HOST_CONFIG
  86. if [ ! -f /etc/prosody/conf.d/$JVB_HOSTNAME.cfg.lua ]; then
  87. ln -s $PROSODY_HOST_CONFIG /etc/prosody/conf.d/$JVB_HOSTNAME.cfg.lua
  88. fi
  89. PROSODY_CREATE_JICOFO_USER="true"
  90. # on some distributions main prosody config doesn't include configs
  91. # from conf.d folder enable it as this where we put our config by default
  92. if ! grep -q "Include \"conf\.d\/\*\.cfg.lua\"" $PROSODY_CONFIG_OLD; then
  93. echo -e "\nInclude \"conf.d/*.cfg.lua\"" >> $PROSODY_CONFIG_OLD
  94. fi
  95. fi
  96. if [ "$PROSODY_CREATE_JICOFO_USER" = "true" ]; then
  97. # create 'focus@auth.domain' prosody user
  98. prosodyctl register $JICOFO_AUTH_USER $JICOFO_AUTH_DOMAIN $JICOFO_AUTH_PASSWORD
  99. # trigger a restart
  100. PROSODY_CONFIG_PRESENT="false"
  101. fi
  102. if [ ! -f /var/lib/prosody/$JVB_HOSTNAME.crt ]; then
  103. # prosodyctl takes care for the permissions
  104. # echo for using all default values
  105. echo | prosodyctl cert generate $JVB_HOSTNAME
  106. ln -sf /var/lib/prosody/$JVB_HOSTNAME.key /etc/prosody/certs/$JVB_HOSTNAME.key
  107. ln -sf /var/lib/prosody/$JVB_HOSTNAME.crt /etc/prosody/certs/$JVB_HOSTNAME.crt
  108. fi
  109. PR11_INSTALL_CHECK="$(dpkg-query -f '${Status}' -W 'prosody-0.11' 2>/dev/null | awk '{print $3}' || true)"
  110. PR10_INSTALL_CHECK="$(dpkg-query -f '${Status}' -W 'prosody-0.10' 2>/dev/null | awk '{print $3}' || true)"
  111. PR_VER_INSTALLED=$(dpkg-query -f='${Version}\n' --show prosody 2>/dev/null || true)
  112. if [ "$PR11_INSTALL_CHECK" = "installed" ] \
  113. || [ "$PR11_INSTALL_CHECK" = "unpacked" ] \
  114. || dpkg --compare-versions "$PR_VER_INSTALLED" gt "0.11" ; then
  115. if [ -f $PROSODY_HOST_CONFIG ]; then
  116. sed -i 's/storage = \"null\"/storage = \"memory\"/g' $PROSODY_HOST_CONFIG
  117. # trigger a restart
  118. PROSODY_CONFIG_PRESENT="false"
  119. fi
  120. fi
  121. if [ "$PR10_INSTALL_CHECK" = "installed" ] \
  122. || [ "$PR10_INSTALL_CHECK" = "unpacked" ] \
  123. || dpkg --compare-versions "$PR_VER_INSTALLED" gt "0.10" ; then
  124. # if the version is 0.10.X (>0.10 and <0.11)
  125. if [ -f $PROSODY_HOST_CONFIG ] \
  126. && dpkg --compare-versions "$PR_VER_INSTALLED" lt "0.11" ; then
  127. sed -i 's/storage = \"null\"/storage = \"none\"/g' $PROSODY_HOST_CONFIG
  128. # trigger a restart
  129. PROSODY_CONFIG_PRESENT="false"
  130. fi
  131. fi
  132. if [ ! -f /var/lib/prosody/$JICOFO_AUTH_DOMAIN.crt ]; then
  133. # prosodyctl takes care for the permissions
  134. # echo for using all default values
  135. echo | prosodyctl cert generate $JICOFO_AUTH_DOMAIN
  136. AUTH_KEY_FILE="/etc/prosody/certs/$JICOFO_AUTH_DOMAIN.key"
  137. AUTH_CRT_FILE="/etc/prosody/certs/$JICOFO_AUTH_DOMAIN.crt"
  138. ln -sf /var/lib/prosody/$JICOFO_AUTH_DOMAIN.key $AUTH_KEY_FILE
  139. ln -sf /var/lib/prosody/$JICOFO_AUTH_DOMAIN.crt $AUTH_CRT_FILE
  140. ln -sf /var/lib/prosody/$JICOFO_AUTH_DOMAIN.crt /usr/local/share/ca-certificates/$JICOFO_AUTH_DOMAIN.crt
  141. # we need to force updating certificates, in some cases java trust
  142. # store not get re-generated with latest changes
  143. update-ca-certificates -f
  144. # don't fail on systems with custom config ($PROSODY_HOST_CONFIG is missing)
  145. if [ -f $PROSODY_HOST_CONFIG ]; then
  146. # now let's add the ssl cert for the auth. domain (we use # as a sed delimiter cause filepaths are confused with default / delimiter)
  147. sed -i "s#VirtualHost \"$JICOFO_AUTH_DOMAIN\"#VirtualHost \"$JICOFO_AUTH_DOMAIN\"\n ssl = {\n key = \"$AUTH_KEY_FILE\";\n certificate = \"$AUTH_CRT_FILE\";\n \}#g" $PROSODY_HOST_CONFIG
  148. fi
  149. # trigger a restart
  150. PROSODY_CONFIG_PRESENT="false"
  151. fi
  152. if [ "$PROSODY_CONFIG_PRESENT" = "false" ]; then
  153. invoke-rc.d prosody restart
  154. fi
  155. ;;
  156. abort-upgrade|abort-remove|abort-deconfigure)
  157. ;;
  158. *)
  159. echo "postinst called with unknown argument \`$1'" >&2
  160. exit 1
  161. ;;
  162. esac
  163. # dh_installdeb will replace this with shell code automatically
  164. # generated by other debhelper scripts.
  165. #DEBHELPER#
  166. exit 0