mirror of https://gitlab.com/hp3icc/fdmr.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
177 lines
6.3 KiB
177 lines
6.3 KiB
#!/bin/bash
|
|
|
|
if [ $EUID -ne 0 ]; then
|
|
whiptail --title "sudo su" --msgbox "requiere ser usuario root , escriba (sudo su) antes de entrar a menu / requires root user, type (sudo su) before entering menu" 0 50
|
|
exit 0
|
|
fi
|
|
|
|
# Actualizar la lista de paquetes una vez al principio
|
|
apt-get update
|
|
|
|
# Ejecutar actualización completa
|
|
#DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y
|
|
|
|
# Verificar si es necesario ejecutar autoremove
|
|
if apt-get --dry-run autoremove | grep -q "The following packages will be REMOVED:"; then
|
|
echo "Ejecutando autoremove..."
|
|
apt-get autoremove -y
|
|
else
|
|
echo "No es necesario ejecutar autoremove."
|
|
fi
|
|
|
|
# Lista de aplicaciones para verificar e instalar
|
|
apps="sudo curl git make build-essential libusb-1.0-0-dev python3 python3-pip libi2c-dev i2c-tools lm-sensors wget \
|
|
python3-dev python3-venv libffi-dev libssl-dev cargo pkg-config sed libmariadb-dev zip unzip rrdtool openssl \
|
|
wavemon gcc g++ cmake libasound2-dev libudev-dev gpsd libgps-dev gpsd-clients gpsd-tools chrony libsamplerate0-dev \
|
|
php-sqlite3"
|
|
|
|
# Función para verificar e instalar una aplicación
|
|
check_and_install() {
|
|
app=$1
|
|
if ! dpkg -s $app 2>/dev/null | grep -q "Status: install ok installed"; then
|
|
echo "$app no está instalado. Instalando..."
|
|
DEBIAN_FRONTEND=noninteractive apt-get install -y $app || true
|
|
if dpkg -s $app 2>/dev/null | grep -q "Status: install ok installed"; then
|
|
echo "$app instalado correctamente."
|
|
else
|
|
echo "No se pudo instalar $app. Continuando con la siguiente aplicación..."
|
|
fi
|
|
else
|
|
echo "$app ya está instalado."
|
|
fi
|
|
}
|
|
|
|
# Verificar e instalar cada aplicación
|
|
for app in $apps; do
|
|
check_and_install $app
|
|
done
|
|
|
|
# Verificar y actualizar python3-venv si no está instalado
|
|
if ! dpkg -s python3-venv >/dev/null 2>&1; then
|
|
echo "python3-venv no está instalado. Instalando..."
|
|
apt-get install python3-venv -y
|
|
echo "python3-venv instalado correctamente."
|
|
fi
|
|
|
|
# Crear y activar un entorno virtual
|
|
cd /opt/
|
|
python3 -m venv myenv
|
|
source myenv/bin/activate
|
|
|
|
# Crear y activar un entorno virtual
|
|
cd /opt/
|
|
python3 -m venv myenv
|
|
source myenv/bin/activate
|
|
|
|
# Instalar pip en el entorno virtual
|
|
if [ -f "/opt/get-pip.py" ]; then
|
|
rm /opt/get-pip.*
|
|
fi
|
|
wget https://bootstrap.pypa.io/pip/get-pip.py
|
|
python3 get-pip.py
|
|
rm get-pip.*
|
|
|
|
# Instalar paquetes en el entorno virtual
|
|
apt-get install -y libssl-dev
|
|
|
|
# Desactivar el entorno virtual
|
|
deactivate
|
|
# Detectar el sistema operativo y su versión
|
|
if [ -f "/etc/os-release" ]; then
|
|
. /etc/os-release
|
|
OS=$ID
|
|
VERSION=$VERSION_ID
|
|
CODENAME=$VERSION_CODENAME
|
|
else
|
|
echo "No se pudo detectar el sistema operativo."
|
|
exit 1
|
|
fi
|
|
|
|
# Instalación de módulos pip según el sistema operativo
|
|
if [ "$OS" == "debian" ] && { [ "$VERSION" == "12" ] || [ "$VERSION" == "13" ] || [ "$CODENAME" == "trixie" ]; }; then
|
|
/usr/bin/python3 -m pip install --break-system-packages Twisted pyOpenSSL autobahn jinja2 dmr-utils3 ansi2html aprslib tinydb mysqlclient setproctitle pynmea2 maidenhead spyne \
|
|
Pyro5 bitstring bitarray dmr_utils3 configparser resettabletimer setuptools wheel MarkupSafe service-identity
|
|
source myenv/bin/activate
|
|
/usr/bin/python3 -m pip uninstall --break-system-packages Twisted -y
|
|
/usr/bin/python3 -m pip install --break-system-packages Twisted==22.10.
|
|
deactivate
|
|
else
|
|
/usr/bin/python3 -m pip install --upgrade Twisted pyOpenSSL autobahn jinja2 dmr-utils3 ansi2html aprslib tinydb mysqlclient setproctitle pynmea2 maidenhead spyne \
|
|
Pyro5 bitstring bitarray dmr_utils3 configparser resettabletimer setuptools wheel MarkupSafe service-identity
|
|
sudo pip3 uninstall -y Twisted --quiet
|
|
pip install Twisted==22.10.0
|
|
fi
|
|
|
|
# Función para verificar si Rust 1.72.0 o superior está instalado
|
|
is_rust_installed() {
|
|
command -v rustc &>/dev/null && {
|
|
installed_version=$(rustc --version | awk '{print $2}')
|
|
required_version="1.72.0"
|
|
[ "$(printf '%s\n' "$required_version" "$installed_version" | sort -V | head -n1)" = "$required_version" ]
|
|
}
|
|
}
|
|
|
|
if ! is_rust_installed; then
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
|
source $HOME/.cargo/env
|
|
rustup install 1.72.0
|
|
rustup default 1.72.0
|
|
fi
|
|
|
|
echo "Instalación completa."
|
|
|
|
# Configuración adicional (timezone, cron, etc.)
|
|
sudo timedatectl set-timezone America/Panama
|
|
|
|
#######
|
|
bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/rpiswap.sh)" &&
|
|
bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/nginx.sh)" &&
|
|
bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/fdmr/-/raw/main/install.sh)"
|
|
|
|
(crontab -l | grep -v "rm /opt/FDMR-Monitor2/data/*") | crontab -
|
|
(crontab -l | grep -v "rm /opt/FDMR-Monitor/data/*") | crontab -
|
|
(crontab -l | grep -v "/opt/FDMR-Monitor/sysinfo/cpu.sh") | crontab -
|
|
(crontab -l | grep -v "/opt/FDMR-Monitor/sysinfo/graph.sh") | crontab -
|
|
sudo systemctl stop mariadb.service 2>/dev/null || true
|
|
sudo systemctl stop proxy.service 2>/dev/null || true
|
|
sudo systemctl stop fdmr_mon.service 2>/dev/null || true
|
|
sudo systemctl stop fdmr_mon2.service 2>/dev/null || true
|
|
sudo systemctl disable fdmr_mon2.service 2>/dev/null || true
|
|
sudo systemctl disable fdmr_mon.service 2>/dev/null || true
|
|
sudo systemctl disable proxy.service 2>/dev/null || true
|
|
sudo systemctl disable mariadb.service 2>/dev/null || true
|
|
|
|
if [ "$(ls -A "/opt/ADN-DMR-Peer-Server/data/")" ]; then
|
|
rm -rf "/opt/ADN-DMR-Peer-Server/data/"* >/dev/null 2>&1
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/defauld" ]; then
|
|
rm /etc/nginx/sites-enabled/defauld
|
|
fi
|
|
if [ -f "/etc/nginx/sites-enabled/000" ]; then
|
|
rm /etc/nginx/sites-enabled/000
|
|
fi
|
|
|
|
sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/adn
|
|
|
|
sed -i "s|wsn0|adn|g" /etc/nginx/sites-enabled/adn
|
|
sed -i "s|wd0p|80|g" /etc/nginx/sites-enabled/adn
|
|
sed -i "s|w0d0|/opt/adn-dashboard/html|g" /etc/nginx/sites-enabled/adn
|
|
|
|
# Iniciar y habilitar
|
|
servicios="proxy2.service adn-parrot.service adn-server.service fdmr_mon3.service"
|
|
|
|
# Luego, iniciar todos los servicios
|
|
for servicio in $servicios; do
|
|
echo "Iniciando $servicio"
|
|
sudo systemctl start "$servicio" 2>/dev/null || true
|
|
sudo systemctl enable "$servicio" 2>/dev/null || true
|
|
done
|
|
|
|
sudo systemctl restart nginx
|
|
menu-adn
|
|
|
|
|
|
|
|
|
|
|