您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

jitsi-meet-turnserver.postinst 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #!/bin/bash
  2. # postinst script for jitsi-meet-turnserver
  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=$(echo "$RET" | xargs echo -n)
  30. TURN_CONFIG="/etc/turnserver.conf"
  31. JITSI_MEET_CONFIG="/etc/jitsi/meet/$JVB_HOSTNAME-config.js"
  32. # if there was a turn config backup it so we can configure
  33. # we cannot recognize at the moment is this a user config or default config when installing coturn
  34. if [[ -f $TURN_CONFIG ]] && ! grep -q "jitsi-meet coturn config" "$TURN_CONFIG" ; then
  35. mv $TURN_CONFIG $TURN_CONFIG.bak
  36. fi
  37. # detect dpkg-reconfigure, just delete old links
  38. db_get jitsi-meet-turnserver/jvb-hostname
  39. JVB_HOSTNAME_OLD=$(echo "$RET" | xargs echo -n)
  40. if [ -n "$RET" ] && [ ! "$JVB_HOSTNAME_OLD" = "$JVB_HOSTNAME" ] ; then
  41. if [[ -f $TURN_CONFIG ]] && grep -q "jitsi-meet coturn config" "$TURN_CONFIG" ; then
  42. rm -f $TURN_CONFIG
  43. fi
  44. fi
  45. if [[ -f $TURN_CONFIG ]] ; then
  46. echo "------------------------------------------------"
  47. echo ""
  48. echo "turnserver is already configured on this machine."
  49. echo ""
  50. echo "------------------------------------------------"
  51. if grep -q "jitsi-meet coturn config" "$TURN_CONFIG" && ! grep -q "jitsi-meet coturn relay disable config" "$TURN_CONFIG" ; then
  52. echo "Updating coturn config"
  53. echo "# jitsi-meet coturn relay disable config. Do not modify this line
  54. no-multicast-peers
  55. no-cli
  56. no-loopback-peers
  57. no-tcp-relay
  58. denied-peer-ip=0.0.0.0-0.255.255.255
  59. denied-peer-ip=10.0.0.0-10.255.255.255
  60. denied-peer-ip=100.64.0.0-100.127.255.255
  61. denied-peer-ip=127.0.0.0-127.255.255.255
  62. denied-peer-ip=169.254.0.0-169.254.255.255
  63. denied-peer-ip=127.0.0.0-127.255.255.255
  64. denied-peer-ip=172.16.0.0-172.31.255.255
  65. denied-peer-ip=192.0.0.0-192.0.0.255
  66. denied-peer-ip=192.0.2.0-192.0.2.255
  67. denied-peer-ip=192.88.99.0-192.88.99.255
  68. denied-peer-ip=192.168.0.0-192.168.255.255
  69. denied-peer-ip=198.18.0.0-198.19.255.255
  70. denied-peer-ip=198.51.100.0-198.51.100.255
  71. denied-peer-ip=203.0.113.0-203.0.113.255
  72. denied-peer-ip=240.0.0.0-255.255.255.255" >> $TURN_CONFIG
  73. invoke-rc.d coturn restart || true
  74. fi
  75. db_stop
  76. exit 0
  77. fi
  78. # stores the hostname so we will reuse it later, like in purge
  79. db_set jitsi-meet-turnserver/jvb-hostname "$JVB_HOSTNAME"
  80. # try to get turnserver password
  81. db_get jitsi-meet-prosody/turn-secret
  82. if [ -z "$RET" ] ; then
  83. db_input critical jitsi-meet-prosody/turn-secret || true
  84. db_go
  85. fi
  86. TURN_SECRET="$RET"
  87. # no turn config exists, lt's copy template and fill it in
  88. cp /usr/share/jitsi-meet-turnserver/turnserver.conf $TURN_CONFIG
  89. sed -i "s/jitsi-meet.example.com/$JVB_HOSTNAME/g" $TURN_CONFIG
  90. sed -i "s/__turnSecret__/$TURN_SECRET/g" $TURN_CONFIG
  91. # SSL settings
  92. db_get jitsi-meet/cert-choice
  93. CERT_CHOICE="$RET"
  94. if [ "$CERT_CHOICE" = "I want to use my own certificate" ] ; then
  95. db_get jitsi-meet/cert-path-key
  96. CERT_KEY="$RET"
  97. db_get jitsi-meet/cert-path-crt
  98. CERT_CRT="$RET"
  99. # replace self-signed certificate paths with user provided ones
  100. CERT_KEY_ESC=$(echo $CERT_KEY | sed 's/\./\\\./g')
  101. CERT_KEY_ESC=$(echo $CERT_KEY_ESC | sed 's/\//\\\//g')
  102. sed -i "s/pkey=\/etc\/jitsi\/meet\/.*key/pkey=$CERT_KEY_ESC/g" $TURN_CONFIG
  103. CERT_CRT_ESC=$(echo $CERT_CRT | sed 's/\./\\\./g')
  104. CERT_CRT_ESC=$(echo $CERT_CRT_ESC | sed 's/\//\\\//g')
  105. sed -i "s/cert=\/etc\/jitsi\/meet\/.*crt/cert=$CERT_CRT_ESC/g" $TURN_CONFIG
  106. fi
  107. sed -i "s/#TURNSERVER_ENABLED/TURNSERVER_ENABLED/g" /etc/default/coturn
  108. invoke-rc.d coturn restart || true
  109. NGINX_STREAM_CONFIG="/etc/nginx/modules-enabled/60-jitsi-meet.conf"
  110. if [ -f $NGINX_STREAM_CONFIG ] ; then
  111. echo "------------------------------------------------"
  112. echo ""
  113. echo "You have multiplexing enabled, it is recommended to disable it and migrate to using websockets for the bridge channel."
  114. echo "The support for sctp data channels is deprecated and will be dropped at some point."
  115. echo "How to do it at: https://jitsi.org/multiplexing-to-bridge-ws-howto"
  116. echo ""
  117. echo "------------------------------------------------"
  118. fi
  119. # and we're done with debconf
  120. db_stop
  121. ;;
  122. abort-upgrade|abort-remove|abort-deconfigure)
  123. ;;
  124. *)
  125. echo "postinst called with unknown argument \`$1'" >&2
  126. exit 1
  127. ;;
  128. esac
  129. # dh_installdeb will replace this with shell code automatically
  130. # generated by other debhelper scripts.
  131. #DEBHELPER#
  132. exit 0