Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > main-release > by-pkgid > 5357dabc702fd7723d24e7cbd26989d6 > scriptlet

apache-mod_ssl-2.2.15-3mdv2010.1.x86_64.rpm

PREIN

/bin/sh
# http://qa.mandriva.com/show_bug.cgi?id=32773
# http://qa.mandriva.com/show_bug.cgi?id=33198
# If there was default mod_ssl vhost misplaced move it as rpmsave
if [ -f /etc/httpd/modules.d/41_mod_ssl.default-vhost.conf -a ! -f  /etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf ]; then
    mv -vf /etc/httpd/modules.d/41_mod_ssl.default-vhost.conf /etc/httpd/conf/vhosts.d/01_default_ssl_vhost.conf
fi

POSTIN

/bin/sh
if [ "$1" = "1" ]; then 

mkdir -p /etc/pki/tls/{private,certs} 2>/dev/null
umask 077

if [ ! -f /etc/pki/tls/private/localhost.key ]; then
    /usr/bin/openssl genrsa -rand /proc/apm:/proc/cpuinfo:/proc/dma:/proc/filesystems:/proc/interrupts:/proc/ioports:/proc/pci:/proc/rtc:/proc/uptime 1024 > /etc/pki/tls/private/localhost.key 2> /dev/null
fi

FQDN=`hostname`
if [ "x${FQDN}" = "x" ]; then
    FQDN=localhost.localdomain
fi

if [ ! -f /etc/pki/tls/certs/localhost.crt ] ; then
cat << EOF | /usr/bin/openssl req -new -key /etc/pki/tls/private/localhost.key -x509 -days 365 -set_serial $RANDOM -out /etc/pki/tls/certs/localhost.crt 2>/dev/null
--
SomeState
SomeCity
SomeOrganization
SomeOrganizationalUnit
${FQDN}
root@${FQDN}
EOF
fi
fi

if [ "$1" -gt "1" ]; then
    mkdir -p /etc/pki/tls/{private,certs} 2>/dev/null
    if [ -d /etc/ssl/apache ];then
	if [ -f /etc/ssl/apache/server.crt.rpmsave -a ! -f /etc/pki/tls/certs/localhost.crt ]; then
	    cp -p /etc/ssl/apache/server.crt.rpmsave /etc/pki/tls/certs/localhost.crt
	fi
	if [ -f /etc/ssl/apache/server.key.rpmsave -a ! -f /etc/pki/tls/private/localhost.key ]; then
	    cp -p /etc/ssl/apache/server.key.rpmsave /etc/pki/tls/private/localhost.key
	fi

    fi
fi

# create some ghost files
/usr/share/rpm-helper/create-file apache $1 /var/cache/httpd/mod_ssl/scache.dir apache root 0600 
/usr/share/rpm-helper/create-file apache $1 /var/cache/httpd/mod_ssl/scache.pag apache root 0600 
/usr/share/rpm-helper/create-file apache $1 /var/cache/httpd/mod_ssl/scache.sem apache root 0600 

# http://qa.mandriva.com/show_bug.cgi?id=33429
if [ -f /etc/pki/tls/certs/localhost.crt ]; then
    chmod 644 /etc/pki/tls/certs/localhost.crt
fi

if [ -f /var/lock/subsys/httpd ]; then
    /etc/rc.d/init.d/httpd restart 1>&2;
fi

POSTUN

/bin/sh
if [ "$1" = "0" ]; then
    if [ -f /var/lock/subsys/httpd ]; then
        /etc/rc.d/init.d/httpd restart 1>&2
    fi
fi