10-config 4.3 KB

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