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)" uuid="$(uuidgen)"
timestamp="$(date +%s)" 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]}" 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) file=$(date +%Y%m%d%H%M%S)-$(uuidgen)
for ((i=1 ; i <=3 ; i++));do for ((i=1 ; i <=3 ; i++));do
if echo $json | jsonlint-php 2> /dev/null;then 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 echo $json > /opt/nodemecu/stack/$file && rm /opt/nodemecu/lock && echo $((counter+1)) > $install_dir/counter && break
else 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 fi
done done

View file

@ -1,21 +1,21 @@
#!/bin/bash #!/bin/bash
#set -e #set -e
source /etc/nodemecu.conf source /etc/nodemecu.conf
source /opt/nodemecu/functions source $install_dir/functions
# Revisando stack # Revisando stack
for filename in /opt/nodemecu/stack/*;do for filename in $install_dir/stack/*;do
test "$filename" = "/opt/nodemecu/stack/\*" || break test "$filename" = "$install_dir/stack/\*" || break
jsonlint-php $filename > /dev/null || mv -v $filename $corrupt jq $filename >/dev/null 2>&1 || mv -v $filename $corrupt
done done
while :;do while :;do
ping -c 1 fsf.org > /dev/null 2>&1 || continue ping -c 1 fsf.org > /dev/null 2>&1 || continue
test_url="$(curl -s -X POST -o /dev/null -w "%{http_code}" $url)" test_url="$(curl -s -X POST -o /dev/null -w "%{http_code}" $url)"
if [ $test_url -eq 404 ];then 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 fi
[ -f $install_dir/lock ] && continue [ -f $install_dir/lock ] && continue
file=$(get_stack) file=$(get_stack)