@ -1,39 +1,62 @@
#!/bin/bash
# Verificar si el usuario tiene permisos de root
if [ [ $EUID -ne 0 ] ] ; then
echo "Este script debe ejecutarse como usuario 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
fi
# Detectar el sistema operativo y su versión
if [ -f "/etc/os-release" ] ; then
. /etc/os-release
OS = $ID
VERSION = $VERSION_ID
else
echo "No se pudo detectar el sistema operativo."
exit 1
fi
# Actualizar la lista de paquetes una vez al principio
apt-get update
DEBIAN_FRONTEND = noninteractive apt-get upgrade -y
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" "python" "python3" "python3-pip" "chkconfig" "git-core" "libi2c-dev" "i2c-tools" "lm-sensors" "python3-websockets" "python3-gpiozero" "python3-psutil" "python3-serial" "wget" "sudo" "python3-dev" "python3-venv" "libffi-dev" "libssl-dev" "cargo" "pkg-config" "sed" "default-libmysqlclient-dev" "libmysqlclient-dev" "build-essential" "zip" "unzip" "python3-distutils" "python3-twisted" "python3-bitarray" "rrdtool" "openssl" "wavemon" "gcc" "g++" "cmake" "libasound2-dev" "libudev-dev" "gpsd" "libgps-dev" "gpsd-clients" "gpsd-tools" "chrony" )
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"
# 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... "
apt-get install -y $app
echo " $app instalado correctamente. "
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
for app in $ apps; do
check_and_install $app
done
bash -c " $( curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/ipv6off.sh) " &&
# 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..."
sudo DEBIAN_FRONTEND = noninteractive apt-get install -y python3-venv
apt-get install python3-venv -y
echo "python3-venv instalado correctamente."
fi
@ -43,9 +66,8 @@ 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.*
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
@ -60,9 +82,6 @@ python3 -m pip install cryptography Twisted bitstring MarkupSafe bitarray config
# Desactivar el entorno virtual
deactivate
#pip install cryptography pyopenssl autobahn Twisted bitstring MarkupSafe bitarray configparser aprslib attrs wheel service_identity pyOpenSSL mysqlclient tinydb ansi2html mysql-connector-python pandas xlsxwriter cursor pynmea2 maidenhead flask folium mysql-connector resettabletimer setproctitle requests libscrc Pyro5
cd /opt
# Instalar Rust y configurar versión
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME /.cargo/env
@ -70,63 +89,41 @@ source $HOME/.cargo/env
rustup install 1.72.0
rustup default 1.72.0
if [ -f "/etc/os-release" ] ; then
source /etc/os-release
if [ " $VERSION_ID " = = "12" ] ; then
/usr/bin/python3 -m pip install --break-system-packages pyOpenSSL
/usr/bin/python3 -m pip install --break-system-packages autobahn
/usr/bin/python3 -m pip install --break-system-packages jinja2
/usr/bin/python3 -m pip install --break-system-packages dmr-utils3
/usr/bin/python3 -m pip install --break-system-packages ansi2html
/usr/bin/python3 -m pip install --break-system-packages aprslib
/usr/bin/python3 -m pip install --break-system-packages tinydb
/usr/bin/python3 -m pip install --break-system-packages mysqlclient
/usr/bin/python3 -m pip install --break-system-packages setproctitle
/usr/bin/python3 -m pip install --break-system-packages pynmea2
/usr/bin/python3 -m pip install --break-system-packages maidenhead
/usr/bin/python3 -m pip install --break-system-packages Twisted
/usr/bin/python3 -m pip install --break-system-packages spyne
/usr/bin/python3 -m pip install --break-system-packages Pyro5
/usr/bin/python3 -m pip install --break-system-packages bitstring
/usr/bin/python3 -m pip install --break-system-packages bitarray
/usr/bin/python3 -m pip install --break-system-packages dmr_utils3
/usr/bin/python3 -m pip install --break-system-packages configparser
/usr/bin/python3 -m pip install --break-system-packages resettabletimer
/usr/bin/python3 -m pip install --break-system-packages setuptools
/usr/bin/python3 -m pip install --break-system-packages wheel
/usr/bin/python3 -m pip install --break-system-packages MarkupSafe
/usr/bin/python3 -m pip install --break-system-packages service-identity
else
/usr/bin/python3 -m pip install --upgrade pyOpenSSL
/usr/bin/python3 -m pip install --upgrade autobahn
/usr/bin/python3 -m pip install --upgrade jinja2
/usr/bin/python3 -m pip install --upgrade dmr-utils3
/usr/bin/python3 -m pip install --upgrade ansi2html
/usr/bin/python3 -m pip install --upgrade aprslib
/usr/bin/python3 -m pip install --upgrade tinydb
/usr/bin/python3 -m pip install --upgrade mysqlclient
/usr/bin/python3 -m pip install --upgrade setproctitle
/usr/bin/python3 -m pip install --upgrade pynmea2
/usr/bin/python3 -m pip install --upgrade maidenhead
/usr/bin/python3 -m pip install --upgrade Twisted
/usr/bin/python3 -m pip install --upgrade spyne
/usr/bin/python3 -m pip install --upgrade Pyro5
/usr/bin/python3 -m pip install --upgrade bitstring
/usr/bin/python3 -m pip install --upgrade bitarray
/usr/bin/python3 -m pip install --upgrade dmr_utils3
/usr/bin/python3 -m pip install --upgrade configparser
/usr/bin/python3 -m pip install --upgrade resettabletimer
/usr/bin/python3 -m pip install --upgrade setuptools
/usr/bin/python3 -m pip install --upgrade wheel
/usr/bin/python3 -m pip install --upgrade MarkupSafe
/usr/bin/python3 -m pip install --upgrade service-identity
fi
# Instalación de módulos pip según el sistema operativo
if [ " $OS " = = "debian" ] && [ " $VERSION " = = "12" ] ; then
/usr/bin/python3 -m pip install --break-system-packages pyOpenSSL autobahn jinja2 dmr-utils3 ansi2html aprslib tinydb mysqlclient setproctitle pynmea2 maidenhead Twisted spyne Pyro5 bitstring bitarray dmr_utils3 configparser resettabletimer setuptools wheel MarkupSafe service-identity
else
/usr/bin/python3 -m pip install --upgrade pyOpenSSL autobahn jinja2 dmr-utils3 ansi2html aprslib tinydb mysqlclient setproctitle pynmea2 maidenhead Twisted spyne Pyro5 bitstring bitarray dmr_utils3 configparser resettabletimer setuptools wheel MarkupSafe service-identity
fi
sudo pip3 uninstall -y twisted --quiet
sudo pip3 install twisted --quiet
echo "Instalación completa."
# Configuración adicional (timezone, cron, etc.)
sudo timedatectl set-timezone America/Panama
# Crear script para editar cronjobs
cat > /usr/local/bin/cronedit.sh <<- "EOF"
cronjob_editor ( ) {
# usage: cronjob_editor '<interval>' '<command>' <add|remove>
if [ [ -z " $1 " ] ] ; then printf " no interval specified\n" ; fi
if [ [ -z " $2 " ] ] ; then printf " no command specified\n" ; fi
if [ [ -z " $3 " ] ] ; then printf " no action specified\n" ; fi
if [ [ " $3 " = = add ] ] ; then
# add cronjob, no duplication:
( sudo crontab -l | grep -v -F -w " $2 " ; echo " $1 $2 " ) | sudo crontab -
elif [ [ " $3 " = = remove ] ] ; then
# remove cronjob:
( sudo crontab -l | grep -v -F -w " $2 " ) | sudo crontab -
fi
}
cronjob_editor " $1 " " $2 " " $3 "
EOF
sudo chmod +x /usr/local/bin/cronedit.sh
#######
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) " &&