atendeticket 2.1.9 → 2.1.13
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.
|
@@ -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
|
}
|
|
@@ -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 };
|
|
@@ -3,7 +3,7 @@ const { info, success } = require('../../core/logger');
|
|
|
3
3
|
|
|
4
4
|
async function installNode() {
|
|
5
5
|
info('Instalando Node.js + NPM + NPX...');
|
|
6
|
-
await runCommand('
|
|
6
|
+
await runCommand('bash', ['-c', 'curl -fsSL https://deb.nodesource.com/setup_20.x | bash -']);
|
|
7
7
|
await runCommand('sudo', ['apt', 'install', '-y', 'nodejs']);
|
|
8
8
|
await runCommand('sudo', ['npm', 'install', '-g', 'npm@latest']);
|
|
9
9
|
success('Node.js + NPM + NPX instalados!');
|