-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_certs.js
58 lines (57 loc) · 2.17 KB
/
get_certs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//Download the cert/key/password from our etcd server
var http = require('http')
var fs = require('fs')
var async = require('async')
async.series([
function(callback) {
http.get('http://' + process.env.ETCD_HOST + ':' + process.env.ETCD_PORT + '/v2/keys/molecularmatch.com.key', function(response) {
// Continuously update stream with data
var body = ''
response.on('data', function(d) {
body += d
})
response.on('end', function() {
// Data reception is done, do whatever with it!
var parsed = JSON.parse(body)
fs.writeFile('/etc/nginx/molecularmatch.com.key', parsed.node.value, callback)
})
}).on('error', function(err) {
callback(err)
})
},
function(callback) {
http.get('http://' + process.env.ETCD_HOST + ':' + process.env.ETCD_PORT + '/v2/keys/molecularmatch.com.cert', function(response) {
// Continuously update stream with data
var body = ''
response.on('data', function(d) {
body += d
})
response.on('end', function() {
// Data reception is done, do whatever with it!
var parsed = JSON.parse(body)
fs.writeFile('/etc/nginx/molecularmatch.com.cert', parsed.node.value, callback)
})
}).on('error', function(err) {
callback(err)
})
},
function(callback) {
http.get('http://' + process.env.ETCD_HOST + ':' + process.env.ETCD_PORT + '/v2/keys/passwords', function(response) {
// Continuously update stream with data
var body = ''
response.on('data', function(d) {
body += d
})
response.on('end', function() {
// Data reception is done, do whatever with it!
var parsed = JSON.parse(body)
fs.writeFile('/etc/nginx/passwords', parsed.node.value, callback)
})
}).on('error', function(err) {
callback(err)
})
}
], function(err) {
if (err) console.log(err)
process.exit()
})