10-config 3.7 KB

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