# 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 ${instance_fqdn_interne}
+#echo ${code}
if [ "${code}" == 200 ] || [ "${code}" == 301 ]
then
# SI LA VARIABLE EST INITIALISEE MAIS VIDE => PAS D'ERREUR
if [[ -z $isJSONCorrupted && ${isJSONCorrupted+x} ]]
then
+ # RÉCUPÉRATION DES NOMS, UUIDS ET LABELS DES DISQUES
+ disques=$(blkid /dev/sd* | sed 's/\"//g')
+
+ # SYSTEME D'EXPLOITATION
+ systeme=$(cat /etc/issue | sed 's/\\n\ \\l//g')
+
# AJOUT DE LA REFERENCE PRODUIT (nécessite package jq)
jq '. + { "reference": "'"${instance_reference}"'" }' response.json > tmp1.json
# AJOUT DU TYPE D'USAGER
- jq '. + { "usager_type": "'"${usager_type}"'" }' tmp1.json > tmp2.json
+ jq '. + { "usager_type": "'"${usager_type}"'" }' tmp1.json > tmp2.json
+
+ # AJOUT DES INFOS DISQUES
+ jq '. + { "disques": "'"${disques}"'" }' tmp2.json > tmp3.json
- # AJOUT DU TYPE DE PRODUIT
- jq '. + { "instance_type": "'"${instance_type}"'" }' tmp2.json > request.json
+ # AJOUT DES INFOS DISQUES
+ jq '. + { "systeme": "'"${systeme}"'" }' tmp3.json > tmp4.json
+
+ # AJOUT DU FQDN EXTERNE
+ jq '. + { "fqdn_externe": "'"${instance_fqdn_externe}"'" }' tmp4.json > tmp5.json
+ # AJOUT DU FQDN INTERNE
+ jq '. + { "fqdn_interne": "'"${instance_fqdn_interne}"'" }' tmp5.json > tmp6.json
+
+ # AJOUT DU TYPE DE PRODUIT
+ jq '. + { "instance_type": "'"${instance_type}"'" }' tmp6.json > request.json
+
# ENVOI DE L'UPDATE AU SERVEUR
- curl -k -X PUT -H "${request_type}" -d "$(cat request.json)" -i "http://${allo_serveur_url}/?action=upload_info" --output "response_server" 2> /dev/null
- if [ -e ./response_server ]
+ 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
+ if [ -e ./response_server ]
then
echo "$(cat response_server)" 2>&1 | tee -a $log_file
else
"400" | "404")
echo "Mauvaise requete" 2>&1 | tee -a $log_file
;;
+ "403")
+ echo "Accès refusé" 2>&1 | tee -a $log_file
+ ;;
*)
echo "Aucune réponse de l'application" 2>&1 | tee -a $log_file
;;