Alternc  latest
Alternc logiel libre pour l'hébergement
ssl_alias_manager.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 rm -f /var/run/alternc-ssl/generate_certif_alias
4 
5 # Launched by incron when /tmp/generate_certif_alias exists
6 # regenerate the list of global aliases used by Comodo for certificate ownership validation
7 # FIXME: how do we lock that, ensuring we don't launch this more than once ?
8 APACHECONF=/etc/apache2/conf.d/alternc-ssl_cert-alias.conf
9 TMP=/tmp/alternc-ssl_cert-alias_${$}.tmp
10 FILEDIR=/var/lib/alternc/ssl-cert-alias
11 
12 
13 rm -f "$TMP"
14 mkdir -p "$FILEDIR"
15 
16 echo "# this file is autogenerated from /usr/lib/alternc/ssl_alias_manager.sh" >$TMP
17 echo "# Please do not edit, your changes will be overwritten" >>$TMP
18 
19 mysql --defaults-file=/etc/alternc/my.cnf --skip-column-names -B -e "SELECT name,content FROM certif_alias;" | while read name content
20 do
21  echo "alias /$name ${FILEDIR}/${name}" >>$TMP
22  echo "$content" >"${FILEDIR}/${name}"
23 done
24 if ! diff -q "$TMP" "$APACHECONF"
25 then
26  mv -f "$TMP" "$APACHECONF"
27  service apache2 reload
28 else
29  rm -f "$TMP"
30 fi
31