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