10-config 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. cp /defaults/config.js /config/config.js
  62. tpl /defaults/system-config.js >> /config/config.js
  63. tpl /defaults/settings-config.js >> /config/config.js
  64. if [[ -f /config/custom-config.js ]]; then
  65. cat /config/custom-config.js >> /config/config.js
  66. fi
  67. if [[ ! -f /config/interface_config.js ]]; then
  68. cp /defaults/interface_config.js /config/interface_config.js
  69. # It will remove parameter 'closedcaptions' from TOOLBAR_BUTTONS if ENABLE_TRANSCRIPTIONS is false,
  70. # because it enabled by default, but not supported out of the box.
  71. if [[ $ENABLE_TRANSCRIPTIONS -ne 1 && "$ENABLE_TRANSCRIPTIONS" != "true" ]]; then
  72. sed -i \
  73. -e "s#'closedcaptions', ##" \
  74. /config/interface_config.js
  75. fi
  76. fi