40 lines
1.9 KiB
Bash
Executable File
40 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
DATE=`date +%F-%H-%M-%S`
|
|
|
|
email=$EMAIL
|
|
|
|
start_letsencrypt() {
|
|
|
|
mkdir -p /acme.sh/$DOMAIN/ ;
|
|
|
|
acme.sh --register-account -m $email --issue --standalone --keylength 4096 -d $DOMAIN --cert-file /acme.sh/$DOMAIN/cert.pem --key-file /acme.sh/$DOMAIN/key.pem --fullchain-file /acme.sh/$DOMAIN/fullchain.pem ;
|
|
|
|
#mkdir -p /acme.sh/$DOMAIN/ecc-certs ;
|
|
|
|
#acme.sh --issue --standalone --keylength ec-384 -d $DOMAIN --cert-file /acme.sh/$DOMAIN/ecc-certs/cert.pem --key-file /acme.sh/$DOMAIN/ecc-certs/key.pem --fullchain-file /acme.sh/$DOMAIN/ecc-certs/fullchain.pem
|
|
|
|
}
|
|
|
|
LETSENCRYPT_FILE=$(find /acme.sh/ -type f -name letsencrypt);
|
|
if [ -f "$LETSENCRYPT_FILE" ] ; then
|
|
DOMAIN=$(jq -r .DOMAIN $LETSENCRYPT_FILE) ;
|
|
start_letsencrypt;
|
|
rm $LETSENCRYPT_FILE;
|
|
else
|
|
for i in `ls /domains/` ; do
|
|
DOMAIN=$(jq -r .DOMAIN /domains/$i) ;
|
|
if [[ -f "/acme.sh/$DOMAIN/key.pem" && -f "/acme.sh/$DOMAIN/fullchain.pem" && -f "/acme.sh/$DOMAIN/cert.pem" ]] ; then
|
|
echo "Found certificate files";
|
|
start_letsencrypt;
|
|
if [ find /acme.sh/$DOMAIN/ -type f -mmin +60 ]; then
|
|
touch /acme.sh/$DOMAIN/renew_certificate;
|
|
fi
|
|
else
|
|
start_letsencrypt;
|
|
touch /acme.sh/$DOMAIN/new_certificate;
|
|
fi
|
|
done ;
|
|
fi
|
|
|