terminada implementacion de firma

This commit is contained in:
Sergio Pernas 2022-03-17 19:26:50 +00:00
parent 14aec95b6f
commit 3cf6f1d4bf
3 changed files with 15 additions and 14 deletions

View file

@ -2,9 +2,9 @@
#set -x
get_stack () {
if [[ ! -z $1 && $1 == "wc" ]];then
ls -I "*.sign" $registros | wc -l
ls -I "*.sig" $registros | wc -l
else
ls -I "*.sign" $registros | tail -1
ls -I "*.sig" $registros | tail -1
fi
}

View file

@ -5,7 +5,7 @@ source /opt/nodemecu/envs
source $funciones
conteo=$(cat $contador)
uuid="$(uuidgen)"
uuid="$(uuid)"
marca_de_tiempo="$(date +%s)"

View file

@ -1,5 +1,5 @@
#!/bin/bash
set -x
#set -x
source /etc/nodemecu.conf
source /opt/nodemecu/envs
source $funciones
@ -39,21 +39,19 @@ while :;do
# echo "$(date +%Y-%m-%d-%H:%M:%S) - $url - $test_url" >> /opt/nodemecu/errors.log && sleep 300 && continue
#fi
# firma de registros
sign_file $registros/$file
exit
firma=$(sign_file $registros/$file)
local_transaction_uuid=$(jq -r '."transaction_uuid"' $registros/$file)
remote_transaction=$(curl -s --connect-timeout 1,5 --show-error -w "~%{http_code}" -X POST -H "X-Signature: $(sign_file $registros/$file.sig)" -H "Content-Type: application/json" -d @$registros/$file $servidor 2> $curl_err)
remote_transaction=$(curl -s --show-error -w "~%{http_code}" -X POST -H "X-Signature: $(sign_file $registros/$file)" -H "Content-Type: application/json" -d @$registros/$file $servidor 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 $registros/$file $registros/$file.sig $historicos
if [ ${#remote_response} -eq 36 ] && [ "$local_transaction_uuid" == "$remote_response" ]; then
echo -e "$remote_response: \e[92mOK\e[0m"
fi
mv $registros/$file $registros/$file.sig $historicos
else
echo -e "$local_transaction_uuid: \e[91mFAIL\e[0m"
# errores
@ -62,8 +60,11 @@ while :;do
err_time=$(date +%Y-%m-%d-%H:%M:%S)
[ ! -z "$remote_response" ] && srv_msg="- $( echo $remote_response | grep -o '<body.*>.*</body>')"
[ -s "$curl_err" ] && curl_msg="- $(</tmp/curl_err)"
echo $err_time - $local_transaction_uuid - server status: $server_error $srv_msg $curl_msg >> $log
echo "$err_time - $local_transaction_uuid - server status: $server_error $srv_msg curl message: " >> $log
[ -s "$curl_err" ] && cat $curl_err >> $log
rm $curl_err
exit
fi
done