Browse Source

Preparing for letsencrypt

Bob Mottram 9 years ago
parent
commit
178f9becd1
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      src/freedombone-addcert

+ 7
- 1
src/freedombone-addcert View File

@@ -45,6 +45,7 @@ NODH=
45 45
 DH_KEYLENGTH=2048
46 46
 INSTALL_DIR=/root/build
47 47
 LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
48
+LETSENCRYPT_REPO='https://github.com/letsencrypt/letsencrypt'
48 49
 
49 50
 function show_help {
50 51
     echo ''
@@ -155,7 +156,7 @@ if [ $LETSENCRYPT_HOSTNAME ]; then
155 156
 
156 157
     # obtain the repo
157 158
     if [ ! -d ${INSTALL_DIR}/letsencrypt ]; then
158
-        git clone https://github.com/letsencrypt/letsencrypt
159
+        git clone $LETSENCRYPT_REPO
159 160
         if [ ! -d ${INSTALL_DIR}/letsencrypt ]; then
160 161
             exit 76283
161 162
         fi
@@ -165,11 +166,15 @@ if [ $LETSENCRYPT_HOSTNAME ]; then
165 166
         git pull
166 167
     fi
167 168
 
169
+    # stop the web server
170
+    systemctl stop nginx
171
+
168 172
     cd ${INSTALL_DIR}/letsencrypt
169 173
     # TODO this requires user interaction - is there a non-interactive mode?
170 174
     ./letsencrypt-auto certonly --server $LETSENCRYPT_SERVER --standalone -d $LETSENCRYPT_HOSTNAME
171 175
     if [ ! "$?" = "0" ]; then
172 176
         echo $"Failed to install letsencrypt for domain $LETSENCRYPT_HOSTNAME"
177
+        systemctl start nginx
173 178
         exit 63216
174 179
     fi
175 180
 
@@ -200,6 +205,7 @@ if [ $LETSENCRYPT_HOSTNAME ]; then
200 205
     ln -s /etc/letsencrypt/live/${LETSENCRYPT_HOSTNAME}/fullchain.pem /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem
201 206
 
202 207
     cp /etc/letsencrypt/live/${LETSENCRYPT_HOSTNAME}/fullchain.pem /etc/ssl/mycerts/${LETSENCRYPT_HOSTNAME}.pem
208
+    systemctl start nginx
203 209
 else
204 210
     CERTFILE=$HOSTNAME
205 211
     if [[ $ORGANISATION == "Freedombone-CA" ]]; then