annotate scripts/create-combined-pemfile @ 79:ea014ed97581

Add a script for making backups.
author John "Elwin" Edwards
date Fri, 13 Jan 2017 17:36:23 -0500
parents c99fac2b0dc7
children 08c6e8c87caa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
76
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
1 #!/bin/sh
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
2 # Combines a private key and host cert into a single pemfile, for webservers
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
3 # that require it.
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
4
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
5 if [ $# -lt 1 ]
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
6 then
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
7 echo "No domains given."
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
8 exit 1
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
9 fi
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
10
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
11 for DOMAIN in "$@"
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
12 do
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
13 LINKDIR=/etc/letsencrypt/live/"$DOMAIN"
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
14 if [ ! -d "$LINKDIR" ]
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
15 then
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
16 echo "No certificates for $DOMAIN, skipping"
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
17 continue
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
18 fi
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
19 REALCERTFILE=`readlink -f "$LINKDIR"/cert.pem`
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
20 PEMFILE=`dirname "$REALCERTFILE"`/combined.pem
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
21 touch "$PEMFILE"
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
22 chown root:root "$PEMFILE"
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
23 chmod 400 "$PEMFILE"
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
24 cat "$LINKDIR"/privkey.pem "$LINKDIR"/cert.pem >"$PEMFILE"
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
25 ln -s -f -r "$PEMFILE" "$LINKDIR"/combined.pem
c99fac2b0dc7 Add files related to SSL support.
John "Elwin" Edwards
parents:
diff changeset
26 done