10-config 3.3 KB

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