Skip to content
Snippets Groups Projects

Let's Encrypt automatic renewal

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Erick Hitter
    Edited
    eth-le-autorenew.sh 767 B
    #!/bin/sh
    
    printf "LET'S ENCRYPT BULK RENEWAL\n%s\n\n" "$(date)"
    
    for f in /etc/letsencrypt/configs/*.ini;
    do
    	printf "RENEWING CERTIFICATES FROM '%s':\n\n" "$f"
    
    	printf "Moving old files...\n\n"
    	basedir=$(basename $f | sed -e "s/\.ini$//" )
    
    	mv /etc/letsencrypt/custom/"$basedir"/certs/cert /etc/letsencrypt/custom/"$basedir"/certs/cert.old
    	mv /etc/letsencrypt/custom/"$basedir"/chains/chain /etc/letsencrypt/custom/"$basedir"/chains/chain.old
    	mv /etc/letsencrypt/custom/"$basedir"/fullchains/fullchain /etc/letsencrypt/custom/"$basedir"/fullchains/fullchain.old
    
    	printf "Running letsencrypt-auto...\n\n"
    
    	/usr/local/src/letsencrypt/letsencrypt-auto certonly --config "$f"
    
    	printf "\n\n";
    done
    
    printf "DONE RENEWING. PLEASE RELOAD THE RELEVANT SERVICES.\n"
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment