From dd48575a1b0e761c265deeb052c261b34fe0b10d Mon Sep 17 00:00:00 2001 From: f Date: Thu, 3 Mar 2022 14:11:32 -0300 Subject: [PATCH] =?UTF-8?q?no=20hardcodear=20el=20directorio=20de=20instal?= =?UTF-8?q?aci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data_gen.sh | 4 ++-- register.sh | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/data_gen.sh b/data_gen.sh index acf5728..e051db5 100755 --- a/data_gen.sh +++ b/data_gen.sh @@ -42,12 +42,12 @@ counter=$(cat $install_dir/counter) uuid="$(uuidgen)" timestamp="$(date +%s)" json="{\"transaction_uuid\":\"$uuid\",\"controller_id\":\"$name\",\"timestamp\":\"$timestamp\",\"error_code\":\"10\",\"coordinates\":{\"lat\":1,\"lng\":1},\"battery_status\":\"98\",\"sample\":\"0\",\"storage\":\"uso del almacenamiento\",\"arduinos\":[$sensores]}" - touch /opt/nodemecu/lock + touch $install_dir/lock file=$(date +%Y%m%d%H%M%S)-$(uuidgen) for ((i=1 ; i <=3 ; i++));do if echo $json | jsonlint-php 2> /dev/null;then echo $json > /opt/nodemecu/stack/$file && rm /opt/nodemecu/lock && echo $((counter+1)) > $install_dir/counter && break else - echo "$(date +%Y-%m-%d-%H:%M:%S) - No se pudo obtener informaciĆ³n." >> /opt/nodemecu/errors.log && sleep 1 + echo "$(date +%Y-%m-%d-%H:%M:%S) - No se pudo obtener informaciĆ³n." >> $install_dir/errors.log && sleep 1 fi done diff --git a/register.sh b/register.sh index 93dcdb6..f53986d 100755 --- a/register.sh +++ b/register.sh @@ -1,21 +1,21 @@ #!/bin/bash #set -e source /etc/nodemecu.conf -source /opt/nodemecu/functions +source $install_dir/functions # Revisando stack -for filename in /opt/nodemecu/stack/*;do - test "$filename" = "/opt/nodemecu/stack/\*" || break - jsonlint-php $filename > /dev/null || mv -v $filename $corrupt +for filename in $install_dir/stack/*;do + test "$filename" = "$install_dir/stack/\*" || break + jq $filename >/dev/null 2>&1 || mv -v $filename $corrupt done while :;do ping -c 1 fsf.org > /dev/null 2>&1 || continue test_url="$(curl -s -X POST -o /dev/null -w "%{http_code}" $url)" if [ $test_url -eq 404 ];then - echo "$(date +%Y-%m-%d-%H:%M:%S) - $url - $test_url" >> /opt/nodemecu/errors.log && sleep 300 && continue + echo "$(date +%Y-%m-%d-%H:%M:%S) - $url - $test_url" >> $install_dir/errors.log && sleep 300 && continue fi [ -f $install_dir/lock ] && continue file=$(get_stack) @@ -42,6 +42,6 @@ while :;do rm $curl_err fi -done +done exit