Skip to content

Instantly share code, notes, and snippets.

@AstraSerg
Last active August 8, 2019 11:06
Show Gist options
  • Save AstraSerg/1c571bc1c0ea49d5fb8934c034cb1b2a to your computer and use it in GitHub Desktop.
Save AstraSerg/1c571bc1c0ea49d5fb8934c034cb1b2a to your computer and use it in GitHub Desktop.
post renew SSL certs lego
#!/bin/bash
# checks if certs was updated by lego
# and put it to spot
key_file='/home/certs/certificates/hs1.srv.key'
crt_file='/home/certs/certificates/hs1.srv.crt'
mix_file='/opt//config/server.pem'
# take 1 line from the middle of new (?) cert
l="$(head -n 3 $crt_file | tail -n 1)"
grep "$l" $mix_file > /dev/null \
|| { cat $key_file $crt_file > $mix_file; systemctl restart spot; }
# and cron:
#cat /etc/cron.d/renewcerts
#0 4 * * * root docker run --rm -v /home/spotcerts:/home/spotcerts --net=host goacme/lego --domains=hs1.srv.ru -a -m astraserg@gmail.com --tls --path /home/spotcerts renew; /home/scripts/update_certs.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment