Created
June 21, 2024 20:29
-
-
Save m4rkw/6c9b65dcd4914e1aa03188d2b5d5c5b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import datetime | |
import math | |
import json | |
config = json.loads(open('/usr/syno/etc/ssl/ssl.info/server.info').read()) | |
domain = config['domains'] | |
not_after = os.popen("echo | openssl s_client -connect %s:8001 2>/dev/null |openssl x509 -text |grep 'Not After' |sed 's/.*Not After : //'" % (domain)).read().rstrip()[0:-4] | |
ts = datetime.datetime.strptime(not_after, '%b %d %H:%M:%S %Y') | |
remaining_days = int(math.floor((ts - datetime.datetime.now()).total_seconds() / 86400)) | |
if remaining_days <= 28: | |
os.system("/usr/syno/sbin/syno-letsencrypt renew-all -vv 1>/tmp/renew.stdout 2>/tmp/renew.stderr") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment