10-config 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 /config/acme.sh/acme.sh ]]; then
  12. mkdir /config/acme.sh
  13. pushd /opt
  14. sh ./acme.sh --install --home /config/acme.sh --accountemail $LETSENCRYPT_EMAIL
  15. popd
  16. fi
  17. if [[ ! -f /etc/nginx/acme/$LETSENCRYPT_DOMAIN/fullchain.pem ]]; then
  18. STAGING=""
  19. if [[ $LETSENCRYPT_USE_STAGING -eq 1 ]]; then
  20. STAGING="--staging"
  21. fi
  22. # TODO: move away from standalone mode to webroot mode.
  23. if ! /config/acme.sh/acme.sh \
  24. $STAGING \
  25. --issue \
  26. --standalone \
  27. --pre-hook "if [[ -f /var/run/s6/services/nginx ]]; then s6-svc -d /var/run/s6/services/nginx; fi" \
  28. --post-hook "if [[ -f /var/run/s6/services/nginx ]]; then s6-svc -u /var/run/s6/services/nginx; fi" \
  29. -d $LETSENCRYPT_DOMAIN ; then
  30. echo "Failed to obtain a certificate from the Let's Encrypt CA."
  31. # this tries to get the user's attention and to spare the
  32. # authority's rate limit:
  33. sleep 15
  34. echo "Exiting."
  35. exit 1
  36. fi
  37. mkdir -p /etc/nginx/acme/$LETSENCRYPT_DOMAIN
  38. if ! /config/acme.sh/acme.sh \
  39. --install-cert -d $LETSENCRYPT_DOMAIN \
  40. --key-file /etc/nginx/acme/$LETSENCRYPT_DOMAIN/key.pem \
  41. --fullchain-file /etc/nginx/acme/$LETSENCRYPT_DOMAIN/fullchain.pem ; then
  42. echo "Failed to install certificate."
  43. # this tries to get the user's attention and to spare the
  44. # authority's rate limit:
  45. sleep 15
  46. echo "Exiting."
  47. exit 1
  48. fi
  49. fi
  50. else
  51. # use self-signed certs
  52. if [[ -f /config/keys/cert.key && -f /config/keys/cert.crt ]]; then
  53. echo "using keys found in /config/keys"
  54. else
  55. echo "generating self-signed keys in /config/keys, you can replace these with your own keys if required"
  56. SUBJECT="/C=US/ST=TX/L=Austin/O=jitsi.org/OU=Jitsi Server/CN=*"
  57. openssl req -new -x509 -days 3650 -nodes -out /config/keys/cert.crt -keyout /config/keys/cert.key -subj "$SUBJECT"
  58. fi
  59. fi
  60. fi
  61. # copy config files
  62. tpl /defaults/nginx.conf > /config/nginx/nginx.conf
  63. tpl /defaults/meet.conf > /config/nginx/meet.conf
  64. if [[ -f /config/nginx/custom-meet.conf ]]; then
  65. cat /config/nginx/custom-meet.conf >> /config/nginx/meet.conf
  66. fi
  67. tpl /defaults/ssl.conf > /config/nginx/ssl.conf
  68. tpl /defaults/default > /config/nginx/site-confs/default
  69. cp /defaults/config.js /config/config.js
  70. tpl /defaults/system-config.js >> /config/config.js
  71. tpl /defaults/settings-config.js >> /config/config.js
  72. if [[ -f /config/custom-config.js ]]; then
  73. cat /config/custom-config.js >> /config/config.js
  74. fi
  75. if [[ ! -f /config/interface_config.js ]]; then
  76. cp /defaults/interface_config.js /config/interface_config.js
  77. # It will remove parameter 'closedcaptions' from TOOLBAR_BUTTONS if ENABLE_TRANSCRIPTIONS is false,
  78. # because it enabled by default, but not supported out of the box.
  79. if [[ $ENABLE_TRANSCRIPTIONS -ne 1 && "$ENABLE_TRANSCRIPTIONS" != "true" ]]; then
  80. sed -i \
  81. -e "s#'closedcaptions', ##" \
  82. /config/interface_config.js
  83. fi
  84. fi