bin/: Fix preamble to handle invocation through a symlink.
[distorted-letsencrypt] / bin / make-cert
index 8c5605b..19808c6 100755 (executable)
@@ -1,6 +1,8 @@
 #! /bin/sh
 set -e
-. "${0%/*}/../config.sh"
+usage=" TAG"
+prog=$(readlink -e "$0")
+. "${prog%/*}/../config.sh"
 . "$home/lib/lib.sh"
 
 run_as_user "$@"
@@ -13,7 +15,8 @@ case $# in 0) ;; *) fail_usage ;; esac
 prepare_tmp $tag
 
 ## Get started.
-cd $home/cert/$tag
+cert=$home/cert/$tag
+cd $cert
 openssl req -in req -out $tmp/req.der -outform der
 sans=$(openssl req -in req -text -noout |
        sed -n '
@@ -27,4 +30,10 @@ sans=$(openssl req -in req -text -noout |
          }')
 make_le_conf $sans
 
-cat "$tmp/le.conf"
+cd $tmp
+$home/letsencrypt/letsencrypt-auto -c "$tmp/le.conf" --text \
+       -a webroot --csr $tmp/req.der certonly
+
+cd $cert
+cat $tmp/0001_chain.pem $home/le-root.cert >full-chain.new
+mv full-chain.new full-chain