Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

install-letsencrypt-cert.sh 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/bin/bash
  2. set -e
  3. DEB_CONF_RESULT=`debconf-show jitsi-meet-web-config | grep jvb-hostname`
  4. DOMAIN="${DEB_CONF_RESULT##*:}"
  5. # remove whitespace
  6. DOMAIN="$(echo -e "${DOMAIN}" | tr -d '[:space:]')"
  7. echo "-------------------------------------------------------------------------"
  8. echo "This script will:"
  9. echo "- Need a working DNS record pointing to this machine(for domain ${DOMAIN})"
  10. echo "- Download certbot-auto from https://dl.eff.org to /usr/local/sbin"
  11. echo "- Install additional dependencies in order to request Let’s Encrypt certificate"
  12. echo "- If running with jetty serving web content, will stop Jitsi Videobridge"
  13. echo "- Configure and reload nginx or apache2, whichever is used"
  14. echo ""
  15. echo "You need to agree to the ACME server's Subscriber Agreement (https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf) "
  16. echo "by providing an email address for important account notifications"
  17. echo -n "Enter your email and press [ENTER]: "
  18. read EMAIL
  19. cd /usr/local/sbin
  20. if [ ! -f certbot-auto ] ; then
  21. wget https://dl.eff.org/certbot-auto
  22. chmod a+x ./certbot-auto
  23. fi
  24. CRON_FILE="/etc/cron.weekly/letsencrypt-renew"
  25. echo "#!/bin/bash" > $CRON_FILE
  26. echo "/usr/local/sbin/certbot-auto renew >> /var/log/le-renew.log" >> $CRON_FILE
  27. CERT_KEY="/etc/letsencrypt/live/$DOMAIN/privkey.pem"
  28. CERT_CRT="/etc/letsencrypt/live/$DOMAIN/fullchain.pem"
  29. if [ -f /etc/nginx/sites-enabled/$DOMAIN.conf ] ; then
  30. ./certbot-auto certonly --noninteractive \
  31. --webroot --webroot-path /usr/share/jitsi-meet \
  32. -d $DOMAIN \
  33. --agree-tos --email $EMAIL
  34. echo "Configuring nginx"
  35. CONF_FILE="/etc/nginx/sites-available/$DOMAIN.conf"
  36. CERT_KEY_ESC=$(echo $CERT_KEY | sed 's/\./\\\./g')
  37. CERT_KEY_ESC=$(echo $CERT_KEY_ESC | sed 's/\//\\\//g')
  38. sed -i "s/ssl_certificate_key\ \/etc\/jitsi\/meet\/.*key/ssl_certificate_key\ $CERT_KEY_ESC/g" \
  39. $CONF_FILE
  40. CERT_CRT_ESC=$(echo $CERT_CRT | sed 's/\./\\\./g')
  41. CERT_CRT_ESC=$(echo $CERT_CRT_ESC | sed 's/\//\\\//g')
  42. sed -i "s/ssl_certificate\ \/etc\/jitsi\/meet\/.*crt/ssl_certificate\ $CERT_CRT_ESC/g" \
  43. $CONF_FILE
  44. echo "service nginx reload" >> $CRON_FILE
  45. service nginx reload
  46. elif [ -f /etc/apache2/sites-enabled/$DOMAIN.conf ] ; then
  47. ./certbot-auto certonly --noninteractive \
  48. --webroot --webroot-path /usr/share/jitsi-meet \
  49. -d $DOMAIN \
  50. --agree-tos --email $EMAIL
  51. echo "Configuring apache2"
  52. CONF_FILE="/etc/apache2/sites-available/$DOMAIN.conf"
  53. CERT_KEY_ESC=$(echo $CERT_KEY | sed 's/\./\\\./g')
  54. CERT_KEY_ESC=$(echo $CERT_KEY_ESC | sed 's/\//\\\//g')
  55. sed -i "s/SSLCertificateKeyFile\ \/etc\/jitsi\/meet\/.*key/SSLCertificateKeyFile\ $CERT_KEY_ESC/g" \
  56. $CONF_FILE
  57. CERT_CRT_ESC=$(echo $CERT_CRT | sed 's/\./\\\./g')
  58. CERT_CRT_ESC=$(echo $CERT_CRT_ESC | sed 's/\//\\\//g')
  59. sed -i "s/SSLCertificateFile\ \/etc\/jitsi\/meet\/.*crt/SSLCertificateFile\ $CERT_CRT_ESC/g" \
  60. $CONF_FILE
  61. echo "service apache2 reload" >> $CRON_FILE
  62. service apache2 reload
  63. else
  64. service jitsi-videobridge stop
  65. ./certbot-auto certonly --noninteractive \
  66. --standalone \
  67. -d $DOMAIN \
  68. --agree-tos --email $EMAIL
  69. echo "Configuring jetty"
  70. CERT_P12="/etc/jitsi/videobridge/$DOMAIN.p12"
  71. CERT_JKS="/etc/jitsi/videobridge/$DOMAIN.jks"
  72. # create jks from certs
  73. openssl pkcs12 -export \
  74. -in $CERT_CRT -inkey $CERT_KEY -passout pass:changeit > $CERT_P12
  75. keytool -importkeystore -destkeystore $CERT_JKS \
  76. -srckeystore $CERT_P12 -srcstoretype pkcs12 \
  77. -noprompt -storepass changeit -srcstorepass changeit
  78. service jitsi-videobridge start
  79. fi
  80. # the cron file that will renew certificates
  81. chmod a+x $CRON_FILE