#!/bin/bash

cd /ccc/work/cont003/igcmg/igcmg

echo " Resultat du rsync en dry-run : "
echo ""
rsync -n --omit-dir-times  -vrltgoD --progress --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" igcmg@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets IGCM
#rsync -n -vrltgoD --progress --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" jservon@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/atm ReferenceDatasets
#rsync -n -vrltgoD --progress --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" igcmg@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/oce ReferenceDatasets
#rsync -n -vrltgoD --progress --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" igcmg@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/ice ReferenceDatasets
#rsync -n -vrltgoD --progress --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" igcmg@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/PCMDI-MP ReferenceDatasets

echo "Voulez vous effectuer les actions listees ci dessus oui/non ?"
echo -n " Votre reponse : "
read reponse

case ${reponse} in

oui|OUI|o)
rsync --omit-dir-times  -vrltgoD --progress --chmod=o-w --chmod=g-w --chmod=u-w --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" igcmg@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets IGCM
#rsync -vrltgoD --progress --chmod=o-w --chmod=g-w --chmod=u-w --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" jservon@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/atm ReferenceDatasets
#rsync -vrltgoD --progress --chmod=o-w --chmod=g-w --chmod=u-w --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" jservon@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/oce ReferenceDatasets
#rsync -vrltgoD --progress --chmod=o-w --chmod=g-w --chmod=u-w --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" jservon@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/ice ReferenceDatasets
#rsync -vrltgoD --progress --chmod=o-w --chmod=g-w --chmod=u-w --delete -e "ssh -ax -o ClearAllForwardings=yes -c blowfish" jservon@ciclad.ipsl.jussieu.fr:/data/jservon/Evaluation/ReferenceDatasets/PCMDI-MP ReferenceDatasets


;;
non|NON|n)
echo "RIEN A FAIRE !"
;;
*)
echo "Reponse non reconnue"
;;
esac

echo "Verification des droits des repertoires TGCC"
ccc_shspace_chmod userread /ccc/work/cont003/igcmg/igcmg/IGCM/ReferenceDatasets
is_problem=` ccc_shspace_modck ReferenceDatasets |grep ccc_shspace_chmod |wc -l`
if [ "x${is_problem}" != "x0" ] 
then
  echo "Il y a un probleme de droit sur un repertoire qui ne vous appartient pas"
  echo "vous pouvez utiliser la commande ccc_shspace_modck IGCM pour savoir qui doit mettre a jour les droits"
fi 
