#
if [ ! -f ${sslkey}/apache2-ca.key ]; then
- openssl genrsa -out ${sslkey}/apache2-ca.key 1024
+ (umask 027; openssl genrsa -out ${sslkey}/apache2-ca.key 1024)
KEYS="${KEYS}
- ${sslkey}/apache2-ca.key"
fi
# Generate server certificate
#
-openssl genrsa -out ${sslkey}/apache2.key 1024
+(umask 027; openssl genrsa -out ${sslkey}/apache2.key 1024)
echo 01 > "$TMPFILE2"
sed "s/HOST/$FQDN/g; s/DOMAIN/$DOMAIN/g; s/WEBMASTER/$WEBMASTER/g" \
# Add VirtualHosts.
#
-db_fget apache2-cn/wwwhost seen
-if [ "$RET" != "true" ]; then
-
- db_get apache2-cn/wwwhost || true
- if [ "$RET" = "true" ]; then
+db_get apache2-cn/wwwhost || true
+if [ "$RET" = "true" ]; then
# Add WWW VirtualHost.
if [ -f "$CONFDIR/sites-available/$FQDN" ]; then
fi
chk_conf_tag "$CONFDIR/sites-available/$FQDN"
- if [ ! -f "$CONFDIR/sites-available/$FQDN" ] || [ $RET -eq 0 -a -f "$CONFOLD" ]; then
+ if [ ! -f "$CONFDIR/sites-available/$FQDN" ] || [ $RET -eq 0 ]; then
install_vhost -nvh -d -r www.$DOMAIN default $FQDN 000-$FQDN
need_restart=1
fi
chk_conf_tag "$CONFDIR/sites-available/www.$DOMAIN"
- if [ ! -f "$CONFDIR/sites-available/www.$DOMAIN" ] || [ $RET -eq 0 -a -f "$CONFOLD" ]; then
+ if [ ! -f "$CONFDIR/sites-available/www.$DOMAIN" ] || [ $RET -eq 0 ]; then
install_vhost default www.$DOMAIN www.$DOMAIN
need_restart=1
fi
fi
chk_conf_tag "$CONFDIR/sites-available/$FQDN"
- if [ ! -f "$CONFDIR/sites-available/$FQDN" ] || [ $RET -eq 0 -a -f "$CONFOLD" ]; then
+ if [ ! -f "$CONFDIR/sites-available/$FQDN" ] || [ $RET -eq 0 ]; then
install_vhost -nvh -d -r $FQDN default $FQDN 000-$FQDN
need_restart=1
fi
- fi
fi
if [ $RET -eq 0 ] && [ -n "$apache2_sslcf" ]; then
SSLTMP=$(mktemp ${CONFDIR}/ssltmp.XXXXXX)
- temp_files="${temp_files} ${SSLTMP}"
+ temp_files="${temp_files} ${SSLTMP} ${SSLTMP}.cn-old"
cp ${CONFDIR}/sites-available/ssl $SSLTMP
# SSLCertificateFile
need_restart=1
# Just to be sure.
- if [ -e "$SSLTMP" ]; then
- rm -f $SSLTMP
- fi
+ [ -e "${SSLTMP}" ] && rm -f ${SSLTMP}
+ [ -e "${SSLTMP}.cn-old" ] && rm -f ${SSLTMP}.cn-old
fi
fi
+# Check file access permissions and group ownership for SSL certificates.
+#
+cp_echo "CN: Checking file permissions and group ownership for Apache2 SSL certificates."
+sslkey=/etc/ssl/private
+sslcerts="${sslkey}/ca.key ${sslkey}/ca.csr ${sslkey}/apache2-ca.key
+ ${sslkey}/apache2-ca.csr ${sslkey}/apache2.key ${sslkey}/apache2.csr"
+for certf in $sslcerts; do
+ if [ -f "$certf" ]; then
+ chgrp www-data $certf
+ chmod 640 $certf
+ fi
+done
+
+
# Check for CustomLog, ErrorLog and TransferLog in Apache2 configuration.
#
cp_echo "CN: Checking Apache2 CustomLog, ErrorLog and TransferLog directives."
# (re)generate monit.d files if monit-cn is installed.
#
if [ -x "/usr/sbin/update-monit.d" ]; then
+ cp_echo "CN: Updating monit configuration..."
update-monit.d || true
fi