| 1 | #!/bin/sh |
| 2 | |
| 3 | if [[ -z "${SERVER_HOST}" ]]; then |
| 4 | echo "No SERVER_HOST set!" |
| 5 | echo "Please set the SERVER_HOST environment variable to use CoPilot" |
| 6 | exit 1; |
| 7 | else |
| 8 | echo "Host is now https://${SERVER_HOST}:${SERVER_PORT}" |
| 9 | fi |
| 10 | |
| 11 | if [[ ! -f "${TLS_CERT_PATH}" || ! -f "${TLS_KEY_PATH}" ]]; then |
| 12 | echo "No TLS certs found. Generating...." |
| 13 | mkdir -p $(dirname "${TLS_CERT_PATH}") |
| 14 | openssl req -x509 -subj "/CN=${SERVER_HOST}" -nodes -newkey rsa:4096 -keyout "${TLS_KEY_PATH}" -out "${TLS_CERT_PATH}" -days 365 |
| 15 | else |
| 16 | echo "TLS certificates found" |
| 17 | fi |
| 18 | |
| 19 | if [[ ! -f /etc/nginx/certs/dhparams.pem ]]; then |
| 20 | echo "Generating new DH parameters - this may take a while..." |
| 21 | mkdir -p /etc/nginx/certs/ |
| 22 | openssl dhparam -out /etc/nginx/certs/dhparams.pem 2048 |
| 23 | else |
| 24 | echo "... DH parameters found" |
| 25 | fi |