#! /usr/bin/ksh

echo "Configuring $PKG"

APACHE_ROOT=/opt/apache2

# ISL: Hostname not set up yet.
if [ -f /etc/inst/scripts/postreboot.sh ]; then
	HOST=`grep TCP_DOMAIN_NAME /isl/ifile`
	FQDN=`uname -n`.`echo $HOST | sed -e "s/^.*=\"\(.*\)\"$/\1/p"`
else
	FQDN=`hostname`
fi

if [ "$FQDN" = "" ]; then
	FQDN=localhost.localdomain
fi

# Improperly configured OpenSSL, thinks this lives in /usr/local/ssl/
OPENSSL_CONF=/etc/ssl/openssl.cnf; export OPENSSL_CONF
                                         
openssl genrsa 1024 > $APACHE_ROOT/conf/ssl.key/server.key 2> /tmp/$PKG.log

cat << EOF | openssl req -new -key $APACHE_ROOT/conf/ssl.key/server.key \
 -x509 -days 365 -out $APACHE_ROOT/conf/ssl.crt/server.crt 2>> /tmp/$PKG.log
--
SomeState
SomeCity
SomeOrganization
SomeOrganizationalUnit
${FQDN}
root@${FQDN}
EOF
