Check if mail address from UR1

This commit is contained in:
Jeremy Gardais 2016-05-19 11:22:01 +02:00
parent b244cdd592
commit 65c4d3c5a2
1 changed files with 9 additions and 0 deletions

View File

@ -54,6 +54,7 @@ temp_fqdn=$(host ${ip} | cut -d' ' -f 5)
fqdn="${temp_fqdn%?}" fqdn="${temp_fqdn%?}"
hostname=$(echo ${fqdn} | cut -d'.' -f1) hostname=$(echo ${fqdn} | cut -d'.' -f1)
mail=$(grep "# mail:" ${config_pl_path} | cut -d':' -f 2) mail=$(grep "# mail:" ${config_pl_path} | cut -d':' -f 2)
mail_ur1=$(echo ${mail} | cut -d'@' -f2)
username=$(ldapsearch -ZZ -H ldap://ldap.univ-rennes1.fr -LLL '(mail='"${mail}"')' -b "dc=univ-rennes1,dc=fr" -x uid | grep "^uid" | cut -d" " -f2) username=$(ldapsearch -ZZ -H ldap://ldap.univ-rennes1.fr -LLL '(mail='"${mail}"')' -b "dc=univ-rennes1,dc=fr" -x uid | grep "^uid" | cut -d" " -f2)
#printf "IP: ${ip}\n" #printf "IP: ${ip}\n"
@ -63,11 +64,19 @@ username=$(ldapsearch -ZZ -H ldap://ldap.univ-rennes1.fr -LLL '(mail='"${mail}"'
#printf "mail: ${mail}\n" #printf "mail: ${mail}\n"
#printf "username: ${username}\n" #printf "username: ${username}\n"
#### TESTS ####
# Check IP
if [[ ${ip_ur1} != "129.20" ]]; then if [[ ${ip_ur1} != "129.20" ]]; then
printf "La machine cliente n'était pas sur le réseau UR1\n" printf "La machine cliente n'était pas sur le réseau UR1\n"
exit 1 exit 1
fi fi
# Check mail
if [[ ${mail_ur1} != "univ-rennes1.fr" ]]; then
printf "Le client n'a pas renseigné une adresse UR1\n"
exit 1
fi
#### AJOUTER L HÔTE DANS ${BACKUPPC_CONFIG_DIR}/HOSTS #### #### AJOUTER L HÔTE DANS ${BACKUPPC_CONFIG_DIR}/HOSTS ####
# jfade.pr079076.spm.univ-rennes1.fr 0 jfade # jfade.pr079076.spm.univ-rennes1.fr 0 jfade
if [[ ! $(grep "${username}.${hostname}" "${backuppc_host_file}") ]]; then if [[ ! $(grep "${username}.${hostname}" "${backuppc_host_file}") ]]; then