atendeticket 2.1.12 → 2.1.16
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/TODO.md +23 -0
- package/appInstaller.js +1 -299
- package/instalador_antigo/LICENSE +5 -0
- package/instalador_antigo/Multizap.zip +0 -0
- package/instalador_antigo/README.md +10 -0
- package/instalador_antigo/config +3 -0
- package/instalador_antigo/instalar_nova_instancia +75 -0
- package/instalador_antigo/instalar_primaria +220 -0
- package/instalador_antigo/lib/_backend.sh +453 -0
- package/instalador_antigo/lib/_frontend.sh +342 -0
- package/instalador_antigo/lib/_inquiry.sh +247 -0
- package/instalador_antigo/lib/_system.sh +676 -0
- package/instalador_antigo/lib/manifest.sh +6 -0
- package/instalador_antigo/utils/_banner.sh +45 -0
- package/instalador_antigo/utils/manifest.sh +3 -0
- package/instalador_antigo/variables/_app.sh +15 -0
- package/instalador_antigo/variables/_background.sh +6 -0
- package/instalador_antigo/variables/_fonts.sh +16 -0
- package/instalador_antigo/variables/_general.sh +5 -0
- package/instalador_antigo/variables/manifest.sh +6 -0
- package/installers/backend/createDatabase.js +31 -3
- package/installers/system/certbotSetup.js +16 -0
- package/installers/system/copyProjectFiles.js +20 -0
- package/installers/system/createUser.js +12 -6
- package/installers/system/index.js +12 -2
- package/package.json +1 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Variables to be used for background styling.
|
|
4
|
+
|
|
5
|
+
# app variables
|
|
6
|
+
|
|
7
|
+
jwt_secret=$(openssl rand -base64 32)
|
|
8
|
+
jwt_refresh_secret=$(openssl rand -base64 32)
|
|
9
|
+
|
|
10
|
+
db_pass=$(openssl rand -base64 32)
|
|
11
|
+
|
|
12
|
+
db_user=$(openssl rand -base64 32)
|
|
13
|
+
db_name=$(openssl rand -base64 32)
|
|
14
|
+
|
|
15
|
+
deploy_email=deploy@deploy.com
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Variables to be used for font styling.
|
|
4
|
+
|
|
5
|
+
# color
|
|
6
|
+
readonly RED="\033[1;31m"
|
|
7
|
+
readonly GREEN="\033[1;32m"
|
|
8
|
+
readonly BLUE="\033[1;32m"
|
|
9
|
+
readonly WHITE="\033[1;37m"
|
|
10
|
+
readonly YELLOW="\033[1;33m"
|
|
11
|
+
readonly GRAY_LIGHT="\033[0;37m"
|
|
12
|
+
readonly CYAN_LIGHT="\033[1;36m"
|
|
13
|
+
|
|
14
|
+
# thickness
|
|
15
|
+
readonly BOLD=$(tput bold)
|
|
16
|
+
readonly NORMAL=$(tput sgr0)
|
|
@@ -4,9 +4,37 @@ const { info, success } = require('../../core/logger');
|
|
|
4
4
|
async function createDatabase(instancia_add, mysql_root_password) {
|
|
5
5
|
info(`Configurando PostgreSQL para ${instancia_add}...`);
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// Instala PostgreSQL caso não exista
|
|
8
|
+
try {
|
|
9
|
+
await runCommand('psql', ['--version']);
|
|
10
|
+
} catch {
|
|
11
|
+
info('PostgreSQL não encontrado, instalando...');
|
|
12
|
+
await runCommand('sudo', ['apt', 'update']);
|
|
13
|
+
await runCommand('sudo', ['apt', 'install', '-y', 'postgresql', 'postgresql-contrib']);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Criação de banco e usuário de forma não interativa
|
|
17
|
+
const sql = `
|
|
18
|
+
DO
|
|
19
|
+
$$
|
|
20
|
+
BEGIN
|
|
21
|
+
IF NOT EXISTS (SELECT FROM pg_database WHERE datname = '${instancia_add}') THEN
|
|
22
|
+
CREATE DATABASE ${instancia_add};
|
|
23
|
+
END IF;
|
|
24
|
+
END
|
|
25
|
+
$$;
|
|
26
|
+
|
|
27
|
+
DO
|
|
28
|
+
$$
|
|
29
|
+
BEGIN
|
|
30
|
+
IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '${instancia_add}') THEN
|
|
31
|
+
CREATE ROLE ${instancia_add} SUPERUSER INHERIT CREATEDB CREATEROLE LOGIN PASSWORD '${mysql_root_password}';
|
|
32
|
+
END IF;
|
|
33
|
+
END
|
|
34
|
+
$$;
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
await runCommand('sudo', ['-u', 'postgres', 'psql', '-v', 'ON_ERROR_STOP=1', '-c', sql]);
|
|
10
38
|
|
|
11
39
|
success(`Banco de dados PostgreSQL configurado para ${instancia_add}!`);
|
|
12
40
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info } = require('../../core/logger');
|
|
3
|
+
|
|
4
|
+
async function systemCertbotSetup(backendUrl, frontendUrl, email) {
|
|
5
|
+
info('Configurando SSL com Certbot...');
|
|
6
|
+
|
|
7
|
+
// Extract domains
|
|
8
|
+
const backendDomain = backendUrl.replace(/^https?:\/\//, '').split('/')[0];
|
|
9
|
+
const frontendDomain = frontendUrl.replace(/^https?:\/\//, '').split('/')[0];
|
|
10
|
+
|
|
11
|
+
await runCommand('sudo', ['certbot', '--nginx', '--agree-tos', '--non-interactive', '--domains', `${backendDomain},${frontendDomain}`, '--email', email]);
|
|
12
|
+
|
|
13
|
+
info('✅ SSL configurado com sucesso!');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = { systemCertbotSetup };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const { runCommand } = require('../../core/exec');
|
|
2
|
+
const { info } = require('../../core/logger');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
async function systemCopyProjectFiles(instanceName) {
|
|
6
|
+
info(`💻 Copiando arquivos do projeto para ${instanceName}...`);
|
|
7
|
+
|
|
8
|
+
// Assume AtendeTicket.zip está no diretório raiz do projeto
|
|
9
|
+
const zipPath = path.join(__dirname, '../../AtendeTicket.zip');
|
|
10
|
+
|
|
11
|
+
// Copia o zip para a pasta da instância
|
|
12
|
+
await runCommand('sudo', ['cp', '-f', zipPath, `/home/deploy/${instanceName}/`]);
|
|
13
|
+
|
|
14
|
+
// Muda proprietário para deploy
|
|
15
|
+
await runCommand('sudo', ['chown', 'deploy:deploy', `/home/deploy/${instanceName}/AtendeTicket.zip`]);
|
|
16
|
+
|
|
17
|
+
info(`✅ Arquivos copiados com sucesso!`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = { systemCopyProjectFiles };
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
const { runCommand } = require('../../core/exec');
|
|
2
|
-
const { info
|
|
2
|
+
const { info } = require('../../core/logger');
|
|
3
3
|
|
|
4
|
-
async function
|
|
5
|
-
info(
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
async function systemCreateUser(username, password) {
|
|
5
|
+
info(`💻 Agora, vamos criar o usuário ${username} para a nova instância...`);
|
|
6
|
+
|
|
7
|
+
// Cria o usuário com home, shell bash e grupo sudo
|
|
8
|
+
await runCommand('sudo', ['useradd', '-m', '-s', '/bin/bash', '-G', 'sudo', username]);
|
|
9
|
+
|
|
10
|
+
// Define a senha do usuário de forma não interativa
|
|
11
|
+
await runCommand('sudo', ['chpasswd'], { input: `${username}:${password}` });
|
|
12
|
+
|
|
13
|
+
info(`✅ Usuário ${username} criado com sucesso!`);
|
|
8
14
|
}
|
|
9
15
|
|
|
10
|
-
module.exports = {
|
|
16
|
+
module.exports = { systemCreateUser };
|
|
@@ -4,7 +4,12 @@ const { installDocker } = require('./installDocker');
|
|
|
4
4
|
const { installPM2 } = require('./installPM2');
|
|
5
5
|
const { installNginx } = require('./installNginx');
|
|
6
6
|
const { installCertbot } = require('./installCertbot');
|
|
7
|
-
const {
|
|
7
|
+
const { systemCreateUser } = require('./createUser');
|
|
8
|
+
const { systemCreateFolder } = require('./createFolder');
|
|
9
|
+
const { systemCopyProjectFiles } = require('./copyProjectFiles');
|
|
10
|
+
const { systemUnzipMultizap } = require('./unzipMultizap');
|
|
11
|
+
const { systemNginxRestart } = require('./nginxRestart');
|
|
12
|
+
const { systemCertbotSetup } = require('./certbotSetup');
|
|
8
13
|
|
|
9
14
|
module.exports = {
|
|
10
15
|
updateSystem,
|
|
@@ -13,5 +18,10 @@ module.exports = {
|
|
|
13
18
|
installPM2,
|
|
14
19
|
installNginx,
|
|
15
20
|
installCertbot,
|
|
16
|
-
|
|
21
|
+
systemCreateUser,
|
|
22
|
+
systemCreateFolder,
|
|
23
|
+
systemCopyProjectFiles,
|
|
24
|
+
systemUnzipMultizap,
|
|
25
|
+
systemNginxRestart,
|
|
26
|
+
systemCertbotSetup
|
|
17
27
|
};
|