atendeticket 1.0.0 → 2.0.1
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/actions/block.js +8 -0
- package/actions/changeDomain.js +8 -0
- package/actions/delete.js +8 -0
- package/actions/install.js +10 -0
- package/actions/unblock.js +8 -0
- package/actions/update.js +10 -0
- package/appInstaller.js +148 -0
- package/core/banner.js +13 -0
- package/core/exec.js +14 -0
- package/core/logger.js +15 -0
- package/index.js +9 -49
- package/installers/backend/build.js +10 -0
- package/installers/backend/createDatabase.js +14 -0
- package/installers/backend/createRedis.js +50 -0
- package/installers/backend/installDeps.js +10 -0
- package/installers/backend/seed.js +10 -0
- package/installers/backend/setEnv.js +75 -0
- package/installers/backend/setupNginx.js +10 -0
- package/installers/backend/startPM2.js +10 -0
- package/installers/frontend/build.js +10 -0
- package/installers/frontend/installDeps.js +10 -0
- package/installers/frontend/setEnv.js +55 -0
- package/installers/frontend/setupNginx.js +10 -0
- package/installers/frontend/startPM2.js +10 -0
- package/installers/system/createUser.js +10 -0
- package/installers/system/installCertbot.js +10 -0
- package/installers/system/installDocker.js +11 -0
- package/installers/system/installNginx.js +11 -0
- package/installers/system/installNode.js +10 -0
- package/installers/system/installPM2.js +10 -0
- package/installers/system/updateSystem.js +11 -0
- package/package.json +17 -14
- package/prompts/domainPrompts.js +10 -0
- package/prompts/installPrompts.js +11 -0
- package/prompts/mainMenu.js +18 -0
- package/prompts/updatePrompts.js +12 -0
- package/ssl/setupSSL.js +10 -0
- package/LICENSE +0 -21
- package/src/appInstaller.js +0 -48
- package/src/core/logger.js +0 -5
- package/src/core/rollback.js +0 -3
- package/src/core/run.js +0 -6
- package/src/installer/01-checkRoot.js +0 -6
- package/src/installer/02-systemDeps.js +0 -6
- package/src/installer/03-nodejs.js +0 -6
- package/src/installer/04-pm2.js +0 -7
- package/src/installer/05-nginx.js +0 -7
- package/src/installer/06-certbot.js +0 -5
- package/src/installer/07-cloneRepos.js +0 -7
- package/src/installer/08-backend.js +0 -5
- package/src/installer/09-frontend.js +0 -6
- package/src/installer/10-env.js +0 -6
- package/src/installer/11-pm2Start.js +0 -6
- package/src/installer/12-nginxProxy.js +0 -29
- package/src/installer/13-ssl.js +0 -5
- package/src/installer/14-finalReport.js +0 -9
- package/src/menu.js +0 -46
- /package/{README.md → installers/backend/migrate.js} +0 -0
package/actions/block.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { installNode } = require('../installers/system/installNode');
|
|
2
|
+
const { info, success } = require('../core/logger');
|
|
3
|
+
|
|
4
|
+
async function install() {
|
|
5
|
+
info('Iniciando instalação completa...');
|
|
6
|
+
await installNode();
|
|
7
|
+
success('Instalação concluída!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { install };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { updateSystem } = require('../installers/system/updateSystem');
|
|
2
|
+
const { info, success } = require('../core/logger');
|
|
3
|
+
|
|
4
|
+
async function update() {
|
|
5
|
+
info('Iniciando atualização...');
|
|
6
|
+
await updateSystem();
|
|
7
|
+
success('Atualização concluída!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { update };
|
package/appInstaller.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
const { mainMenuPrompt } = require('./prompts/mainMenu');
|
|
2
|
+
const { installPrompts } = require('./prompts/installPrompts');
|
|
3
|
+
const { domainPrompt } = require('./prompts/domainPrompts');
|
|
4
|
+
const { updatePrompts } = require('./prompts/updatePrompts');
|
|
5
|
+
|
|
6
|
+
const { updateSystem, installNode, installDocker, installPM2, installNginx, installCertbot, createUser } = require('./installers/system');
|
|
7
|
+
const { createDatabase, createRedis, setEnv: setBackendEnv, installDeps: installBackendDeps, build: buildBackend, migrate, seed, startPM2: startBackendPM2, setupNginx: setupBackendNginx } = require('./installers/backend');
|
|
8
|
+
const { setEnv: setFrontendEnv, installDeps: installFrontendDeps, build: buildFrontend, startPM2: startFrontendPM2, setupNginx: setupFrontendNginx } = require('./installers/frontend');
|
|
9
|
+
const { setupSSL } = require('./ssl/setupSSL');
|
|
10
|
+
|
|
11
|
+
const { info, success } = require('./core/logger');
|
|
12
|
+
|
|
13
|
+
async function runInstaller() {
|
|
14
|
+
info('Bem-vindo ao instalador do AtendeTicket!');
|
|
15
|
+
|
|
16
|
+
const mainMenu = await mainMenuPrompt();
|
|
17
|
+
|
|
18
|
+
if (mainMenu.action === 'install') {
|
|
19
|
+
const answers = await installPrompts();
|
|
20
|
+
|
|
21
|
+
// Generate JWT secrets
|
|
22
|
+
const jwt_secret = require('crypto').randomBytes(64).toString('base64');
|
|
23
|
+
const jwt_refresh_secret = require('crypto').randomBytes(64).toString('base64');
|
|
24
|
+
|
|
25
|
+
// Configurações automáticas do Redis
|
|
26
|
+
const redis_host = "localhost";
|
|
27
|
+
const redis_password = answers.mysql_root_password;
|
|
28
|
+
const redis_uri = `redis://:${redis_password}@${redis_host}:${answers.redisPort}`;
|
|
29
|
+
|
|
30
|
+
// Sistema
|
|
31
|
+
await updateSystem();
|
|
32
|
+
await installNode();
|
|
33
|
+
await installDocker();
|
|
34
|
+
await installPM2();
|
|
35
|
+
await installNginx();
|
|
36
|
+
await installCertbot();
|
|
37
|
+
await createUser(answers.mysql_root_password);
|
|
38
|
+
|
|
39
|
+
// Backend
|
|
40
|
+
await createDatabase(answers.instancia_add, answers.mysql_root_password);
|
|
41
|
+
await createRedis(answers.instancia_add, answers.redisPort, answers.mysql_root_password);
|
|
42
|
+
await setBackendEnv(
|
|
43
|
+
'', // node_env
|
|
44
|
+
answers.backendUrl,
|
|
45
|
+
answers.frontendUrl,
|
|
46
|
+
443, // proxy_port
|
|
47
|
+
answers.backendPort,
|
|
48
|
+
'localhost', // db_host
|
|
49
|
+
'postgres', // db_dialect
|
|
50
|
+
answers.instancia_add, // db_user
|
|
51
|
+
answers.mysql_root_password, // db_pass
|
|
52
|
+
answers.instancia_add, // db_name
|
|
53
|
+
5432, // db_port
|
|
54
|
+
'senha_master', // master_key
|
|
55
|
+
1, // import_fallback_file
|
|
56
|
+
1000, // timeout_to_import_message
|
|
57
|
+
3, // app_trialexpiration
|
|
58
|
+
jwt_secret,
|
|
59
|
+
jwt_refresh_secret,
|
|
60
|
+
redis_uri,
|
|
61
|
+
1, // redis_opt_limiter_max
|
|
62
|
+
3000, // redis_opt_limiter_duration
|
|
63
|
+
8, // flow_menu_cooldown_sec
|
|
64
|
+
answers.max_user, // user_limit
|
|
65
|
+
answers.max_whats, // connections_limit
|
|
66
|
+
true, // closed_send_by_me
|
|
67
|
+
'whaticket', // verify_token
|
|
68
|
+
'', // mp_access_token
|
|
69
|
+
'2813216208828642', // facebook_app_id
|
|
70
|
+
'8233912aeade366dd8e2ebef6be256b6', // facebook_app_secret
|
|
71
|
+
'smtp.gmail.com', // smtp_host
|
|
72
|
+
'587', // smtp_port
|
|
73
|
+
'false', // smtp_secure
|
|
74
|
+
'seuemail@gmail.com', // smtp_user
|
|
75
|
+
'suasenha', // smtp_pass
|
|
76
|
+
'Redefinição de senha <seuemail@gmail.com>' // smtp_from
|
|
77
|
+
);
|
|
78
|
+
await installBackendDeps();
|
|
79
|
+
await buildBackend();
|
|
80
|
+
await migrate();
|
|
81
|
+
await seed();
|
|
82
|
+
await startBackendPM2();
|
|
83
|
+
await setupBackendNginx(answers.backendUrl.replace(/^https?:\/\//, ''));
|
|
84
|
+
|
|
85
|
+
// Frontend
|
|
86
|
+
await setFrontendEnv(
|
|
87
|
+
answers.backendUrl,
|
|
88
|
+
24, // hours_close_tickets_auto
|
|
89
|
+
'https', // backend_protocol
|
|
90
|
+
answers.backendUrl.replace(/^https?:\/\//, ''), // backend_host
|
|
91
|
+
answers.backendPort, // backend_port_param
|
|
92
|
+
'pt-br', // locale
|
|
93
|
+
'America/Sao_Paulo', // timezone
|
|
94
|
+
'55XXXXXXXXXXX', // number_support
|
|
95
|
+
'2813216208828642', // facebook_app_id
|
|
96
|
+
true, // require_business_management
|
|
97
|
+
false, // certificates
|
|
98
|
+
true, // https
|
|
99
|
+
'F:\\bkpidx\\workflow\\backend\\certs\\localhost.pem', // ssl_crt_file
|
|
100
|
+
'F:\\bkpidx\\workflow\\backend\\certs\\localhost-key.pem', // ssl_key_file
|
|
101
|
+
'2813216208828642', // react_app_facebook_app_id
|
|
102
|
+
true, // react_app_require_business_management
|
|
103
|
+
false, // generate_sourcemap
|
|
104
|
+
false // disable_eslint_plugin
|
|
105
|
+
);
|
|
106
|
+
await installFrontendDeps();
|
|
107
|
+
await buildFrontend();
|
|
108
|
+
await startFrontendPM2();
|
|
109
|
+
await setupFrontendNginx(answers.frontendUrl.replace(/^https?:\/\//, ''));
|
|
110
|
+
|
|
111
|
+
// SSL
|
|
112
|
+
const backend_domain = answers.backendUrl.replace(/^https?:\/\//, '');
|
|
113
|
+
const frontend_domain = answers.frontendUrl.replace(/^https?:\/\//, '');
|
|
114
|
+
await setupSSL(backend_domain, frontend_domain, answers.deployEmail);
|
|
115
|
+
|
|
116
|
+
success('Instalação completa do Multizap!');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (mainMenu.action === 'update') {
|
|
120
|
+
const answers = await updatePrompts();
|
|
121
|
+
|
|
122
|
+
if (answers.updateSystem) await updateSystem();
|
|
123
|
+
if (answers.updateBackend) {
|
|
124
|
+
await installBackendDeps();
|
|
125
|
+
await buildBackend();
|
|
126
|
+
await migrate();
|
|
127
|
+
await seed();
|
|
128
|
+
await startBackendPM2();
|
|
129
|
+
}
|
|
130
|
+
if (answers.updateFrontend) {
|
|
131
|
+
await installFrontendDeps();
|
|
132
|
+
await buildFrontend();
|
|
133
|
+
await startFrontendPM2();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
success('Atualização concluída!');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (mainMenu.action === 'changeDomain') {
|
|
140
|
+
const domain = await domainPrompt();
|
|
141
|
+
await setupBackendNginx(domain);
|
|
142
|
+
await setupFrontendNginx(domain);
|
|
143
|
+
await setupSSL(domain);
|
|
144
|
+
success(`Domínio alterado e SSL configurado para ${domain}!`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
module.exports = { runInstaller };
|
package/core/banner.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
function showBanner() {
|
|
4
|
+
console.log(chalk.blue(`
|
|
5
|
+
___ _ _ _ _ _
|
|
6
|
+
/ _ \\ _ __(_)_ _____| | ___ | | (_) | ___
|
|
7
|
+
| | | | '__| \\ \\ / / _ \\ |/ _ \\ | | | | |/ _ \\
|
|
8
|
+
| |_| | | | |\\ V / __/ | __/ | |__| | | __/
|
|
9
|
+
\\___/|_| |_| \\_/ \\___|_|\\___| |____/|_|\\___|
|
|
10
|
+
`));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = { showBanner };
|
package/core/exec.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { spawn } = require('cross-spawn');
|
|
2
|
+
const { info, error } = require('./logger');
|
|
3
|
+
|
|
4
|
+
function runCommand(cmd, args = []) {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
const child = spawn(cmd, args, { stdio: 'inherit' });
|
|
7
|
+
child.on('close', code => {
|
|
8
|
+
if (code === 0) resolve();
|
|
9
|
+
else reject(new Error(`${cmd} falhou com código ${code}`));
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = { runCommand };
|
package/core/logger.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
function info(msg) {
|
|
4
|
+
console.log(chalk.cyan('[INFO]'), msg);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function success(msg) {
|
|
8
|
+
console.log(chalk.green('[SUCCESS]'), msg);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function error(msg) {
|
|
12
|
+
console.error(chalk.red('[ERROR]'), msg);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = { info, success, error };
|
package/index.js
CHANGED
|
@@ -1,50 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
chalk.yellow("Execute o instalador como root:\n") +
|
|
12
|
-
chalk.cyan("sudo atendeticket\n")
|
|
13
|
-
);
|
|
14
|
-
process.exit(1);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// ================================
|
|
18
|
-
// ✅ LIMPA TELA
|
|
19
|
-
// ================================
|
|
20
|
-
console.clear();
|
|
21
|
-
|
|
22
|
-
// ================================
|
|
23
|
-
// ✅ BANNER PROFISSIONAL
|
|
24
|
-
// ================================
|
|
25
|
-
console.log(
|
|
26
|
-
chalk.green.bold(`
|
|
27
|
-
███████╗ █████╗ ████████╗███████╗███╗ ██╗██████╗ ███████╗
|
|
28
|
-
██╔════╝██╔══██╗╚══██╔══╝██╔════╝████╗ ██║██╔══██╗██╔════╝
|
|
29
|
-
█████╗ ███████║ ██║ █████╗ ██╔██╗ ██║██║ ██║█████╗
|
|
30
|
-
██╔══╝ ██╔══██║ ██║ ██╔══╝ ██║╚██╗██║██║ ██║██╔══╝
|
|
31
|
-
██║ ██║ ██║ ██║ ███████╗██║ ╚████║██████╔╝███████╗
|
|
32
|
-
╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝╚═════╝ ╚══════╝
|
|
33
|
-
`
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
console.log(
|
|
38
|
-
chalk.white.bold(" 🚀 ATENDETICKET INSTALLER - v1.0.0\n")
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
// ================================
|
|
42
|
-
// ✅ INICIA O MENU PRINCIPAL
|
|
43
|
-
// ================================
|
|
44
|
-
try {
|
|
45
|
-
await showMainMenu();
|
|
46
|
-
} catch (err) {
|
|
47
|
-
console.log(chalk.red("\n❌ Erro fatal no instalador:\n"));
|
|
48
|
-
console.error(err);
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
2
|
+
const { showBanner } = require('./core/banner');
|
|
3
|
+
const { mainMenuPrompt } = require('./prompts/mainMenu');
|
|
4
|
+
const { handleMenu } = require('./appInstaller');
|
|
5
|
+
|
|
6
|
+
(async () => {
|
|
7
|
+
showBanner();
|
|
8
|
+
const choice = await mainMenuPrompt();
|
|
9
|
+
await handleMenu(choice);
|
|
10
|
+
})();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function build() {
|
|
5
|
+
info('Construindo backend...');
|
|
6
|
+
await runCommand('npm', ['run', 'build']);
|
|
7
|
+
success('Backend construído!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { build };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function createDatabase(instancia_add, mysql_root_password) {
|
|
5
|
+
info(`Configurando PostgreSQL para ${instancia_add}...`);
|
|
6
|
+
|
|
7
|
+
await runCommand('sudo', ['-u', 'postgres', 'createdb', instancia_add]);
|
|
8
|
+
await runCommand('sudo', ['-u', 'postgres', 'psql', '-c', `CREATE USER ${instancia_add} SUPERUSER INHERIT CREATEDB CREATEROLE;`]);
|
|
9
|
+
await runCommand('sudo', ['-u', 'postgres', 'psql', '-c', `ALTER USER ${instancia_add} PASSWORD '${mysql_root_password}';`]);
|
|
10
|
+
|
|
11
|
+
success(`Banco de dados PostgreSQL configurado para ${instancia_add}!`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = { createDatabase };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function createRedis(instancia_add, redis_port, redis_password) {
|
|
5
|
+
info('Criando Redis & Banco Postgres...');
|
|
6
|
+
|
|
7
|
+
// Configurações automáticas do Redis
|
|
8
|
+
const redis_host = "localhost";
|
|
9
|
+
|
|
10
|
+
await runCommand('sudo', ['usermod', '-aG', 'docker', 'deploy']);
|
|
11
|
+
|
|
12
|
+
// Verifica se o container Redis já existe e remove se existir
|
|
13
|
+
try {
|
|
14
|
+
await runCommand('docker', ['ps', '-a', '--filter', `name=redis-${instancia_add}`, '--format', '{{.Names}}']);
|
|
15
|
+
info('Removendo container Redis existente...');
|
|
16
|
+
await runCommand('docker', ['rm', '-f', `redis-${instancia_add}`]);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
// Container não existe, continua
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
info('Criando container Redis...');
|
|
22
|
+
// Cria o container Redis com configurações automáticas
|
|
23
|
+
await runCommand('docker', ['run', '--name', `redis-${instancia_add}`,
|
|
24
|
+
'-p', `${redis_port}:6379`,
|
|
25
|
+
'--restart', 'always',
|
|
26
|
+
'--detach',
|
|
27
|
+
'redis:alpine',
|
|
28
|
+
'redis-server', '--requirepass', redis_password]);
|
|
29
|
+
|
|
30
|
+
// Aguarda o Redis inicializar
|
|
31
|
+
info('Aguardando Redis inicializar...');
|
|
32
|
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
33
|
+
|
|
34
|
+
// Verifica se o Redis está rodando
|
|
35
|
+
await runCommand('docker', ['ps', '--filter', `name=redis-${instancia_add}`]);
|
|
36
|
+
|
|
37
|
+
success('Redis criado com sucesso!');
|
|
38
|
+
info(`Porta: ${redis_port}`);
|
|
39
|
+
info(`Senha: mesma do banco`);
|
|
40
|
+
|
|
41
|
+
// Configuração do PostgreSQL
|
|
42
|
+
info('Configurando PostgreSQL...');
|
|
43
|
+
await runCommand('sudo', ['-u', 'postgres', 'createdb', instancia_add]);
|
|
44
|
+
await runCommand('sudo', ['-u', 'postgres', 'psql', '-c', `CREATE USER ${instancia_add} SUPERUSER INHERIT CREATEDB CREATEROLE;`]);
|
|
45
|
+
await runCommand('sudo', ['-u', 'postgres', 'psql', '-c', `ALTER USER ${instancia_add} PASSWORD '${redis_password}';`]);
|
|
46
|
+
|
|
47
|
+
success('PostgreSQL configurado!');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = { createRedis };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function installDeps() {
|
|
5
|
+
info('Instalando dependências do backend...');
|
|
6
|
+
await runCommand('npm', ['install']);
|
|
7
|
+
success('Dependências do backend instaladas!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { installDeps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function seed() {
|
|
5
|
+
info('Populando banco com seed...');
|
|
6
|
+
await runCommand('npm', ['run', 'seed']);
|
|
7
|
+
success('Seed concluída!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { seed };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
const { info, success } = require('../../core/logger');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
async function setEnv(node_env, backend_url, frontend_url, proxy_port, port, db_host, db_dialect, db_user, db_pass, db_name, db_port, master_key, import_fallback_file, timeout_to_import_message, app_trialexpiration, jwt_secret, jwt_refresh_secret, redis_uri, redis_opt_limiter_max, redis_opt_limiter_duration, flow_menu_cooldown_sec, user_limit, connections_limit, closed_send_by_me, verify_token, mp_access_token, facebook_app_id, facebook_app_secret, smtp_host, smtp_port, smtp_secure, smtp_user, smtp_pass, smtp_from) {
|
|
6
|
+
info('Configurando variáveis de ambiente (backend)...');
|
|
7
|
+
|
|
8
|
+
// ensure idempotency
|
|
9
|
+
let backendUrl = backend_url.replace(/^https?:\/\//, '');
|
|
10
|
+
backendUrl = backendUrl.split('/')[0];
|
|
11
|
+
backendUrl = `https://${backendUrl}`;
|
|
12
|
+
|
|
13
|
+
// ensure idempotency
|
|
14
|
+
let frontendUrl = frontend_url.replace(/^https?:\/\//, '');
|
|
15
|
+
frontendUrl = frontendUrl.split('/')[0];
|
|
16
|
+
frontendUrl = `https://${frontendUrl}`;
|
|
17
|
+
|
|
18
|
+
const envContent = `NODE_ENV=${node_env}
|
|
19
|
+
BACKEND_URL=${backendUrl}
|
|
20
|
+
FRONTEND_URL=${frontendUrl}
|
|
21
|
+
PROXY_PORT=${proxy_port}
|
|
22
|
+
PORT=${port}
|
|
23
|
+
|
|
24
|
+
DB_HOST=${db_host}
|
|
25
|
+
DB_DIALECT=${db_dialect}
|
|
26
|
+
DB_USER=${db_user}
|
|
27
|
+
DB_PASS=${db_pass}
|
|
28
|
+
DB_NAME=${db_name}
|
|
29
|
+
DB_PORT=${db_port}
|
|
30
|
+
|
|
31
|
+
MASTER_KEY=${master_key}
|
|
32
|
+
|
|
33
|
+
IMPORT_FALLBACK_FILE=${import_fallback_file}
|
|
34
|
+
|
|
35
|
+
TIMEOUT_TO_IMPORT_MESSAGE=${timeout_to_import_message}
|
|
36
|
+
|
|
37
|
+
APP_TRIALEXPIRATION=${app_trialexpiration}
|
|
38
|
+
|
|
39
|
+
JWT_SECRET=${jwt_secret}
|
|
40
|
+
JWT_REFRESH_SECRET=${jwt_refresh_secret}
|
|
41
|
+
|
|
42
|
+
# REDIS CONFIGURADO AUTOMATICAMENTE
|
|
43
|
+
REDIS_URI=${redis_uri}
|
|
44
|
+
REDIS_OPT_LIMITER_MAX=${redis_opt_limiter_max}
|
|
45
|
+
REDIS_OPT_LIMITER_DURATION=${redis_opt_limiter_duration}
|
|
46
|
+
|
|
47
|
+
FLOW_MENU_COOLDOWN_SEC=${flow_menu_cooldown_sec}
|
|
48
|
+
|
|
49
|
+
USER_LIMIT=${user_limit}
|
|
50
|
+
CONNECTIONS_LIMIT=${connections_limit}
|
|
51
|
+
CLOSED_SEND_BY_ME=${closed_send_by_me}
|
|
52
|
+
|
|
53
|
+
VERIFY_TOKEN=${verify_token}
|
|
54
|
+
|
|
55
|
+
#METODOS DE PAGAMENTO
|
|
56
|
+
MP_ACCESS_TOKEN=${mp_access_token}
|
|
57
|
+
|
|
58
|
+
FACEBOOK_APP_ID=${facebook_app_id}
|
|
59
|
+
FACEBOOK_APP_SECRET=${facebook_app_secret}
|
|
60
|
+
|
|
61
|
+
# EMAIL
|
|
62
|
+
SMTP_HOST="${smtp_host}"
|
|
63
|
+
SMTP_PORT="${smtp_port}"
|
|
64
|
+
SMTP_SECURE="${smtp_secure}"
|
|
65
|
+
SMTP_USER="${smtp_user}"
|
|
66
|
+
SMTP_PASS="${smtp_pass}"
|
|
67
|
+
SMTP_FROM="${smtp_from}"`;
|
|
68
|
+
|
|
69
|
+
const envPath = path.join(process.cwd(), 'backend', '.env');
|
|
70
|
+
fs.writeFileSync(envPath, envContent);
|
|
71
|
+
|
|
72
|
+
success('Variáveis de ambiente configuradas com Redis automático');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { setEnv };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function setupNginx(domain) {
|
|
5
|
+
info(`Configurando Nginx para ${domain}...`);
|
|
6
|
+
// placeholder: criar arquivo de config Nginx
|
|
7
|
+
success(`Nginx configurado para ${domain}!`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { setupNginx };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function startPM2() {
|
|
5
|
+
info('Iniciando backend com PM2...');
|
|
6
|
+
await runCommand('pm2', ['start', 'npm', '--name', 'backend', '--', 'start']);
|
|
7
|
+
success('Backend iniciado com PM2!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { startPM2 };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function build() {
|
|
5
|
+
info('Construindo frontend...');
|
|
6
|
+
await runCommand('npm', ['run', 'build']);
|
|
7
|
+
success('Frontend construído!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { build };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function installDeps() {
|
|
5
|
+
info('Instalando dependências do frontend...');
|
|
6
|
+
await runCommand('npm', ['install']);
|
|
7
|
+
success('Dependências do frontend instaladas!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { installDeps };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const { info, success } = require('../../core/logger');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
async function setEnv(backend_url, hours_close_tickets_auto, backend_protocol, backend_host, backend_port_param, locale, timezone, number_support, facebook_app_id, require_business_management, certificates, https, ssl_crt_file, ssl_key_file, react_app_facebook_app_id, react_app_require_business_management, generate_sourcemap, disable_eslint_plugin) {
|
|
6
|
+
info('Configurando variáveis de ambiente (frontend)...');
|
|
7
|
+
|
|
8
|
+
// ensure idempotency
|
|
9
|
+
let backendUrl = backend_url.replace(/^https?:\/\//, '');
|
|
10
|
+
backendUrl = backendUrl.split('/')[0];
|
|
11
|
+
backendUrl = `https://${backendUrl}`;
|
|
12
|
+
|
|
13
|
+
const envContent = `REACT_APP_BACKEND_URL=${backendUrl}
|
|
14
|
+
REACT_APP_HOURS_CLOSE_TICKETS_AUTO=${hours_close_tickets_auto}
|
|
15
|
+
|
|
16
|
+
REACT_APP_BACKEND_PROTOCOL=${backend_protocol}
|
|
17
|
+
REACT_APP_BACKEND_HOST=${backend_host}
|
|
18
|
+
REACT_APP_BACKEND_PORT=${backend_port_param}
|
|
19
|
+
REACT_APP_LOCALE=${locale}
|
|
20
|
+
REACT_APP_TIMEZONE=${timezone}
|
|
21
|
+
REACT_APP_NUMBER_SUPPORT=${number_support}
|
|
22
|
+
|
|
23
|
+
CERTIFICADOS=${certificates}
|
|
24
|
+
HTTPS=${https}
|
|
25
|
+
SSL_CRT_FILE=${ssl_crt_file}
|
|
26
|
+
SSL_KEY_FILE=${ssl_key_file}
|
|
27
|
+
|
|
28
|
+
REACT_APP_FACEBOOK_APP_ID=${facebook_app_id}
|
|
29
|
+
REACT_APP_REQUIRE_BUSINESS_MANAGEMENT=${require_business_management}
|
|
30
|
+
|
|
31
|
+
# Variáveis para build
|
|
32
|
+
GENERATE_SOURCEMAP=${generate_sourcemap}
|
|
33
|
+
DISABLE_ESLINT_PLUGIN=${disable_eslint_plugin}`;
|
|
34
|
+
|
|
35
|
+
const envPath = path.join(process.cwd(), 'frontend', '.env');
|
|
36
|
+
fs.writeFileSync(envPath, envContent);
|
|
37
|
+
|
|
38
|
+
// Create server.js for production build
|
|
39
|
+
const serverContent = `//simple express server to run frontend production build;
|
|
40
|
+
const express = require("express");
|
|
41
|
+
const path = require("path");
|
|
42
|
+
const app = express();
|
|
43
|
+
app.use(express.static(path.join(__dirname, "build")));
|
|
44
|
+
app.get("/*", function (req, res) {
|
|
45
|
+
res.sendFile(path.join(__dirname, "build", "index.html"));
|
|
46
|
+
});
|
|
47
|
+
app.listen(${backend_port_param});`;
|
|
48
|
+
|
|
49
|
+
const serverPath = path.join(process.cwd(), 'frontend', 'server.js');
|
|
50
|
+
fs.writeFileSync(serverPath, serverContent);
|
|
51
|
+
|
|
52
|
+
success('Variáveis de ambiente do frontend configuradas!');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = { setEnv };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function setupNginx(domain) {
|
|
5
|
+
info(`Configurando Nginx para frontend em ${domain}...`);
|
|
6
|
+
// placeholder: criar arquivo de config Nginx
|
|
7
|
+
success(`Nginx configurado para frontend em ${domain}!`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { setupNginx };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function startPM2() {
|
|
5
|
+
info('Iniciando frontend com PM2...');
|
|
6
|
+
await runCommand('pm2', ['start', 'npm', '--name', 'frontend', '--', 'start']);
|
|
7
|
+
success('Frontend iniciado com PM2!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { startPM2 };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function createUser(username) {
|
|
5
|
+
info(`Criando usuário ${username}...`);
|
|
6
|
+
await runCommand('sudo', ['adduser', username]);
|
|
7
|
+
success(`Usuário ${username} criado!`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { createUser };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function installCertbot() {
|
|
5
|
+
info('Instalando Certbot...');
|
|
6
|
+
await runCommand('sudo', ['apt', 'install', '-y', 'certbot', 'python3-certbot-nginx']);
|
|
7
|
+
success('Certbot instalado!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { installCertbot };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function installDocker() {
|
|
5
|
+
info('Instalando Docker...');
|
|
6
|
+
await runCommand('sudo', ['apt', 'install', '-y', 'docker.io']);
|
|
7
|
+
await runCommand('sudo', ['systemctl', 'enable', '--now', 'docker']);
|
|
8
|
+
success('Docker instalado!');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = { installDocker };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function installNginx() {
|
|
5
|
+
info('Instalando Nginx...');
|
|
6
|
+
await runCommand('sudo', ['apt', 'install', '-y', 'nginx']);
|
|
7
|
+
await runCommand('sudo', ['systemctl', 'enable', '--now', 'nginx']);
|
|
8
|
+
success('Nginx instalado!');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = { installNginx };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function installNode() {
|
|
5
|
+
info('Instalando Node.js...');
|
|
6
|
+
await runCommand('sudo', ['apt', 'update']);
|
|
7
|
+
await runCommand('sudo', ['apt', 'install', '-y', 'nodejs', 'npm']);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { installNode };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function installPM2() {
|
|
5
|
+
info('Instalando PM2...');
|
|
6
|
+
await runCommand('sudo', ['npm', 'install', '-g', 'pm2']);
|
|
7
|
+
success('PM2 instalado!');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { installPM2 };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info, success } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function updateSystem() {
|
|
5
|
+
info('Atualizando pacotes do sistema...');
|
|
6
|
+
await runCommand('sudo', ['apt', 'update']);
|
|
7
|
+
await runCommand('sudo', ['apt', 'upgrade', '-y']);
|
|
8
|
+
success('Sistema atualizado!');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = { updateSystem };
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "atendeticket",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "atendeticket",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Instalador CLI para AtendeTicket",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "node index.js"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"atendeticket": "./index.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"chalk": "^5.3.0",
|
|
14
|
+
"inquirer": "^9.2.7",
|
|
15
|
+
"cross-spawn": "^7.0.6"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const inquirer = require('inquirer');
|
|
2
|
+
|
|
3
|
+
async function domainPrompt() {
|
|
4
|
+
const answers = await inquirer.prompt([
|
|
5
|
+
{ type: 'input', name: 'domain', message: 'Informe o domínio que deseja configurar:' }
|
|
6
|
+
]);
|
|
7
|
+
return answers.domain;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { domainPrompt };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const inquirer = require('inquirer');
|
|
2
|
+
|
|
3
|
+
async function installPrompts() {
|
|
4
|
+
const answers = await inquirer.prompt([
|
|
5
|
+
{ type: 'input', name: 'domain', message: 'Informe o domínio:' },
|
|
6
|
+
{ type: 'confirm', name: 'ssl', message: 'Deseja configurar SSL?', default: true },
|
|
7
|
+
]);
|
|
8
|
+
return answers;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = { installPrompts };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const inquirer = require('inquirer');
|
|
2
|
+
|
|
3
|
+
async function mainMenuPrompt() {
|
|
4
|
+
const answers = await inquirer.prompt([
|
|
5
|
+
{
|
|
6
|
+
type: 'list',
|
|
7
|
+
name: 'action',
|
|
8
|
+
message: 'Escolha uma ação:',
|
|
9
|
+
choices: [
|
|
10
|
+
{ name: 'Instalar sistema', value: 'install' },
|
|
11
|
+
{ name: 'Atualizar sistema', value: 'update' },
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
]);
|
|
15
|
+
return answers.action;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = { mainMenuPrompt };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const inquirer = require('inquirer');
|
|
2
|
+
|
|
3
|
+
async function updatePrompts() {
|
|
4
|
+
const answers = await inquirer.prompt([
|
|
5
|
+
{ type: 'confirm', name: 'updateSystem', message: 'Deseja atualizar o sistema?', default: true },
|
|
6
|
+
{ type: 'confirm', name: 'updateBackend', message: 'Deseja atualizar o backend?', default: true },
|
|
7
|
+
{ type: 'confirm', name: 'updateFrontend', message: 'Deseja atualizar o frontend?', default: true },
|
|
8
|
+
]);
|
|
9
|
+
return answers;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = { updatePrompts };
|
package/ssl/setupSSL.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const { runCommand } = require('../core/exec');
|
|
2
|
+
const { info, success } = require('../core/logger');
|
|
3
|
+
|
|
4
|
+
async function setupSSL(domain) {
|
|
5
|
+
info(`Configurando SSL para ${domain}...`);
|
|
6
|
+
await runCommand('sudo', ['certbot', '--nginx', '-d', domain, '--non-interactive', '--agree-tos', '-m', 'admin@' + domain]);
|
|
7
|
+
success(`SSL configurado para ${domain}!`);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = { setupSSL };
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 AtendeTicket
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/src/appInstaller.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import inquirer from "inquirer";
|
|
2
|
-
|
|
3
|
-
import { checkRoot } from "./installer/01-checkRoot.js";
|
|
4
|
-
import { installSystemDeps } from "./installer/02-systemDeps.js";
|
|
5
|
-
import { installNode } from "./installer/03-nodejs.js";
|
|
6
|
-
import { installPM2 } from "./installer/04-pm2.js";
|
|
7
|
-
import { installNginx } from "./installer/05-nginx.js";
|
|
8
|
-
import { installCertbot } from "./installer/06-certbot.js";
|
|
9
|
-
import { cloneRepos } from "./installer/07-cloneRepos.js";
|
|
10
|
-
import { setupBackend } from "./installer/08-backend.js";
|
|
11
|
-
import { setupFrontend } from "./installer/09-frontend.js";
|
|
12
|
-
import { createEnv } from "./installer/10-env.js";
|
|
13
|
-
import { startPM2 } from "./installer/11-pm2Start.js";
|
|
14
|
-
import { setupProxy } from "./installer/12-nginxProxy.js";
|
|
15
|
-
import { setupSSL } from "./installer/13-ssl.js";
|
|
16
|
-
import { finalReport } from "./installer/14-finalReport.js";
|
|
17
|
-
|
|
18
|
-
export async function installAtendeTicket() {
|
|
19
|
-
checkRoot();
|
|
20
|
-
|
|
21
|
-
const answers = await inquirer.prompt([
|
|
22
|
-
{ name: "domain", message: "Domínio:" },
|
|
23
|
-
{ name: "backendPort", message: "Porta do backend:", default: "3000" },
|
|
24
|
-
{ name: "repoBackend", message: "Repo BACKEND:" },
|
|
25
|
-
{ name: "repoFrontend", message: "Repo FRONTEND:" }
|
|
26
|
-
]);
|
|
27
|
-
|
|
28
|
-
installSystemDeps();
|
|
29
|
-
installNode();
|
|
30
|
-
installPM2();
|
|
31
|
-
installNginx();
|
|
32
|
-
installCertbot();
|
|
33
|
-
|
|
34
|
-
cloneRepos({
|
|
35
|
-
backend: answers.repoBackend,
|
|
36
|
-
frontend: answers.repoFrontend
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
setupBackend();
|
|
40
|
-
setupFrontend();
|
|
41
|
-
createEnv({ backendPort: answers.backendPort });
|
|
42
|
-
|
|
43
|
-
startPM2();
|
|
44
|
-
setupProxy({ domain: answers.domain, backendPort: answers.backendPort });
|
|
45
|
-
setupSSL(answers.domain);
|
|
46
|
-
|
|
47
|
-
finalReport(answers.domain);
|
|
48
|
-
}
|
package/src/core/logger.js
DELETED
package/src/core/rollback.js
DELETED
package/src/core/run.js
DELETED
package/src/installer/04-pm2.js
DELETED
package/src/installer/10-env.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { run } from "../core/run.js";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
|
|
4
|
-
export function setupProxy({ domain, backendPort }) {
|
|
5
|
-
const conf = `
|
|
6
|
-
server {
|
|
7
|
-
listen 80;
|
|
8
|
-
server_name ${domain};
|
|
9
|
-
|
|
10
|
-
location / {
|
|
11
|
-
root /var/www/atendeticket/frontend/dist;
|
|
12
|
-
index index.html;
|
|
13
|
-
try_files $uri $uri/ /index.html;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
location /api {
|
|
17
|
-
proxy_pass http://localhost:${backendPort};
|
|
18
|
-
proxy_set_header Host $host;
|
|
19
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
fs.writeFileSync("/etc/nginx/sites-available/atendeticket", conf);
|
|
25
|
-
|
|
26
|
-
run("ln -sf /etc/nginx/sites-available/atendeticket /etc/nginx/sites-enabled/");
|
|
27
|
-
run("nginx -t");
|
|
28
|
-
run("systemctl reload nginx");
|
|
29
|
-
}
|
package/src/installer/13-ssl.js
DELETED
package/src/menu.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import inquirer from "inquirer";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
|
|
4
|
-
import { installAtendeTicket } from "./appInstaller.js";
|
|
5
|
-
|
|
6
|
-
export async function showMainMenu() {
|
|
7
|
-
const { option } = await inquirer.prompt([
|
|
8
|
-
{
|
|
9
|
-
type: "list",
|
|
10
|
-
name: "option",
|
|
11
|
-
message: "O que deseja fazer?",
|
|
12
|
-
choices: [
|
|
13
|
-
{ name: "🚀 Instalar AtendeTicket Completo", value: "app" },
|
|
14
|
-
{ name: "🛠 Instalar dependências do sistema", value: "system" },
|
|
15
|
-
{ name: "⚡ Configurar PM2", value: "pm2" },
|
|
16
|
-
{ name: "🌐 Configurar NGINX", value: "nginx" },
|
|
17
|
-
{ name: "❌ Sair", value: "exit" }
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
switch (option) {
|
|
23
|
-
case "app":
|
|
24
|
-
await installAtendeTicket();
|
|
25
|
-
break;
|
|
26
|
-
|
|
27
|
-
case "system":
|
|
28
|
-
console.log(chalk.yellow("Instalação de sistema ainda não ligada ao menu."));
|
|
29
|
-
break;
|
|
30
|
-
|
|
31
|
-
case "pm2":
|
|
32
|
-
console.log(chalk.yellow("Configuração do PM2 ainda não ligada ao menu."));
|
|
33
|
-
break;
|
|
34
|
-
|
|
35
|
-
case "nginx":
|
|
36
|
-
console.log(chalk.yellow("Configuração do NGINX ainda não ligada ao menu."));
|
|
37
|
-
break;
|
|
38
|
-
|
|
39
|
-
case "exit":
|
|
40
|
-
console.log(chalk.red("Saindo do instalador..."));
|
|
41
|
-
process.exit(0);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Volta para o menu após qualquer ação
|
|
45
|
-
await showMainMenu();
|
|
46
|
-
}
|
|
File without changes
|