2017-02-18 14:18:39 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
PATH="/bin:/usr/bin:/sbin:/usr/sbin"
|
|
|
|
CERT_DIR="{{ certsync_dir }}"
|
|
|
|
|
|
|
|
if [ ! -d $CERT_DIR ]; then
|
|
|
|
mkdir -p $CERT_DIR
|
|
|
|
chown root.root $CERT_DIR
|
|
|
|
chmod 750 $CERT_DIR
|
|
|
|
fi
|
|
|
|
|
2017-06-30 22:24:56 +02:00
|
|
|
sftp -p -q -i {{ certsync_key }} certsync@{{ certsync_host }}:* "$CERT_DIR/" > /dev/null 2>&1
|
2017-02-18 14:18:39 +01:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Error getting certificates"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
chown root.root $CERT_DIR/*
|
|
|
|
chmod 440 $CERT_DIR/*
|
|
|
|
|
2017-06-30 22:24:56 +02:00
|
|
|
COUNT=$(find $CERT_DIR -mtime -7 | wc -l)
|
|
|
|
if [ $COUNT -gt 0 ]; then
|
2020-03-25 21:28:19 +01:00
|
|
|
systemctl reload nginx > /dev/null
|
2017-06-30 22:24:56 +02:00
|
|
|
fi
|