echo "------------------------------------------------------------------------"
validation=false
while [ "$validation" = false ] ; do
-read -p "FQDN (interne) de l'application [instance.mondomaine.local] : "
-if [ "$REPLY" == "" ]
-then
- fqdn_interne="instance.mondomaine.local"
-else
- fqdn_interne="$REPLY"
-fi
-read -p "FQDN (externe) de l'application [instance.mondomaine.fr] : "
-if [ "$REPLY" == "" ]
-then
- fqdn_externe="instance.mondomaine.fr"
-else
- fqdn_externe="$REPLY"
-fi
-read -p "Canal de mise à jour [QUALIF/prod] : "
-if [ "$REPLY" == "" ]
-then
- canal="qualif"
-else
- canal="$REPLY"
-fi
-read -p "Type d'usager [CLIENT/exploitant] : "
-if [ "$REPLY" == "" ]
-then
- usager="client"
-else
- usager="$REPLY"
-fi
-read -p "Reférence du client [] : "
-reference_client="$REPLY"
-echo "FQDN interne : "${fqdn_interne}
-echo "FQDN externe : "${fqdn_externe}
-echo "Canal de mise à jour : "${canal}
-echo "Type d'usager : "${usager}
-echo "Référence client : "${reference_client}
-read -p "Ces informations sont-elles correctes [O/n] ? "
-if [ "$REPLY" == "" ] || [ "$REPLY" == "o" ] || [ "$REPLY" == "O" ] || [ "$REPLY" == "oui" ] || [ "$REPLY" == "Oui" ] || [ "$REPLY" == "OUI" ]
-then
- validation=true
-fi
-done
-# TEST DE CONNEXION
-fqdn_interne="api_test"
-code=$(curl -s -w "%{http_code}" --max-time 5 --output /dev/null "http://${fqdn_interne}/api/rest/allo/version")
+ validation_fqdn_interne=false
+ while [ "$validation_fqdn_interne" = false ] ; do
+ read -p "FQDN (interne) de l'application [instance.mondomaine.local] : "
+ if [ "$REPLY" == "" ]
+ then
+ fqdn_interne="instance.mondomaine.local"
+ else
+ fqdn_interne="$REPLY"
+ fi
+ # TEST DE CONNEXION
+ code=$(curl -s -w "%{http_code}" --max-time 5 --output /dev/null "http://${fqdn_interne}/api/rest/allo/version")
-if [ "${code}" == 200 ] || [ "${code}" == 301 ]
-then
- # REQUETE (en insecure pour le moment)
- curl --max-time 10 -k -X GET -H "Accept: application/json" "http://${fqdn_interne}/api/rest/allo/version/" --output "response.json" 2> /dev/null
+ if [ "${code}" == 200 ] || [ "${code}" == 301 ]
+ then
+ # REQUETE (en insecure pour le moment)
+ curl --max-time 10 -k -X GET -H "Accept: application/json" "http://${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
+ produit="$(jq -r '.produit' response.json)"
+ echo "Produit : "${produit}
+
+ case "${produit}" in
+ "i-Parapheur")
+ prefixe="IP"
+ ;;
+ "as@lae")
+ prefixe="AS"
+ ;;
+ *)
+ echo "Produit non reconnu" 2>&1 | tee -a $log_file
+ ;;
+ esac
+
+ read -p "S'agit-il du bon nom de produit pour l'instance [O/n] ? "
+ if [ "$REPLY" == "" ] || [ "$REPLY" == "o" ] || [ "$REPLY" == "O" ] || [ "$REPLY" == "oui" ] || [ "$REPLY" == "Oui" ] || [ "$REPLY" == "OUI" ]
+ then
+ validation_fqdn_interne=true
+ fi
+ else
+ echo "Le FQDN de l'application est incorrect ou cette dernière ne répond pas, merci de vérifier le paramétrage et de renseigner le bon FQDN."
+ fi
+ done
+
+ read -p "FQDN (externe) de l'application [instance.mondomaine.fr] : "
+ if [ "$REPLY" == "" ]
+ then
+ fqdn_externe="instance.mondomaine.fr"
+ else
+ fqdn_externe="$REPLY"
+ fi
- # VALIDATION DU JSON (nécessite outil de validation json)
- #isJSONCorrupted=$(cat response.json | module/json -nq)
+ read -p "Canal de mise à jour [PROD/qualif] : "
+ if [ "$REPLY" == "" ]
+ then
+ canal="prod"
+ else
+ canal="$REPLY"
+ fi
- # SI LA VARIABLE EST INITIALISEE MAIS VIDE => PAS D'ERREUR
- #if [[ -z $isJSONCorrupted && ${isJSONCorrupted+x} ]]
- #then
- produit="$(jq -r '.produit' response.json)"
- echo "Produit : "${produit}
+ validation_ref_client=false
+ while [ "$validation_ref_client" = false ] ; do
+ read -p "Référence client [] : "
+ if [ "$REPLY" == "" ]
+ then
+ echo "Erreur : merci de préciser une référence client valide."
+ else
+ reference_client="$REPLY"
+ validation_ref_client=true
+ fi
+ done
+ echo "FQDN interne : "${fqdn_interne}
+ echo "FQDN externe : "${fqdn_externe}
+ echo "Canal de mise à jour : "${canal}
+ echo "Référence client : "${reference_client}
- case "${produit}" in
- "i-Parapheur")
- prefixe="IP"
- ;;
- "as@lae")
- prefixe="AS"
- ;;
- *)
- echo "Produit non reconnu" 2>&1 | tee -a $log_file
- ;;
- esac
- #fi
-fi
+ read -p "Ces informations sont-elles correctes [O/n] ? "
+ if [ "$REPLY" == "" ] || [ "$REPLY" == "o" ] || [ "$REPLY" == "O" ] || [ "$REPLY" == "oui" ] || [ "$REPLY" == "Oui" ] || [ "$REPLY" == "OUI" ]
+ then
+ validation=true
+ fi
+done
# Création du allo_agent.conf
-# To-do : possibilité de mise à jour d'une conf existante
+# To-do : possibilité de choix de mise à jour d'une conf existante
configuration="allo_agent.conf"
now="$(date +'%d%m%y%H%M')"
if [ -e "${configuration}" ]
echo "# Référence de l'instance sur ALLO" >> $configuration
echo 'instance_reference="'${prefixe}'/'${reference_client}'_'${now}'"' >> $configuration
echo "# Type d'usager (exploitant|client)" >> $configuration
-echo 'usager_type="'${usager}'"' >> $configuration
+echo 'usager_type="client"' >> $configuration
echo "# Type d'instance (qualif|prod)" >> $configuration
-echo 'instance_type="'${canal}'"' >> $configuration
+echo 'instance_canal="'${canal}'"' >> $configuration
echo "# Fqdn interne" >> $configuration
echo 'instance_fqdn_interne="'${fqdn_interne}'"' >> $configuration
echo "# Fqdn externe" >> $configuration