setup-ssl 813 B

1234567891011121314151617181920
  1. #!/bin/bash
  2. [ -z "$1" ] && echo "Please specify a domain (ex. mydomain.test)" && exit
  3. # Generate a new local CA "/root/.local/share/mkcert"
  4. docker-compose exec -T -u root app mkcert -install
  5. # Read the CA install for requested hostname
  6. if ! docker-compose exec -T -u root app cat /root/.local/share/mkcert/rootCA.pem | grep -q 'BEGIN CERTIFICATE'; then
  7. bin/setup-ssl-ca
  8. fi
  9. # Generate the certificate for the specified domain
  10. docker-compose exec -T -u root app mkcert -key-file nginx.key -cert-file nginx.crt "$@"
  11. echo "Moving key and cert to /etc/nginx/certs/..."
  12. docker-compose exec -T -u root app chown app:app nginx.key nginx.crt
  13. docker-compose exec -T -u root app mv nginx.key nginx.crt /etc/nginx/certs/
  14. # Restart nginx to apply the updates
  15. echo "Restarting containers to apply updates..."
  16. bin/restart