10-config 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. fi
  46. # copy config files
  47. if [[ ! -f /config/nginx/nginx.conf ]]; then
  48. cp /defaults/nginx.conf /config/nginx/nginx.conf
  49. fi
  50. if [[ ! -f /config/nginx/meet.conf ]]; then
  51. tpl /defaults/meet.conf > /config/nginx/meet.conf
  52. fi
  53. if [[ ! -f /config/nginx/ssl.conf ]]; then
  54. tpl /defaults/ssl.conf > /config/nginx/ssl.conf
  55. fi
  56. if [[ ! -f /config/nginx/site-confs/default ]]; then
  57. tpl /defaults/default > /config/nginx/site-confs/default
  58. fi
  59. if [[ ! -f /config/config.js ]]; then
  60. cp /defaults/config.js /config/config.js
  61. sed -i \
  62. -e "s#jitsi-meet.example.com#$XMPP_DOMAIN#g" \
  63. -e "s#bosh:.*#bosh: '/http-bind',#" \
  64. -e "s#muc:.*#muc: '${XMPP_MUC_DOMAIN}',#" \
  65. -e "s#// focusUserJid:.*#focusUserJid: '${JICOFO_AUTH_USER}@${XMPP_AUTH_DOMAIN}',#" \
  66. /config/config.js
  67. if [[ $ENABLE_RECORDING -eq 1 || x$ENABLE_RECORDING == xtrue ]]; then
  68. sed -i \
  69. -e "/\/\/ Recording.*/a hiddenDomain: '$XMPP_RECORDER_DOMAIN'," \
  70. -e "s#// fileRecordingsEnabled:.*#fileRecordingsEnabled: true,#" \
  71. -e "s#// liveStreamingEnabled:.*#liveStreamingEnabled: true,#" \
  72. /config/config.js
  73. fi
  74. if [[ $ENABLE_AUTH -eq 1 ]]; then
  75. if [[ $ENABLE_GUESTS -eq 1 ]]; then
  76. sed -i \
  77. -e "s#// anonymousdomain:.*#anonymousdomain: '${XMPP_GUEST_DOMAIN}',#" \
  78. /config/config.js
  79. fi
  80. sed -i \
  81. -e "s#// authdomain:.*#authdomain: '${XMPP_DOMAIN}',#" \
  82. /config/config.js
  83. fi
  84. if [[ ! -z "${ETHERPAD_URL_BASE}" && -z "$(grep -om1 'etherpad_base:' /config/config.js)" ]]; then
  85. sed -i \
  86. -e "/enableWelcomePage/a\ etherpad_base: '${PUBLIC_URL}/etherpad/p/'," \
  87. /config/config.js
  88. fi
  89. if [[ $ENABLE_TRANSCRIPTIONS -eq 1 || "$ENABLE_TRANSCRIPTIONS" == "true" ]]; then
  90. sed -i \
  91. -e "s#// transcribingEnabled:.*#transcribingEnabled: true,#" \
  92. /config/config.js
  93. fi
  94. fi
  95. if [[ ! -f /config/interface_config.js ]]; then
  96. cp /defaults/interface_config.js /config/interface_config.js
  97. # It will remove parameter 'closedcaptions' from TOOLBAR_BUTTONS if ENABLE_TRANSCRIPTIONS is false,
  98. # because it enabled by default, but not supported out of the box.
  99. if [[ $ENABLE_TRANSCRIPTIONS -ne 1 || "$ENABLE_TRANSCRIPTIONS" != "true" ]]; then
  100. sed -i \
  101. -e "s#'closedcaptions', ##" \
  102. /config/interface_config.js
  103. fi
  104. fi