forked from batuoc263/ssl-rpc-host
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.js
33 lines (28 loc) · 1.23 KB
/
generate.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
const _ = require('lodash');
const argv = require('yargs')
.string('vps')
.string('email')
.parserConfiguration({
'parse-numbers': false
})
.argv;
const fs = require('fs');
const vps = argv.vps;
if (!vps) {
console.log('Missing parameter. Please add param --vps dns.com with dns.com is your VPS\'s dns');
process.exit(0);
}
const email = argv.email;
if (!email || email == '') {
console.log('Missing parameter. Please add param --email [email protected] with [email protected] is your email');
process.exit(0);
}
fs.cpSync('./nginx/nginx-template.conf', './nginx/nginx.conf');
let nginxConf = fs.readFileSync('./nginx/nginx.conf', 'utf-8');
nginxConf = _.replace(nginxConf, new RegExp('{vps}', 'g'), vps);
fs.writeFileSync('./nginx/nginx.conf', nginxConf, 'utf-8');
fs.cpSync('./docker-compose-certbot-template.yml', './docker-compose-certbot.yml');
let dockerComposeYml = fs.readFileSync('./docker-compose-certbot.yml', 'utf-8');
dockerComposeYml = _.replace(dockerComposeYml, new RegExp('{domain}', 'g'), vps);
dockerComposeYml = _.replace(dockerComposeYml, new RegExp('{email}', 'g'), email);
fs.writeFileSync('./docker-compose-certbot.yml', dockerComposeYml, 'utf-8');