~dricottone/huttese-apk

ref: a63152bc561cceb26e8df9470112a1e15fa0bfd0 huttese-apk/sr.ht/sr.ht-uacme/acme-update-certs -rw-r--r-- 738 bytes
a63152bc — Drew DeVault submit-builds: add manifest override, edge manifest 2 years ago
                                                                                
09fc19f3 Drew DeVault
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh -eu
exec >>/var/log/acme.log 2>&1
date

stats() {
	cert="/etc/ssl/uacme/$1/cert.pem"
	if ! [ -e "$cert" ]
	then
		return
	fi
	expiration=$(date -d"$(openssl x509 -enddate -noout -in "$cert" \
		| cut -d= -f2)" -D'%b %d %H:%M:%S %Y GMT' +'%s')
	printf '# TYPE certificate_expiration gauge\n'
	printf '# HELP certificate_expiration Timestamp when SSL certificate will expire\n'
	printf 'certificate_expiration{instance="%s"} %s\n' "$1" "$expiration"
}

acme() {
	site=$1
	shift
	/usr/bin/uacme -v -h /usr/share/uacme/uacme.sh issue $site $* || true
	stats $site | curl --data-binary @- https://push.metrics.sr.ht/metrics/job/$site
}

source /etc/uacme.conf
chmod -R g+rX /etc/ssl/uacme /etc/ssl/uacme/private
doas nginx -s reload