2
0

10-config 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/usr/bin/with-contenv bash
  2. # make our folders
  3. mkdir -p \
  4. /config/{nginx/site-confs,keys} \
  5. /run \
  6. /var/lib/nginx/tmp/client_body \
  7. /var/tmp/nginx
  8. # generate keys (maybe)
  9. if [[ $DISABLE_HTTPS -ne 1 ]]; then
  10. if [[ $ENABLE_LETSENCRYPT -eq 1 ]]; then
  11. if [[ ! -f /etc/letsencrypt/live/$LETSENCRYPT_DOMAIN/fullchain.pem ]]; then
  12. if ! certbot-auto \
  13. certonly \
  14. --no-self-upgrade \
  15. --noninteractive \
  16. --standalone \
  17. --preferred-challenges http \
  18. -d $LETSENCRYPT_DOMAIN \
  19. --agree-tos \
  20. --email $LETSENCRYPT_EMAIL ; then
  21. echo "Failed to obtain a certificate from the Let's Encrypt CA."
  22. # this tries to get the user's attention and to spare the
  23. # authority's rate limit:
  24. sleep 15
  25. echo "Exiting."
  26. exit 1
  27. fi
  28. fi
  29. # remove default certbot renewal
  30. if [[ -f /etc/cron.d/certbot ]]; then
  31. rm /etc/cron.d/certbot
  32. fi
  33. # setup certbot renewal script
  34. if [[ ! -f /etc/cron.daily/letencrypt-renew ]]; then
  35. cp /defaults/letsencrypt-renew /etc/cron.daily/
  36. fi
  37. else
  38. # use self-signed certs
  39. if [[ -f /config/keys/cert.key && -f /config/keys/cert.crt ]]; then
  40. echo "using keys found in /config/keys"
  41. else
  42. echo "generating self-signed keys in /config/keys, you can replace these with your own keys if required"
  43. SUBJECT="/C=US/ST=TX/L=Austin/O=jitsi.org/OU=Jitsi Server/CN=*"
  44. openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT"
  45. fi
  46. fi
  47. fi
  48. # copy config files
  49. if [[ ! -f /config/nginx/nginx.conf ]]; then
  50. cp /defaults/nginx.conf /config/nginx/nginx.conf
  51. fi
  52. if [[ ! -f /config/nginx/meet.conf ]]; then
  53. tpl /defaults/meet.conf > /config/nginx/meet.conf
  54. fi
  55. if [[ ! -f /config/nginx/ssl.conf ]]; then
  56. tpl /defaults/ssl.conf > /config/nginx/ssl.conf
  57. fi
  58. if [[ ! -f /config/nginx/site-confs/default ]]; then
  59. tpl /defaults/default > /config/nginx/site-confs/default
  60. fi
  61. if [[ ! -f /config/config.js ]]; then
  62. cp /defaults/config.js /config/config.js
  63. sed -i \
  64. -e "s#jitsi-meet.example.com#$XMPP_DOMAIN#g" \
  65. -e "s#bosh:.*#bosh: '/http-bind',#" \
  66. -e "s#muc:.*#muc: '${XMPP_MUC_DOMAIN}',#" \
  67. -e "s#// focusUserJid:.*#focusUserJid: '${JICOFO_AUTH_USER}@${XMPP_AUTH_DOMAIN}',#" \
  68. /config/config.js
  69. if [[ $ENABLE_RECORDING -eq 1 || x$ENABLE_RECORDING == xtrue ]]; then
  70. sed -i \
  71. -e "/\/\/ Recording.*/a hiddenDomain: '$XMPP_RECORDER_DOMAIN'," \
  72. -e "s#// fileRecordingsEnabled:.*#fileRecordingsEnabled: true,#" \
  73. -e "s#// liveStreamingEnabled:.*#liveStreamingEnabled: true,#" \
  74. /config/config.js
  75. fi
  76. if [[ $ENABLE_AUTH -eq 1 ]]; then
  77. if [[ $ENABLE_GUESTS -eq 1 ]]; then
  78. sed -i \
  79. -e "s#// anonymousdomain:.*#anonymousdomain: '${XMPP_GUEST_DOMAIN}',#" \
  80. /config/config.js
  81. fi
  82. sed -i \
  83. -e "s#// authdomain:.*#authdomain: '${XMPP_DOMAIN}',#" \
  84. /config/config.js
  85. fi
  86. if [[ -z "$(grep -om1 'etherpad_base:' /config/config.js)" ]]; then
  87. if [[ ! -z "${ETHERPAD_PUBLIC_URL}" ]]; then
  88. sed -i \
  89. -e "/enableWelcomePage/a\ etherpad_base: '${ETHERPAD_PUBLIC_URL}/p/'," \
  90. /config/config.js
  91. elif [[ ! -z "${ETHERPAD_URL_BASE}" ]]; then
  92. sed -i \
  93. -e "/enableWelcomePage/a\ etherpad_base: '${PUBLIC_URL}/etherpad/p/'," \
  94. /config/config.js
  95. fi
  96. fi
  97. if [[ $ENABLE_TRANSCRIPTIONS -eq 1 || "$ENABLE_TRANSCRIPTIONS" == "true" ]]; then
  98. sed -i \
  99. -e "s#// transcribingEnabled:.*#transcribingEnabled: true,#" \
  100. /config/config.js
  101. fi
  102. fi
  103. if [[ ! -f /config/interface_config.js ]]; then
  104. cp /defaults/interface_config.js /config/interface_config.js
  105. # It will remove parameter 'closedcaptions' from TOOLBAR_BUTTONS if ENABLE_TRANSCRIPTIONS is false,
  106. # because it enabled by default, but not supported out of the box.
  107. if [[ $ENABLE_TRANSCRIPTIONS -ne 1 && "$ENABLE_TRANSCRIPTIONS" != "true" ]]; then
  108. sed -i \
  109. -e "s#'closedcaptions', ##" \
  110. /config/interface_config.js
  111. fi
  112. fi