2016-06-21 19:58:26 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-06-23 14:05:11 +02:00
|
|
|
H_NAME=$( hostname -f )
|
2016-06-21 19:58:26 +02:00
|
|
|
LE_SERVICES_SCRIPT_DIR=/usr/lib/acme/hooks
|
2016-06-23 14:05:11 +02:00
|
|
|
LE_CERTS_DIR=/var/lib/acme/live/$H_NAME
|
2016-06-21 19:58:26 +02:00
|
|
|
LE_LOG_DIR=/var/log/letsencrypt
|
|
|
|
POSTGRESQL_CERTDIR=/etc/pki/postgresql
|
|
|
|
POSTGRESQL_KEYFILE=$POSTGRESQL_CERTDIR/postgresql.key
|
|
|
|
DATE=$( date )
|
|
|
|
|
|
|
|
[ ! -d $POSTGRESQL_CERTDIR ] && mkdir -p $POSTGRESQL_CERTDIR
|
|
|
|
[ ! -d $LE_LOG_DIR ] && mkdir $LE_LOG_DIR
|
|
|
|
echo "$DATE" >> $LE_LOG_DIR/postgresql.log
|
|
|
|
|
|
|
|
if [ -f /etc/default/letsencrypt ] ; then
|
|
|
|
. /etc/default/letsencrypt
|
|
|
|
else
|
|
|
|
echo "No letsencrypt default file" >> $LE_LOG_DIR/postgresql.log
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Copy the key file" >> $LE_LOG_DIR/postgresql.log
|
|
|
|
cp ${LE_CERTS_DIR}/privkey ${POSTGRESQL_KEYFILE}
|
|
|
|
chmod 440 ${POSTGRESQL_KEYFILE}
|
2017-01-19 16:43:04 +01:00
|
|
|
chown root ${POSTGRESQL_KEYFILE}
|
2016-06-21 19:58:26 +02:00
|
|
|
chgrp postgres ${POSTGRESQL_KEYFILE}
|
|
|
|
|
2017-11-06 18:01:48 +01:00
|
|
|
echo "Restart the postgresql service" >> $LE_LOG_DIR/postgresql.log
|
2016-06-21 19:58:26 +02:00
|
|
|
if [ -x /bin/systemctl ] ; then
|
2017-08-21 13:26:14 +02:00
|
|
|
systemctl restart postgresql >> $LE_LOG_DIR/postgresql.log 2>&1
|
2016-06-21 19:58:26 +02:00
|
|
|
else
|
2017-08-21 13:26:14 +02:00
|
|
|
service postgresql restart >> $LE_LOG_DIR/postgresql.log 2>&1
|
2016-06-21 19:58:26 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Done." >> $LE_LOG_DIR/postgresql.log
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|