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 00:57:16 +00:00
|
|
|
ficheros="bin arduinos.py contador generador_json funciones monitor monitor_web nodemecu.conf.ejemplo nodemecu.service registrador desinstalar"
|
2022-03-03 22:13:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Dependencias
|
|
|
|
|
|
|
|
echo "1. Instalando dependencias
|
|
|
|
"
|
|
|
|
#pip install pyserial
|
|
|
|
#apt update && apt install -y jsonlint
|
|
|
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
systemctl enable nodemecu.service
|
|
|
|
systemctl start nodemecu.service
|
|
|
|
systemctl status nodemecu.service
|
|
|
|
|
|
|
|
|
2022-03-05 20:09:45 +00:00
|
|
|
echo "
|
|
|
|
4. Configurar
|
|
|
|
"
|
2022-03-03 22:13:00 +00:00
|
|
|
|
2022-03-05 20:09:45 +00:00
|
|
|
echo "Ejecute 'sudo nodemecu configurar' para comenzar.
|
|
|
|
"
|