From 2feee6f70b40c2f543746f49f7114fcf888d66c4 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 3 Mar 2022 15:07:45 -0300 Subject: [PATCH] mover los archivos fallados a otro directorio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit de lo contrario detienen el envĂ­o porque el stack siempre devuelve el fallado --- install.sh | 1 + nodemecu.conf.sample | 1 + register.sh | 13 ++++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index eb9ce2b..a477195 100755 --- a/install.sh +++ b/install.sh @@ -18,6 +18,7 @@ sudo mkdir -vp $install_dir/archives/logs sudo mkdir $historical sudo mkdir $stack sudo mkdir $corrupt +sudo mkdir $failed echo "" sudo cp -vr $files $install_dir sudo cp -v $config /etc/nodemecu.conf diff --git a/nodemecu.conf.sample b/nodemecu.conf.sample index aadd101..4d1c3d0 100644 --- a/nodemecu.conf.sample +++ b/nodemecu.conf.sample @@ -15,3 +15,4 @@ stack=$install_dir/stack historical=$install_dir/historical log=$install_dir/errors.log corrupt=$install_dir/corrupt +failed=$install_dir/failed diff --git a/register.sh b/register.sh index 444d65a..b15064f 100755 --- a/register.sh +++ b/register.sh @@ -24,15 +24,18 @@ while :;do if [ $test_url -ne 200 ];then echo "$(date +%Y-%m-%d-%H:%M:%S) - $url - $test_url" >> $log && sleep 300 && continue fi + + file="$stack/$file" + local_transaction_uuid="$(echo "$file" | cut -d - -f 2-)" + remote_transaction=$(curl -s --connect-timeout 1 --show-error -w "~%{http_code}" -X POST -H "Content-Type: application/json" -d @$file $url 2> $curl_err) remote_response="$(echo $remote_transaction | cut -d '~' -f 1)" server_error="$(echo $remote_transaction | cut -d '~' -f 2)" - if [ ${#remote_response} -eq 36 ];then - if [ $local_transaction_uuid == $remote_response ]; then - mv $stack/$file $historical - echo -e "$remote_response: \e[92mOK\e[0m" - fi + if [ "$local_transaction_uuid" = "$remote_response" ]; then + mv $file $historical + echo -e "$remote_response: \e[92mOK\e[0m" else + mv $file $failed echo -e "$local_transaction_uuid: \e[91mFAIL\e[0m" # errores unset srv_msg