|
@@ -130,10 +130,10 @@ shift
|
130
|
130
|
done
|
131
|
131
|
|
132
|
132
|
if [ ! $HOSTNAME ]; then
|
133
|
|
- if [ ! $LETSENCRYPT_HOSTNAME ]; then
|
|
133
|
+ if [ ! $LETSENCRYPT_HOSTNAME ]; then
|
134
|
134
|
echo $'No hostname specified'
|
135
|
135
|
exit 5748
|
136
|
|
- fi
|
|
136
|
+ fi
|
137
|
137
|
fi
|
138
|
138
|
|
139
|
139
|
if ! which openssl > /dev/null ;then
|
|
@@ -148,56 +148,56 @@ fi
|
148
|
148
|
if [ $LETSENCRYPT_HOSTNAME ]; then
|
149
|
149
|
CERTFILE=$LETSENCRYPT_HOSTNAME
|
150
|
150
|
|
151
|
|
- if [ ! -d $INSTALL_DIR ]; then
|
152
|
|
- mkdir -p $INSTALL_DIR
|
153
|
|
- fi
|
154
|
|
- cd $INSTALL_DIR
|
155
|
|
-
|
156
|
|
- # obtain the repo
|
157
|
|
- if [ ! -d $INSTALL_DIR/letsencrypt ]; then
|
158
|
|
- git clone https://github.com/letsencrypt/letsencrypt
|
159
|
|
- if [ ! -d $INSTALL_DIR/letsencrypt ]; then
|
160
|
|
- exit 76283
|
161
|
|
- fi
|
162
|
|
- else
|
163
|
|
- cd $INSTALL_DIR/letsencrypt
|
164
|
|
- git stash
|
165
|
|
- git pull
|
166
|
|
- fi
|
167
|
|
-
|
168
|
|
- cd $INSTALL_DIR/letsencrypt
|
169
|
|
- # TODO this requires user interaction - is there a non-interactive mode?
|
170
|
|
- ./letsencrypt-auto certonly --server $LETSENCRYPT_SERVER --standalone -d $LETSENCRYPT_HOSTNAME
|
171
|
|
- if [ ! "$?" = "0" ]; then
|
172
|
|
- echo $"Failed to install letsencrypt for domain $LETSENCRYPT_HOSTNAME"
|
173
|
|
- exit 63216
|
174
|
|
- fi
|
175
|
|
-
|
176
|
|
- # replace some legacy filenames
|
177
|
|
- if [ -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.bundle.crt ]; then
|
178
|
|
- mv /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.bundle.crt /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem
|
179
|
|
- fi
|
180
|
|
- if [ -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.crt ]; then
|
181
|
|
- mv /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.crt /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem
|
182
|
|
- fi
|
183
|
|
- sed -i "s|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.bundle.crt|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem|g" /etc/nginx/sites-available/$LETSENCRYPT_HOSTNAME
|
184
|
|
- sed -i "s|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.crt|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem|g" /etc/nginx/sites-available/$LETSENCRYPT_HOSTNAME
|
185
|
|
-
|
186
|
|
- # link the private key
|
187
|
|
- if [ -f /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key ]; then
|
188
|
|
- if [ ! -f /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key.old ]; then
|
189
|
|
- mv /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key.old
|
190
|
|
- fi
|
191
|
|
- fi
|
192
|
|
- ln -s /etc/letsencrypt/live/${LETSENCRYPT_HOSTNAME}/privkey.pem /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key
|
193
|
|
-
|
194
|
|
- # link the public key
|
195
|
|
- if [ -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem ]; then
|
196
|
|
- if [ ! -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem.old ]; then
|
197
|
|
- mv /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem.old
|
198
|
|
- fi
|
199
|
|
- fi
|
200
|
|
- ln -s /etc/letsencrypt/live/${LETSENCRYPT_HOSTNAME}/fullchain.pem /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem
|
|
151
|
+ if [ ! -d $INSTALL_DIR ]; then
|
|
152
|
+ mkdir -p $INSTALL_DIR
|
|
153
|
+ fi
|
|
154
|
+ cd $INSTALL_DIR
|
|
155
|
+
|
|
156
|
+ # obtain the repo
|
|
157
|
+ if [ ! -d $INSTALL_DIR/letsencrypt ]; then
|
|
158
|
+ git clone https://github.com/letsencrypt/letsencrypt
|
|
159
|
+ if [ ! -d $INSTALL_DIR/letsencrypt ]; then
|
|
160
|
+ exit 76283
|
|
161
|
+ fi
|
|
162
|
+ else
|
|
163
|
+ cd $INSTALL_DIR/letsencrypt
|
|
164
|
+ git stash
|
|
165
|
+ git pull
|
|
166
|
+ fi
|
|
167
|
+
|
|
168
|
+ cd $INSTALL_DIR/letsencrypt
|
|
169
|
+ # TODO this requires user interaction - is there a non-interactive mode?
|
|
170
|
+ ./letsencrypt-auto certonly --server $LETSENCRYPT_SERVER --standalone -d $LETSENCRYPT_HOSTNAME
|
|
171
|
+ if [ ! "$?" = "0" ]; then
|
|
172
|
+ echo $"Failed to install letsencrypt for domain $LETSENCRYPT_HOSTNAME"
|
|
173
|
+ exit 63216
|
|
174
|
+ fi
|
|
175
|
+
|
|
176
|
+ # replace some legacy filenames
|
|
177
|
+ if [ -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.bundle.crt ]; then
|
|
178
|
+ mv /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.bundle.crt /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem
|
|
179
|
+ fi
|
|
180
|
+ if [ -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.crt ]; then
|
|
181
|
+ mv /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.crt /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem
|
|
182
|
+ fi
|
|
183
|
+ sed -i "s|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.bundle.crt|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem|g" /etc/nginx/sites-available/$LETSENCRYPT_HOSTNAME
|
|
184
|
+ sed -i "s|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.crt|ssl_certificate /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem|g" /etc/nginx/sites-available/$LETSENCRYPT_HOSTNAME
|
|
185
|
+
|
|
186
|
+ # link the private key
|
|
187
|
+ if [ -f /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key ]; then
|
|
188
|
+ if [ ! -f /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key.old ]; then
|
|
189
|
+ mv /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key.old
|
|
190
|
+ fi
|
|
191
|
+ fi
|
|
192
|
+ ln -s /etc/letsencrypt/live/${LETSENCRYPT_HOSTNAME}/privkey.pem /etc/ssl/private/${LETSENCRYPT_HOSTNAME}.key
|
|
193
|
+
|
|
194
|
+ # link the public key
|
|
195
|
+ if [ -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem ]; then
|
|
196
|
+ if [ ! -f /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem.old ]; then
|
|
197
|
+ mv /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem.old
|
|
198
|
+ fi
|
|
199
|
+ fi
|
|
200
|
+ ln -s /etc/letsencrypt/live/${LETSENCRYPT_HOSTNAME}/fullchain.pem /etc/ssl/certs/${LETSENCRYPT_HOSTNAME}.pem
|
201
|
201
|
|
202
|
202
|
cp /etc/letsencrypt/live/${LETSENCRYPT_HOSTNAME}/fullchain.pem /etc/ssl/mycerts/${LETSENCRYPT_HOSTNAME}.pem
|
203
|
203
|
else
|
|
@@ -217,10 +217,13 @@ fi
|
217
|
217
|
|
218
|
218
|
# generate DH params
|
219
|
219
|
if [ ! $NODH ]; then
|
220
|
|
- if [ ! -f /etc/ssl/certs/$CERTFILE.dhparam ]; then
|
221
|
|
- openssl dhparam -check -text -dsaparam $DH_KEYLENGTH -out /etc/ssl/certs/$CERTFILE.dhparam
|
222
|
|
- chmod 640 /etc/ssl/certs/$CERTFILE.dhparam
|
223
|
|
- fi
|
|
220
|
+ if [ ! -f /etc/ssl/certs/$CERTFILE.dhparam ]; then
|
|
221
|
+ openssl dhparam -check -text -dsaparam $DH_KEYLENGTH -out /etc/ssl/certs/$CERTFILE.dhparam
|
|
222
|
+ if [ ! "$?" = "0" ]; then
|
|
223
|
+ exit 72428
|
|
224
|
+ fi
|
|
225
|
+ chmod 640 /etc/ssl/certs/$CERTFILE.dhparam
|
|
226
|
+ fi
|
224
|
227
|
fi
|
225
|
228
|
|
226
|
229
|
if [ -f /etc/init.d/nginx ]; then
|