#!/bin/bash
set -e -o pipefail

CERT="/var/www/miq/vmdb/certs/server.cer"
KEY="$CERT.key"
if [ ! -f "$CERT" -a ! -f "$KEY" ]; then
  (umask 077 ; openssl req -x509 -newkey rsa -days 1095 -keyout $KEY -out $CERT -subj "/CN=server" -nodes -batch)
fi

#!/bin/bash
set -e -o pipefail

CERT="${NEW_CERT_FILE:-/var/www/miq/vmdb/certs/server.cer}"
KEY="${NEW_KEY_FILE:-$CERT.key}"
if [ ! -f "$CERT" -a ! -f "$KEY" ]; then
  (umask 077 ; openssl req -x509 -newkey rsa -days 1095 -keyout $KEY -out $CERT -subj "/CN=server" -nodes -batch)
fi

Use ENV variables to specify the cert and key file in the generate script
Use ENV variables to specify the cert and key file in the generate script

This will allow us to generate new postgres certs with the following command:

NEW_CERT_FILE=/var/www/miq/vmdb/certs/postgres.crt \
NEW_KEY_FILE=/var/www/miq/vmdb/certs/postgres.key \
generate_miq_server_cert.sh
