f0c4143
#!/usr/bin/bash
f0c4143
f0c4143
set -e
f0c4143
f0c4143
FQDN=`hostname`
10e930c
ssldotconf=/etc/httpd/conf.d/ssl.conf
45393c8
2038991
if test -f /etc/pki/tls/certs/localhost.crt -a \
76ede69
        -f /etc/pki/tls/private/localhost.key; then
2038991
    exit 0
2038991
fi
2038991
2038991
if test -f /etc/pki/tls/certs/localhost.crt -a \
2038991
        ! -f /etc/pki/tls/private/localhost.key; then
2038991
    echo "Missing certificate key!"
2038991
    exit 1
2038991
fi
2038991
2038991
if test ! -f /etc/pki/tls/certs/localhost.crt -a \
2038991
         -f /etc/pki/tls/private/localhost.key; then
2038991
    echo "Missing certificate, but key is present!"
45393c8
    exit 1
f0c4143
fi
f0c4143
10e930c
if ! test -f ${ssldotconf} || \
10e930c
   ! grep -q '^SSLCertificateFile /etc/pki/tls/certs/localhost.crt' ${ssldotconf} || \
10e930c
   ! grep -q '^SSLCertificateKeyFile /etc/pki/tls/private/localhost.key' ${ssldotconf}; then
10e930c
    # Non-default configuration, do nothing.
10e930c
    exit 0
10e930c
fi
2038991
f0c4143
sscg -q                                                             \
f0c4143
     --cert-file           /etc/pki/tls/certs/localhost.crt         \
f0c4143
     --cert-key-file       /etc/pki/tls/private/localhost.key       \
76ede69
     --ca-file             /etc/pki/tls/certs/localhost.crt         \
f0c4143
     --lifetime            365                                      \
f0c4143
     --hostname            $FQDN                                    \
f0c4143
     --email               root@$FQDN
45393c8