10-config 3.7 KB

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