underpost 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/ssl.js DELETED
@@ -1,63 +0,0 @@
1
- import fs from 'fs';
2
- import read from 'read';
3
- import dotenv from 'dotenv';
4
- import { getRootDirectory, pbcopy, shellExec } from '../src/server/process.js';
5
- import { loggerFactory } from '../src/server/logger.js';
6
- import { Cmd, loadConf } from '../src/server/conf.js';
7
- import { buildSSL } from '../src/server/ssl.js';
8
-
9
- dotenv.config();
10
-
11
- const logger = loggerFactory(import.meta);
12
-
13
- await logger.setUpInfo();
14
-
15
- const [exe, dir, deployId, hosts] = process.argv;
16
-
17
- try {
18
- let cmd;
19
- await loadConf(deployId);
20
- shellExec(Cmd.conf(deployId));
21
- const confServer = JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'));
22
- for (const host of hosts.split(',')) {
23
- if (host in confServer) {
24
- const directory = confServer[host]['/']?.['directory'] ? confServer[host]['/']['directory'] : undefined;
25
- cmd = `sudo certbot certonly --webroot --webroot-path ${
26
- directory ? directory : `${getRootDirectory()}/public/${host}`
27
- } --cert-name ${host} -d ${host}`;
28
- // directory ? directory : `${getRootDirectory()}/public/${host}`
29
- // directory ? directory : `${getRootDirectory()}/public/www.${host.split('.').slice(-2).join('.')}`
30
-
31
- // You can get multi domain cert by specifying (extra) -d
32
- // For example
33
- // certbot -d example.com -d example.net -d www.example.org
34
-
35
- // delete all file (no increment live folder)
36
- // certbot delete --cert-name <domain>
37
-
38
- logger.info(`Run the following command`, cmd);
39
- try {
40
- await pbcopy(cmd);
41
- await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
42
- } catch (error) {
43
- logger.error(error);
44
- }
45
- // Certificate
46
- if (process.argv.includes('build')) await buildSSL(host);
47
- logger.info('Certificate saved', host);
48
- } else throw new Error(`host not found: ${host}`);
49
- }
50
- // check for renewal conf:
51
- // /etc/letsencrypt/renewal
52
- // /etc/letsencrypt/live
53
- cmd = `sudo certbot renew --dry-run`;
54
- try {
55
- await pbcopy(cmd);
56
- } catch (error) {
57
- logger.error(error);
58
- }
59
- logger.info(`run the following command for renewal. Command copy to clipboard`, cmd);
60
- logger.info(`success install SLL`, hosts);
61
- } catch (error) {
62
- logger.error(error, error.stack);
63
- }