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
|
|
|
|
2022-03-15 17:56:47 +00:00
|
|
|
if [ $UID -ne 0 ]; then
|
|
|
|
echo "Ejecute 'sudo $0'"
|
|
|
|
exit
|
|
|
|
fi
|
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
|
|
|
|
|
2022-03-03 22:13:00 +00:00
|
|
|
source $configuracion
|
2022-03-15 17:56:47 +00:00
|
|
|
source $envs
|
2022-03-03 22:13:00 +00:00
|
|
|
|
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-17 22:39:06 +00:00
|
|
|
ficheros="bin envs arduinos.py generador_json funciones registrador desinstalar"
|
2022-03-03 22:13:00 +00:00
|
|
|
|
|
|
|
# Dependencias
|
|
|
|
|
|
|
|
echo "1. Instalando dependencias
|
|
|
|
"
|
2022-05-19 16:05:11 +00:00
|
|
|
apt update && apt install -y python3-pip jsonlint jq uuid
|
|
|
|
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
|
|
|
|
"
|
2022-03-21 20:36:12 +00:00
|
|
|
mkdir -vp $registros_corruptos
|
2022-03-03 22:13:00 +00:00
|
|
|
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
|
|
|
|
2022-03-15 17:56:47 +00:00
|
|
|
sed -i 's/numero_serie=/numero_serie='$sn'/' $directorio_instalacion/envs
|
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
|
|
|
"
|