terminada implementacion de firma
This commit is contained in:
parent
14aec95b6f
commit
3cf6f1d4bf
3 changed files with 15 additions and 14 deletions
|
@ -2,9 +2,9 @@
|
||||||
#set -x
|
#set -x
|
||||||
get_stack () {
|
get_stack () {
|
||||||
if [[ ! -z $1 && $1 == "wc" ]];then
|
if [[ ! -z $1 && $1 == "wc" ]];then
|
||||||
ls -I "*.sign" $registros | wc -l
|
ls -I "*.sig" $registros | wc -l
|
||||||
else
|
else
|
||||||
ls -I "*.sign" $registros | tail -1
|
ls -I "*.sig" $registros | tail -1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ source /opt/nodemecu/envs
|
||||||
source $funciones
|
source $funciones
|
||||||
|
|
||||||
conteo=$(cat $contador)
|
conteo=$(cat $contador)
|
||||||
uuid="$(uuidgen)"
|
uuid="$(uuid)"
|
||||||
marca_de_tiempo="$(date +%s)"
|
marca_de_tiempo="$(date +%s)"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -x
|
#set -x
|
||||||
source /etc/nodemecu.conf
|
source /etc/nodemecu.conf
|
||||||
source /opt/nodemecu/envs
|
source /opt/nodemecu/envs
|
||||||
source $funciones
|
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
|
# echo "$(date +%Y-%m-%d-%H:%M:%S) - $url - $test_url" >> /opt/nodemecu/errors.log && sleep 300 && continue
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
# firma de registros
|
firma=$(sign_file $registros/$file)
|
||||||
|
|
||||||
sign_file $registros/$file
|
|
||||||
exit
|
|
||||||
|
|
||||||
local_transaction_uuid=$(jq -r '."transaction_uuid"' $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)"
|
remote_response="$(echo $remote_transaction | cut -d '~' -f 1)"
|
||||||
server_error="$(echo $remote_transaction | cut -d '~' -f 2)"
|
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"
|
echo -e "$remote_response: \e[92mOK\e[0m"
|
||||||
fi
|
mv $registros/$file $registros/$file.sig $historicos
|
||||||
else
|
else
|
||||||
echo -e "$local_transaction_uuid: \e[91mFAIL\e[0m"
|
echo -e "$local_transaction_uuid: \e[91mFAIL\e[0m"
|
||||||
# errores
|
# errores
|
||||||
|
@ -62,8 +60,11 @@ while :;do
|
||||||
err_time=$(date +%Y-%m-%d-%H:%M:%S)
|
err_time=$(date +%Y-%m-%d-%H:%M:%S)
|
||||||
[ ! -z "$remote_response" ] && srv_msg="- $( echo $remote_response | grep -o '<body.*>.*</body>')"
|
[ ! -z "$remote_response" ] && srv_msg="- $( echo $remote_response | grep -o '<body.*>.*</body>')"
|
||||||
[ -s "$curl_err" ] && curl_msg="- $(</tmp/curl_err)"
|
[ -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
|
rm $curl_err
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue