1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/bin/sh
APACHE_CERT=/etc/libravatar/seccdn.crt
APACHE_KEY=/etc/libravatar/seccdn.pem
APACHE_CHAIN=/etc/libravatar/seccdn-chain.pem
SLAVE_CERT=/var/lib/libravatar/slave/cert/seccdn.crt
SLAVE_KEY=/var/lib/libravatar/slave/cert/seccdn.pem
SLAVE_CHAIN=/var/lib/libravatar/slave/cert/seccdn-chain.pem
if [ ! -e $SLAVE_CERT -o ! -e $APACHE_CERT ] ; then
echo "libravatar-slave: SSL certificate is missing"
exit 1
fi
if [ ! -e $SLAVE_KEY -o ! -e $APACHE_KEY ] ; then
echo "libravatar-slave: SSL certificate key is missing"
exit 2
fi
if [ ! -e $SLAVE_CHAIN -o ! -e $APACHE_CHAIN ] ; then
echo "libravatar-slave: SSL certificate chain is missing"
exit 3
fi
cmp --quiet $APACHE_CERT $SLAVE_CERT && cmp --quiet $APACHE_KEY $SLAVE_KEY && cmp --quiet $APACHE_CHAIN $SLAVE_CHAIN && exit 0
# Overwrite Apache's certs with the new ones
cp $SLAVE_CERT $APACHE_CERT
cp $SLAVE_KEY $APACHE_KEY
cp $SLAVE_CHAIN $APACHE_CHAIN
echo "Libravatar SSL certificate updated. Restarting Apache..."
echo
/usr/sbin/apache2ctl configtest && /usr/sbin/apache2ctl graceful
|