emq-TE1/install/allmon3.sh

158 lines
4.9 KiB
Bash

#!/bin/bash
SCRIPT_NAME="allmon3.sh"
# Registra el inicio en /opt/curl.txt
echo "Inicio: $SCRIPT_NAME" >> /opt/curl.txt
if systemctl is-active "apache2" >/dev/null 2>&1; then
sapache=1
else
sapache=0
fi
if [ ! -d "/etc/allmon3" ]; then
samllm3=1
gpg --keyserver keyserver.ubuntu.com --recv-keys 0E98404D386FA1D9
gpg --keyserver keyserver.ubuntu.com --recv-keys 6ED0E7B82643E131
gpg --export 0E98404D386FA1D9 | sudo apt-key add -
gpg --export 6ED0E7B82643E131 | sudo apt-key add -
echo "deb https://deb.debian.org/debian bullseye-backports main" > /etc/apt/sources.list.d/bullseye-backports.list
apt-get update
# Install the dependencies
VERSION=$(sed 's/\..*//' /etc/debian_version)
if [ $VERSION = 10 ]
then
apt-get remove python3-aiohttp python3-websockets -y
pip3 install aiohttp
pip3 install aiohttp_session
pip3 install websockets
elif [ $VERSION = 11 ]
then
apt-get install -y apache2 python3-argon2
apt-get install -y -t bullseye-backports python3-websockets python3-aiohttp python3-aiohttp-session
fi
#### Install Allmon3
wget https://github.com/AllStarLink/Allmon3/releases/download/rel_t_1_0_2/allmon3_1.0.2-1_all.deb
dpkg -i allmon3_1.0.2-1_all.deb
else
samllm3=0
fi
if [ -d "/etc/allmon3" ]; then
cat > "/etc/allmon3/allmon3.ini" <<- "EOFX"
;
; This is the master configuration file for all ASL/Asterisks node-related
; information. It is used for all server daemon processes
; (e.g. asl-statmon, asl-cmdlink) and the web interface/API.
;
; Each configuration item below is marked (R) or (O) for required or optional
; repsectively along with usage notes. The value in the table below is the
; default value for optiional items or examples for required items.
;
; [1999]
; host = 192.0.2.0 # (R) DNS name or IP address of the Asterisk/ASL node
;
; port = 5038 # (O) port of the Asterisk manager
;
; user = admin # (R) username of the Asterisk monitor, most
; # commonly 'admin'
;
; pass = password # (R) password of the monitor user
;
; multinodes = # (O) this node is a server hosting multiple nodes
; # and this is the "primary" record for the host.
;
; voters = n[,n,...] # (O) List voters on this server, comma
; # separate. No value disabled voters
;
; pollinterval = 1 # (O) polling interval to asterisk in seconds
; # default is 1. this value can be expressed as
; # a decimal fraction of a second - e.g., .5
; # is 500ms, .375 is 375ms, etc.
;
; vpollinterval = 1 # (O) broadcast interval of voter data in seconds
; # default is 1. this value can be expressed as
; # a decimal fraction of a second - e.g., .5
; # is 500ms, .375 is 375ms, etc.
;
; retryinterval = 15 # (O) seconds between retries if initial connection to
; # asterisk is lost (optional, default 15)
;
; retrycount = # (O) number of times to retry a lost asterisk
; # connection before ending (default infinite)
; For a basic installation, you chould be able to uncomment the below,
; change 1999 to your node number and set the pass= as
; set in asterisk/manager.conf
;[1999]
;host=127.0.0.1
;user=admin
;pass=password
[a5a4a3a2a1]
host=127.0.0.1
user=admin
pass=a2b2c2d2e2
EOFX
fi
if [ $samllm3 = 1 ]; then
systemctl disable allmon3
systemctl stop allmon3
fi
if [ $sapache = 1 ]; then
systemctl stop apache2
systemctl start apache2
systemctl enable apache2
else
systemctl stop apache2
systemctl disable apache2
fi
#######################
if [ -d "/etc/nginx/sites-available" ]; then
cat > /etc/nginx/sites-available/allmon3 <<- "EOFX1"
server {
listen wd0p;
location / {
root /usr/share/allmon3; # Ajusta la ruta según tu configuración
index index.html;
autoindex off;
}
location /master/ {
proxy_http_version 1.1;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
proxy_pass http://localhost:16080/;
}
location ~ ^/ws/([0-9]+)$ {
set $port $1;
proxy_pass http://127.0.0.1:$port/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
# Otras configuraciones según sea necesario...
}
EOFX1
fi
echo "Finalizado: $SCRIPT_NAME" >> /opt/curl.txt
#########################################################