setup-ssl 704 B

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