bin/: Fix preamble to handle invocation through a symlink.
[distorted-letsencrypt] / bin / make-cert
CommitLineData
55799f78
MW
1#! /bin/sh
2set -e
93005620 3usage=" TAG"
c67523fe
MW
4prog=$(readlink -e "$0")
5. "${prog%/*}/../config.sh"
55799f78
MW
6. "$home/lib/lib.sh"
7
8run_as_user "$@"
9
10## Pick out the certificate tag.
11case $# in 0) fail_usage ;; esac
12tag=$1; shift
13case $# in 0) ;; *) fail_usage ;; esac
14
15prepare_tmp $tag
16
17## Get started.
08eee2f6
MW
18cert=$home/cert/$tag
19cd $cert
55799f78
MW
20openssl req -in req -out $tmp/req.der -outform der
21sans=$(openssl req -in req -text -noout |
22 sed -n '
23 x
24 /^ *X509v3 Subject Alternative Name: $/ {
25 x
26 s/ *DNS://g
27 s/,/ /g
28 p
29 x
30 }')
31make_le_conf $sans
32
08eee2f6
MW
33cd $tmp
34$home/letsencrypt/letsencrypt-auto -c "$tmp/le.conf" --text \
35 -a webroot --csr $tmp/req.der certonly
36
37cd $cert
38cat $tmp/0001_chain.pem $home/le-root.cert >full-chain.new
39mv full-chain.new full-chain