-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathevolution_e_typebot.sh
614 lines (458 loc) · 14.7 KB
/
evolution_e_typebot.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
#######################################################
clear
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m _______ _ _ _______ ______ _ \e[0m"
echo -e "\e[32m(_______) | | _ (_) (_______)(_____ \ | |\e[0m"
echo -e "\e[32m _____ _ _ ___ | | _ _ _| |_ _ ___ ____ _______ _____) )| |\e[0m"
echo -e "\e[32m| ___) | | | | / _ \ | | | | | |(_ _)| | / _ \ | _ \ | ___ || ____/ | |\e[0m"
echo -e "\e[32m| |_____ \ V / | |_| || | | |_| | | |_ | || |_| || | | | | | | || | | |\e[0m"
echo -e "\e[32m|_______) \_/ \___/ \_)|____/ \__)|_| \___/ |_| |_| |_| |_||_| |_|\e[0m"
echo -e "\e[32m \e[0m"
echo -e "\e[32m ___ _______ _ \e[0m"
echo -e "\e[32m / _ \ (_______) | | _ \e[0m"
echo -e "\e[32m( (_) ) _ _ _ ____ _____ | |__ ___ _| |_ \e[0m"
echo -e "\e[32m ) _ ( | | | | | || _ \ | ___ || _ \ / _ \ (_ _)\e[0m"
echo -e "\e[32m( (/ \ | | | |_| || |_| || ____|| |_) )| |_| | | |_ \e[0m"
echo -e "\e[32m \__/\_) |_| \__ || __/ |_____)|____/ \___/ \__)\e[0m"
echo -e "\e[32m (____/ |_| \e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
sleep 3
#######################################################
echo "Preencha as informações a serguir para criar o env da Evolution"
echo ""
read -p "Digite seu dominio para acessar a api (ex: api.dominio.com): " dominio
echo ""
read -p "Digite a porta da api (padrão: 8080): " porta
echo ""
read -p "Digite o nome da sua empresa (ex: OrionDesign): " client
echo ""
echo "crie sua ApiKey no link: https://codebeautify.org/generate-random-hexadecimal-numbers"
read -p "Digite sua ApiKey Global (ex: 1169f6f7306fe524e54f79e45ba012cf): " keyy
echo ""
echo ""
echo ""
echo ""
echo "Agora as informações do Docker Composer do Typebot"
echo ""
read -p "Link do Builder (ex: typebot.seudominio.com): " builder
echo ""
read -p "Porta do Builder (padrão: 3001): " portabuilder
echo ""
read -p "Link do Viewer (ex: bot.seudominio.com): " viewer
echo ""
read -p "Porta do Viewer (padrão: 3002): " portaviewer
echo ""
read -p "Link do Storage (ex: storage.seudominio.com): " storage
echo ""
read -p "Porta do Storage (padrão: 9000): " portastorage
echo ""
read -p "Seu Email (ex: [email protected]): " email
echo ""
read -p "Senha do seu Email (se for gmail, precisa ser a senha de aplicativo): " senha
echo ""
read -p "SMTP do seu email (ex: smtp.hostinger.com): " smtp
echo ""
read -p "Porta SMTP (ex: 465): " portasmtp
echo ""
read -p "SMTP_SECURE (Se a porta SMTP for 465, digite true, caso contrario,digite false): " SECURE #novo
echo ""
echo "crie sua ApiKey no link: https://codebeautify.org/generate-random-hexadecimal-numbers"
read -p "Chave secreta de 32 caracteres: (ex: c56f3775313440c3edce57529a0f02b4) " key
#######################################################
echo "Instalando as Dependencias"
sleep 3
clear
sudo apt update -y
sudo apt upgrade -y
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash - && apt-get install -y nodejs
npm install -g npm@latest
npm install -g pm2@latest
apt-get install -y git zip unzip nload snapd curl wget sudo
sudo timedatectl set-timezone America/Sao_Paulo
apt update && apt -y upgrade
apt install docker-compose -y
sudo apt update
sudo apt install nginx -y
sudo apt update
sudo apt install certbot -y
sudo apt install python3-certbot-nginx -y
sudo apt update
#systemctl start nginx
#systemctl enable nginx
#snap install --classic certbot
#rm /etc/nginx/sites-enabled/default
clear
cd
cd
#######################################################
echo "Clonando git"
git clone https://github.com/EvolutionAPI/evolution-api.git
#cd evolution-api
#git branch -a
#git checkout develop
cd
cd
echo "Criando Env e Instalando com NPM"
cat > env.yml << EOL
# Choose the server type for the application
SERVER:
TYPE: http # https
PORT: $porta # 443
URL: https://$dominio
CORS:
ORIGIN:
- "*"
# - yourdomain.com
METHODS:
- POST
- GET
- PUT
- DELETE
CREDENTIALS: true
# Install ssl certificate and replace string <domain> with domain name
# Access: https://certbot.eff.org/instructions?ws=other&os=ubuntufocal
SSL_CONF:
PRIVKEY: /etc/letsencrypt/live/<domain>/privkey.pem
FULLCHAIN: /etc/letsencrypt/live/<domain>/fullchain.pem
# Determine the logs to be displayed
LOG:
LEVEL:
- ERROR
- WARN
- DEBUG
- INFO
- LOG
- VERBOSE
- DARK
- WEBHOOKS
COLOR: true
BAILEYS: error # fatal | error | warn | info | debug | trace
# Determine how long the instance should be deleted from memory in case of no connection.
# Default time: 5 minutes
# If you don't even want an expiration, enter the value false
DEL_INSTANCE: false # or false
# Temporary data storage
STORE:
MESSAGES: true
MESSAGE_UP: true
CONTACTS: true
CHATS: true
CLEAN_STORE:
CLEANING_INTERVAL: 7200 # 7200 seconds === 2h
MESSAGES: true
MESSAGE_UP: true
CONTACTS: true
CHATS: true
# Permanent data storage
DATABASE:
ENABLED: false
CONNECTION:
URI: "mongodb://root:root@localhost:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true"
DB_PREFIX_NAME: evolution
# Choose the data you want to save in the application's database or store
SAVE_DATA:
INSTANCE: false
NEW_MESSAGE: false
MESSAGE_UPDATE: false
CONTACTS: false
CHATS: false
REDIS:
ENABLED: false
URI: "redis://localhost:6379"
PREFIX_KEY: "evolution"
RABBITMQ:
ENABLED: false
URI: "amqp://guest:guest@localhost:5672"
WEBSOCKET:
ENABLED: false
# Global Webhook Settings
# Each instance's Webhook URL and events will be requested at the time it is created
WEBHOOK:
# Define a global webhook that will listen for enabled events from all instances
GLOBAL:
URL: <url>
ENABLED: false
# With this option activated, you work with a url per webhook event, respecting the global url and the name of each event
WEBHOOK_BY_EVENTS: false
# Automatically maps webhook paths
# Set the events you want to hear
EVENTS:
APPLICATION_STARTUP: false
QRCODE_UPDATED: true
MESSAGES_SET: true
MESSAGES_UPSERT: true
MESSAGES_UPDATE: true
MESSAGES_DELETE: true
SEND_MESSAGE: true
CONTACTS_SET: true
CONTACTS_UPSERT: true
CONTACTS_UPDATE: true
PRESENCE_UPDATE: true
CHATS_SET: true
CHATS_UPSERT: true
CHATS_UPDATE: true
CHATS_DELETE: true
GROUPS_UPSERT: true
GROUP_UPDATE: true
GROUP_PARTICIPANTS_UPDATE: true
CONNECTION_UPDATE: true
CALL: true
# This event fires every time a new token is requested via the refresh route
NEW_JWT_TOKEN: false
CONFIG_SESSION_PHONE:
# Name that will be displayed on smartphone connection
CLIENT: "$client"
NAME: chrome # chrome | firefox | edge | opera | safari
# Set qrcode display limit
QRCODE:
LIMIT: 30
COLOR: '#198754'
# Defines an authentication type for the api
# We recommend using the apikey because it will allow you to use a custom token,
# if you use jwt, a random token will be generated and may be expired and you will have to generate a new token
AUTHENTICATION:
TYPE: apikey # jwt or apikey
# Define a global apikey to access all instances
API_KEY:
# OBS: This key must be inserted in the request header to create an instance.
KEY: $keyy
# Expose the api key on return from fetch instances
EXPOSE_IN_FETCH_INSTANCES: true
# Set the secret key to encrypt and decrypt your token and its expiration time.
JWT:
EXPIRIN_IN: 0 # seconds - 3600s === 1h | zero (0) - never expires
SECRET: L=6544120E713976
EOL
#######################################################
sudo mv env.yml evolution-api/src/env.yml
cd
cd evolution-api
npm install
echo "Iniciando pm2"
pm2 start 'npm run start:prod' --name ApiEvolution
pm2 startup
pm2 save --force
#######################################################
clear
cd
cd
echo "Proxy Reverso"
cat > api << EOL
server {
server_name $dominio;
location / {
proxy_pass http://127.0.0.1:$porta;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_cache_bypass \$http_upgrade;
}
}
EOL
#######################################################
clear
cd
sudo mv api /etc/nginx/sites-available/api
ln -s /etc/nginx/sites-available/api /etc/nginx/sites-enabled
systemctl reload nginx
###############
###############
###############
echo "Instalando Typebot"
echo "Criando arquivo docker-compose.yml"
sleep 3
cat > docker-compose.yml << EOL
version: '3.3'
services:
typebot-db:
image: postgres:13
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=typebot
- POSTGRES_PASSWORD=typebot
typebot-builder:
ports:
- $portabuilder:3000
image: baptistearno/typebot-builder:main
restart: always
depends_on:
- typebot-db
environment:
- DATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot
- NEXTAUTH_URL=https://$builder
- NEXT_PUBLIC_VIEWER_URL=https://$viewer
- ENCRYPTION_SECRET=$key
- ADMIN_EMAIL=$email
- SMTP_SECURE=$SECURE
- SMTP_HOST=$smtp
- SMTP_PORT=$portasmtp
- SMTP_USERNAME=$email
- SMTP_PASSWORD=$senha
- NEXT_PUBLIC_SMTP_FROM='Suporte Typebot' <$email>
- S3_ACCESS_KEY=minio
- S3_SECRET_KEY=minio123
- S3_BUCKET=typebot
- S3_ENDPOINT=$storage
typebot-viewer:
ports:
- $portaviewer:3000
image: baptistearno/typebot-viewer:main
restart: always
environment:
- DATABASE_URL=postgresql://postgres:typebot@typebot-db:5432/typebot
- NEXT_PUBLIC_VIEWER_URL=https://$viewer
- ENCRYPTION_SECRET=$key
- S3_ACCESS_KEY=minio
- S3_SECRET_KEY=minio123
- S3_BUCKET=typebot
- S3_ENDPOINT=$storage
mail:
image: bytemark/smtp
restart: always
minio:
labels:
virtual.host: '$storage'
virtual.port: '$portastorage'
virtual.tls-email: '$email'
image: minio/minio
command: server /data
ports:
- '$portastorage:$portastorage'
environment:
MINIO_ROOT_USER: minio
MINIO_ROOT_PASSWORD: minio123
volumes:
- s3_data:/data
createbuckets:
image: minio/mc
depends_on:
- minio
entrypoint: >
/bin/sh -c "
sleep 10;
/usr/bin/mc config host add minio http://minio:$portastorage minio minio123;
/usr/bin/mc mb minio/typebot;
/usr/bin/mc anonymous set public minio/typebot/public;
exit 0;
"
volumes:
db_data:
s3_data:
EOL
echo "Criado e configurado com sucesso"
sleep 3
clear
###############################################
echo "Iniciando Conteiner"
sleep 3
docker-compose up -d
echo "Typebot Instaldo... Realizando Proxy Reverso"
sleep 3
clear
###############################################
cd
cat > typebot << EOL
server {
server_name $builder;
location / {
proxy_pass http://127.0.0.1:$portabuilder;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_cache_bypass \$http_upgrade;
}
}
EOL
###############################################
sudo mv typebot /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/typebot /etc/nginx/sites-enabled
###############################################
cd
cat > bot << EOL
server {
server_name $viewer;
location / {
proxy_pass http://127.0.0.1:$portaviewer;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_cache_bypass \$http_upgrade;
}
}
EOL
###############################################
sudo mv bot /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/bot /etc/nginx/sites-enabled
##################################################
cd
cat > storage << EOL
server {
server_name $storage;
location / {
proxy_pass http://127.0.0.1:$portastorage;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_cache_bypass \$http_upgrade;
}
}
EOL
###############################################
sudo mv storage /etc/nginx/sites-available/
sudo ln -s /etc/nginx/sites-available/storage /etc/nginx/sites-enabled
#######################################################
echo "proxy reverso da Evolution e do typebot"
sudo certbot --nginx --email $email --redirect --agree-tos -d $dominio -d $builder -d $viewer -d $storage
#######################################################
cd
cd
cd
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m _ _ _ \e[0m"
echo -e "\e[32m| | _ | | | | \e[0m"
echo -e "\e[32m| | ____ ___ _| |_ _____ | | _____ __| | ___ \e[0m"
echo -e "\e[32m| || _ \ /___)(_ _)(____ || | (____ | / _ | / _ \ \e[0m"
echo -e "\e[32m| || | | ||___ | | |_ / ___ || | / ___ |( (_| || |_| |\e[0m"
echo -e "\e[32m|_||_| |_|(___/ \__)\_____| \_)\_____| \____| \___/ \e[0m"
echo -e "\e[32m \e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32mAcesse a Evolution API através do link: https://$dominio\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32mAcesse o Builder do Tyoebot através do link: https://$builder\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32mInscreva-se no meu Canal: https://youtube.com/oriondesign_oficial\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32mSugestões ou duvidas: https://wa.me/+5511973052593\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"
echo -e "\e[32m\e[0m"