Inserting date variable to compare created or modified files with previos versions.

This commit is contained in:
2022-03-29 10:53:44 +00:00
parent 33b2570a98
commit e5bfb9299c

View File

@@ -2,6 +2,13 @@
email=$EMAIL email=$EMAIL
sending_error_msg() {
$1="DOMAIN"
$2="DATE"
echo "there was unsucessfuly created "$DOMAIN" at date: "$DATE;
}
start_letsencrypt() { start_letsencrypt() {
mkdir -p /acme.sh/$DOMAIN/ ; mkdir -p /acme.sh/$DOMAIN/ ;
@@ -22,30 +29,37 @@ start_letsencrypt() {
LETSENCRYPT_FILE=$(find /acme.sh/ -type f -name letsencrypt); LETSENCRYPT_FILE=$(find /acme.sh/ -type f -name letsencrypt);
if [ -n "$LETSENCRYPT_FILE" ] ; then if [ -n "$LETSENCRYPT_FILE" ] ; then
DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE) ; DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE) ;
DATE=$(date +%m%d%m%H)
echo $DATE
start_letsencryp $DOMAIN; start_letsencryp $DOMAIN;
rm $LETSENCRYPT_FILE; rm $LETSENCRYPT_FILE;
touch /acme.sh/$DOMAIN/renew_certificate;
if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then
if [[ "$(date -r /acme.sh/$DOMAIN/key.pem +%m%d%m%H)" == "$DATE" && "$(date -r /acme.sh/$DOMAIN/fullchain.pem +%m%d%m%H)" == "$DATE" && "$(date -r /acme.sh/$DOMAIN/cert.pem +%m%d%m%H)" == "$DATE" ]] ; then
touch /acme.sh/$DOMAIN/new_certificate;
else
sending_error_msg $DOMAIN $DATE;
fi
fi
else else
cd /domains cd /domains
for i in `ls` ; do for i in `ls` ; do
DOMAIN=$(jq -r .DOMAIN $i) ; DOMAIN=$(jq -r .DOMAIN $i) ;
if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then DATE=$(date +%m%d%m%H)
echo $DATE
start_letsencrypt $DOMAIN; start_letsencrypt $DOMAIN;
touch /acme.sh/$DOMAIN/renew_certificate;
else
start_letsencrypt;
if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then
touch /acme.sh/$DOMAIN/new_certificate;
else
while [[ ! -f /acme.sh/$DOMAIN/key.pem || ! -f /acme.sh/$DOMAIN/fullchain.pem || ! -f /acme.sh/$DOMAIN/cert.pem ]] ; do
sleep 10;
start_letsencrypt $DOMAIN;
if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then if [[ -f /acme.sh/$DOMAIN/key.pem && -f /acme.sh/$DOMAIN/fullchain.pem && -f /acme.sh/$DOMAIN/cert.pem ]] ; then
if [[ "$(date -r /acme.sh/$DOMAIN/key.pem +%m%d%m%H)" == "$DATE" && "$(date -r /acme.sh/$DOMAIN/fullchain.pem +%m%d%m%H)" == "$DATE" && "$(date -r /acme.sh/$DOMAIN/cert.pem +%m%d%m%H)" == "$DATE" ]] ; then
touch /acme.sh/$DOMAIN/new_certificate; touch /acme.sh/$DOMAIN/new_certificate;
else
sending_error_msg $DOMAIN $DATE;
fi fi
done
fi
fi fi
done ; done ;
fi fi