2014-09-20 17:23:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-02-24 17:54:28 +00:00
|
|
|
rm -f /var/run/alternc-ssl/generate_certif_alias
|
2014-09-20 17:30:23 +00:00
|
|
|
|
2014-09-20 17:23:57 +00:00
|
|
|
# Launched by incron when /tmp/generate_certif_alias exists
|
|
|
|
# regenerate the list of global aliases used by Comodo for certificate ownership validation
|
2014-09-20 17:30:23 +00:00
|
|
|
# FIXME: how do we lock that, ensuring we don't launch this more than once ?
|
2014-09-20 17:23:57 +00:00
|
|
|
APACHECONF=/etc/apache2/conf.d/alternc-ssl_cert-alias.conf
|
|
|
|
TMP=/tmp/alternc-ssl_cert-alias_${$}.tmp
|
|
|
|
FILEDIR=/var/lib/alternc/ssl-cert-alias
|
|
|
|
|
|
|
|
|
|
|
|
rm -f "$TMP"
|
|
|
|
mkdir -p "$FILEDIR"
|
|
|
|
|
2014-09-21 19:44:35 +00:00
|
|
|
mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "SELECT name,content FROM certif_alias;" | while read name content
|
2014-09-20 17:23:57 +00:00
|
|
|
do
|
2015-02-24 18:05:48 +00:00
|
|
|
echo "alias /$name ${FILEDIR}/${name}" >>$TMP
|
|
|
|
echo "$content" >"${FILEDIR}/${name}"
|
2014-09-20 17:23:57 +00:00
|
|
|
done
|
2015-02-24 17:54:28 +00:00
|
|
|
if ! diff -q "$TMP" "$APACHECONF"
|
|
|
|
then
|
|
|
|
mv -f "$TMP" "$APACHECONF"
|
|
|
|
service apache2 reload
|
|
|
|
else
|
|
|
|
rm -f "$TMP"
|
|
|
|
fi
|
2014-09-20 17:23:57 +00:00
|
|
|
|