Continuando os trabalhos do artigo Ferramenta pra verificar quantidades de dias válidos de um certificado do letsencrypt, fiz uma pequena entrada na crontab pra chamar um script que fiz em fish.

  
# tail -1 /etc/crontab 
0  1  */5 * * root /root/bin/check-domain-expiration-dates.fish >> /tmp/certificate_renew.log 2>&1
  

E o respectivo script:

  
#! /usr/bin/env fish
set EXPIRATION_DAYS 10

for info in (letsencrypt-cert-days)
  set domain (echo $info | cut -d"=" -f1)
  set days (echo $info | cut -d"=" -f2)
  if [ $days -lt $EXPIRATION_DAYS ]
    echo "Renewing domain: $domain"
    certbot renew -d $domain
  end
end    
  

Então eu rodo no crontab a cada 5 dias pra detectar se algum certificado está expirando. E então chamo o `certbot` pra renovar se for o caso.

Funciona? Não sei. Meus certificados estão válidos ainda por quase 50 dias. Daqui um mês eu atualizo se funcionou.

  
# letsencrypt-cert-days --domain=helio.loureiro.eng.br
helio.loureiro.eng.br=48    
  

.oO(nota mental: trocar crontab por systemd-timer)

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.