2022-03-03 22:13:00 +00:00
|
|
|
#!/bin/bash
|
2022-03-05 18:13:50 +00:00
|
|
|
#set -x
|
2022-03-03 22:13:00 +00:00
|
|
|
configuracion=nodemecu.conf.ejemplo
|
|
|
|
source $configuracion
|
|
|
|
|
|
|
|
if [ $UID -ne 0 ]; then
|
|
|
|
echo "Ejecute 'sudo $0'"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2022-03-05 18:13:50 +00:00
|
|
|
if [ -d $directorio_instalacion ] ; then
|
|
|
|
echo "nodemecu ya se encuentra instalado"
|
|
|
|
exit
|
2022-03-03 22:13:00 +00:00
|
|
|
|
2022-03-05 18:13:50 +00:00
|
|
|
fi
|
2022-03-03 22:13:00 +00:00
|
|
|
|
2022-03-11 18:24:03 +00:00
|
|
|
ficheros="bin arduinos.py contador generador_json funciones monitor monitor_web nodemecu.service registrador desinstalar"
|
2022-03-03 22:13:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Dependencias
|
|
|
|
|
|
|
|
echo "1. Instalando dependencias
|
|
|
|
"
|
2022-03-12 02:33:32 +00:00
|
|
|
apt update && apt install -y python3-pip jsonlint jq uuid
|
2022-03-12 01:54:25 +00:00
|
|
|
pip3 install pyserial
|
2022-03-03 22:13:00 +00:00
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
# Directorio de instalación
|
|
|
|
|
|
|
|
echo "2. Creando directorios y copiando archivos"
|
|
|
|
echo "
|
|
|
|
Creación de directorios
|
|
|
|
"
|
|
|
|
mkdir -vp $directorio_instalacion/archives/historical
|
|
|
|
mkdir -v $directorio_instalacion/archives/logs
|
|
|
|
mkdir -v $registros_corruptos
|
|
|
|
mkdir -v $envios_fallidos
|
|
|
|
mkdir -v $historicos
|
|
|
|
mkdir -v $registros
|
2022-03-11 17:10:48 +00:00
|
|
|
mkdir -v $private_key_dir
|
2022-03-03 22:13:00 +00:00
|
|
|
echo "
|
|
|
|
Copiado de archivos
|
|
|
|
"
|
|
|
|
cp -vr $ficheros $directorio_instalacion
|
|
|
|
cp -v $configuracion /etc/nodemecu.conf
|
|
|
|
echo "
|
|
|
|
Enlaces a binarios
|
|
|
|
"
|
2022-03-05 20:09:45 +00:00
|
|
|
chmod 755 $directorio_instalacion/bin/nodemecu
|
2022-03-03 22:13:00 +00:00
|
|
|
ln -vs $directorio_instalacion/bin/nodemecu /usr/bin/nodemecu
|
|
|
|
echo "
|
|
|
|
Fichero de logs
|
|
|
|
"
|
|
|
|
touch $log
|
|
|
|
ls $log
|
|
|
|
|
|
|
|
|
|
|
|
echo "3. Configurando systemd
|
|
|
|
"
|
|
|
|
|
|
|
|
cp nodemecu.service /lib/systemd/system/
|
|
|
|
systemctl daemon-reload
|
|
|
|
|
|
|
|
|
2022-03-05 20:09:45 +00:00
|
|
|
echo "
|
|
|
|
4. Configurar
|
|
|
|
"
|
2022-03-03 22:13:00 +00:00
|
|
|
|
2022-03-11 18:24:03 +00:00
|
|
|
echo "- Ejecute 'sudo nodemecu configurar' para comenzar.
|
|
|
|
"
|
|
|
|
echo "-Ejecute 'sudo nodemecu modo sensores' para obtener datos desde sensores.
|
|
|
|
"
|
|
|
|
echo "- Ejecute 'sudo nodemecu captura iniciar' para comenzar a tomar datos de sensores o datos de prueba.
|
|
|
|
"
|
|
|
|
echo "- Ejecute 'sudo systemctl start nodemecu.service' para iniciar el envío de datos.
|
2022-03-05 20:09:45 +00:00
|
|
|
"
|