Update easy-fdmr.sh

main
hp3icc 2 months ago
parent 74017e91e8
commit 9f1092864a

@ -1,127 +1,98 @@
#!/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 0
exit 1
fi
# Actualizar la lista de paquetes una vez al principio
apt-get update
# === ENTORNO GLOBAL ===
export HOME=/root
export DEBIAN_FRONTEND=noninteractive
export PYTHONWARNINGS="ignore"
set -e
# Ejecutar actualización completa
#DEBIAN_FRONTEND=noninteractive apt-get full-upgrade -y
# === ACTUALIZAR SISTEMA ===
apt-get update
apt-get -y full-upgrade
# Verificar si es necesario ejecutar autoremove
# Autoremove si es necesario
if apt-get --dry-run autoremove | grep -q "The following packages will be REMOVED:"; then
echo "Ejecutando autoremove..."
apt-get autoremove -y
apt-get -y autoremove
else
echo "No es necesario ejecutar autoremove."
fi
# Lista de aplicaciones para verificar e instalar
# === 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 \
php-sqlite3"
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"
# 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
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
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..."
echo "No se pudo instalar $app. Continuando..."
fi
else
echo "$app ya está instalado."
fi
}
# Verificar e instalar cada aplicación
for app in $apps; do
check_and_install $app
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
# === CREAR ENTORNO VIRTUAL PYTHON ===
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
python3 -m ensurepip --upgrade || wget -qO- https://bootstrap.pypa.io/get-pip.py | python3
pip install --no-input --upgrade pip setuptools wheel
deactivate
# Detectar el sistema operativo y su versión
# === DETECTAR SISTEMA OPERATIVO ===
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
OS="unknown"
VERSION="0"
CODENAME=""
fi
echo "Detectado: OS=$OS, VERSION=$VERSION, CODENAME=$CODENAME"
# 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
# === INSTALACIÓN DE MÓDULOS PYTHON ===
PACKAGES="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 gTTS"
# 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" ]
}
}
PIP_BASE_CMD="/usr/bin/python3 -m pip install --no-input --root-user-action=ignore --disable-pip-version-check"
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
if [ "$OS" == "debian" ] && { [ "$VERSION" == "12" ] || [ "$VERSION" == "13" ] || [ "$CODENAME" == "trixie" ]; }; then
echo "Usando instalación con --break-system-packages (Debian $VERSION)"
$PIP_BASE_CMD --upgrade --break-system-packages $PACKAGES || true
# Instalar requests sin desinstalar la versión de apt
$PIP_BASE_CMD --upgrade --break-system-packages --ignore-installed requests || true
# Forzar reinstalación de Twisted específico
$PIP_BASE_CMD --break-system-packages --force-reinstall "Twisted==22.10.0" || true
else
echo "Usando instalación estándar (no Debian 12/13)"
$PIP_BASE_CMD --upgrade $PACKAGES || true
$PIP_BASE_CMD --upgrade --ignore-installed requests || true
$PIP_BASE_CMD --force-reinstall "Twisted==22.10.0" || true
fi
echo "Instalación completa."
echo "Instalación de módulos Python completada."
# Configuración adicional (timezone, cron, etc.)
sudo timedatectl set-timezone America/Panama
# === CONFIGURACIÓN DE SISTEMA ===
timedatectl set-timezone America/Panama
#######
bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/rpiswap.sh)" &&

Loading…
Cancel
Save

Powered by TurnKey Linux.