From 65c4d3c5a2881e3239444e1170345bdb44e79e48 Mon Sep 17 00:00:00 2001 From: GARDAIS Jeremy Date: Thu, 19 May 2016 11:22:01 +0200 Subject: [PATCH] Check if mail address from UR1 --- server/add_backuppc_host.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/add_backuppc_host.sh b/server/add_backuppc_host.sh index a5cf4c8..60df4fd 100755 --- a/server/add_backuppc_host.sh +++ b/server/add_backuppc_host.sh @@ -54,6 +54,7 @@ temp_fqdn=$(host ${ip} | cut -d' ' -f 5) fqdn="${temp_fqdn%?}" hostname=$(echo ${fqdn} | cut -d'.' -f1) 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) #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 "username: ${username}\n" +#### TESTS #### +# Check IP if [[ ${ip_ur1} != "129.20" ]]; then printf "La machine cliente n'était pas sur le réseau UR1\n" exit 1 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 #### # jfade.pr079076.spm.univ-rennes1.fr 0 jfade if [[ ! $(grep "${username}.${hostname}" "${backuppc_host_file}") ]]; then