#!/bin/bash # === COMPROBACIÓN DE ROOT === 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 1 fi # === ENTORNO GLOBAL === export HOME=/root export DEBIAN_FRONTEND=noninteractive export PYTHONWARNINGS="ignore" set -e # === ACTUALIZAR SISTEMA === apt-get update #apt-get -y full-upgrade # Autoremove si es necesario if apt-get --dry-run autoremove | grep -q "The following packages will be REMOVED:"; then echo "Ejecutando autoremove..." apt-get -y autoremove else echo "No es necesario ejecutar autoremove." fi # === INSTALAR PAQUETES NECESARIOS === 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 ffmpeg php-sqlite3" 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..." 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..." fi else echo "$app ya está instalado." fi } for app in $apps; do check_and_install "$app" done # === INSTALACIÓN DE MÓDULOS PYTHON === PACKAGES="pyOpenSSL requests autobahn jinja2 dmr-utils3 ansi2html aprslib tinydb mysqlclient setproctitle pynmea2 maidenhead spyne \ Pyro5 bitstring bitarray dmr_utils3 configparser resettabletimer setuptools wheel MarkupSafe==2.1.3 service-identity gTTS" PIP_BASE_CMD="/usr/bin/python3 -m pip install --no-input --root-user-action=ignore --disable-pip-version-check" PIP_BASE_CMD2="/usr/bin/python3 -m pip install --upgrade --no-input --disable-pip-version-check" if grep -q "VERSION_ID=\"1[3]\"" /etc/os-release; then version=$(grep 'VERSION_ID=' /etc/os-release | cut -d '"' -f 2) echo "Detected Debian $version" # Para Debian 13: Instalar TODOS los paquetes EXCEPTO requests sudo $PIP_BASE_CMD --break-system-packages ${PACKAGES//requests/} || true # Twisted se usa de repositorio en Debian 13 sudo $PIP_BASE_CMD --break-system-packages "Twisted>=23.10.0" || true sudo $PIP_BASE_CMD --break-system-packages "autobahn" || true fi if grep -q "VERSION_ID=\"1[2]\"" /etc/os-release; then version=$(grep 'VERSION_ID=' /etc/os-release | cut -d '"' -f 2) echo "Detected Debian $version" sudo $PIP_BASE_CMD --break-system-packages $PACKAGES || true # Para Debian 12: Reforzar instalación de requests # Forzar reinstalación de Twisted específico sudo $PIP_BASE_CMD --break-system-packages "Twisted==22.10.0" || true sudo $PIP_BASE_CMD --break-system-packages "autobahn" || true fi if ! grep -q "VERSION_ID=\"1[23]\"" /etc/os-release; then version=$(grep 'VERSION_ID=' /etc/os-release | cut -d '"' -f 2) echo "Detected Debian $version" sudo $PIP_BASE_CMD2 $PACKAGES || true # Para otros sistemas: Reforzar instalación de requests sudo $PIP_BASE_CMD2 "Twisted==22.10.0" || true sudo $PIP_BASE_CMD2 "autobahn" || true fi echo "✅ Instalación de módulos Python completada." # === CONFIGURACIÓN DE SISTEMA === timedatectl set-timezone America/Panama ####### bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/swappoff.sh)" || true bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/rpiswap.sh)" || true bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/nginx.sh)" || true bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/php74.sh)" || true bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/php8.sh)" || true bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/fdmr/-/raw/main/install.sh)" || true (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