2022-03-03 22:13:00 +00:00
|
|
|
#!/bin/bash
|
2022-03-05 18:13:50 +00:00
|
|
|
#set -x
|
2022-03-15 16:29:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
basedir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
|
|
|
|
|
|
configuracion=$basedir/nodemecu.conf.ejemplo
|
|
|
|
envs=$basedir/envs
|
|
|
|
|
|
|
|
|
|
|
|
cat $configuracion
|
|
|
|
cat $envs
|
|
|
|
exit
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-03-03 22:13:00 +00:00
|
|
|
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-15 16:29:08 +00:00
|
|
|
ficheros="bin env arduinos.py contador generador_json funciones monitor monitor_web 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-15 16:29:08 +00:00
|
|
|
mkdir -v $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
|
|
|
|
"
|
|
|
|
|
2022-03-15 16:29:08 +00:00
|
|
|
cp -v nodemecu.service /lib/systemd/system/
|
2022-03-03 22:13:00 +00:00
|
|
|
systemctl daemon-reload
|
|
|
|
|
2022-03-14 18:50:41 +00:00
|
|
|
echo "
|
|
|
|
4. Obteniendo numero de serie
|
|
|
|
"
|
|
|
|
|
|
|
|
sn=$(cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2)
|
2022-03-15 16:29:08 +00:00
|
|
|
|
|
|
|
sed -i 's/numero_serie=/numero_serie/' $env
|
2022-03-14 18:50:41 +00:00
|
|
|
|
|
|
|
echo "Número de serie: $sn"
|
|
|
|
|
|
|
|
|
2022-03-03 22:13:00 +00:00
|
|
|
|
2022-03-05 20:09:45 +00:00
|
|
|
echo "
|
2022-03-14 18:50:41 +00:00
|
|
|
5. Configurar
|
2022-03-05 20:09:45 +00:00
|
|
|
"
|
2022-03-03 22:13:00 +00:00
|
|
|
|
2022-03-11 18:24:03 +00:00
|
|
|
echo "- Ejecute 'sudo nodemecu configurar' para comenzar.
|
|
|
|
"
|
2022-03-14 18:50:41 +00:00
|
|
|
echo "- Ejecute 'sudo nodemecu modo sensores' para obtener datos desde sensores.
|
2022-03-11 18:24:03 +00:00
|
|
|
"
|
|
|
|
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
|
|
|
"
|