Arreglos varios #6

Open
fauno wants to merge 21 commits from arreglos into master
2 changed files with 8 additions and 8 deletions
Showing only changes of commit dd48575a1b - Show all commits

View file

@ -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

View file

@ -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