#!/bin/bash
+echo "-----------ALLO / DECLARATION-----------"
+
# FICHIER DE CONFIGURATION
source ./allo_agent.conf
fi
# TEST DE CONNEXION
-code=$(curl -s -w "%{http_code}" --max-time 5 --output /dev/null "http://${instance_fqdn_interne}/api/rest/allo/version")
-#echo ${instance_fqdn_interne}
-#echo ${code}
+echo "Test d'accès de l'application sur ""${instance_fqdn_interne}""..."
+code=$(curl -s -w "%{http_code}" --max-time 5 "http://""${instance_fqdn_interne}""/api/rest/allo/version" --output /dev/null)
if [ "${code}" == 200 ] || [ "${code}" == 301 ]
then
+ echo "Test OK, récupération des informations..."
+
# REQUETE (en insecure pour le moment)
- curl --max-time 10 -k -X GET -H "${response_accept}" "http://${instance_fqdn_interne}/api/rest/allo/version/" --output "response.json" 2> /dev/null
+ curl --max-time 10 -k -X GET -H "${response_accept}" "http://""${instance_fqdn_interne}""/api/rest/allo/version/" --output "response.json" 2> /dev/null
# LOG DE LA REPONSE
#echo "$(cat response.json)" 2>&1 | tee -a $log_file
# VALIDATION DU JSON (nécessite outil de validation json et paquet node)
isJSONCorrupted="$(module/json -nq response.json)"
- echo "${isJSONCorrupted}"
+ #echo "${isJSONCorrupted}"
+
# SI LA VARIABLE EST INITIALISEE MAIS VIDE => PAS D'ERREUR
if [[ -z $isJSONCorrupted && ${isJSONCorrupted+x} ]]
then
+ echo "Envoi des information au serveur ALLO..."
+
# RÉCUPÉRATION DES NOMS, UUIDS ET LABELS DES DISQUES
disques=$(blkid /dev/sd* | sed 's/\"//g')
jq '. + { "canal": "'"${instance_canal}"'" }' tmp6.json > request.json
# ENVOI DE L'UPDATE AU SERVEUR
- curl --cert bma.pem --key bma.key -X POST -H "${request_type}" --data-binary "@request.json" -i "https://${allo_serveur_url}/?action=upload_info" --output "response_server" 2> /dev/null
+ curl --cert bma.pem --key bma.key -X POST -H "${request_type}" --data-binary "@request.json" "https://""${allo_serveur_url}""/?action=upload_info" --output "response_server" 2> /dev/null
if [ -e ./response_server ]
- then
- tee response_server -a "$log_file" 2>&1
+ then
+ echo "Réponse du serveur ALLO :"
+ #tee response_server -a "$log_file"
+ cat response_server 2>&1 | tee -a "$log_file"
else
echo "Aucune réponse du serveur !" 2>&1 | tee -a "$log_file"
fi
;;
esac
fi
+echo ""