[2160] | 1 | #!/bin/bash |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | # 1- faire un mv de la simu d'origine en JobName.BF (BF = Before Pack) |
---|
| 5 | # 2- copier sur le store la simu repackee sur Pseudo_dmnfs_store |
---|
| 6 | # 3- effacer dans JobName_BF les fichiers contenus dans les listes correctement traitees |
---|
| 7 | |
---|
| 8 | #---------------------------------------------------------------- |
---|
| 9 | #---------------------------------------------------------------- |
---|
| 10 | # On renseigne les variables d'environnement |
---|
| 11 | . load_ipslPack_env.sh |
---|
| 12 | |
---|
| 13 | export JOB_DIR=${TMP_MIGR_DATA} |
---|
| 14 | export EXE_DIR=${LS_SUBCWD:-${PWD}} |
---|
| 15 | |
---|
| 16 | SCRIPT_NAME=$(basename ${0} ) |
---|
| 17 | |
---|
| 18 | export IGCM_TMP="${IGCM_DEM}/tmp" # gpdebug : added |
---|
| 19 | |
---|
| 20 | export config_card=${IGCM_DEM}/config_card.liste |
---|
| 21 | |
---|
| 22 | source ${EXE_DIR}/DEM_utilities.sh |
---|
| 23 | #---------------------------------------------------------------- |
---|
| 24 | #---------------------------------------------------------------- |
---|
| 25 | |
---|
| 26 | # Gestion de l'option de lancement |
---|
| 27 | # si -R --> alors on active le stockage sur le store et le remove des anciennes donnees |
---|
| 28 | |
---|
| 29 | execRmv=0 |
---|
[2161] | 30 | forceDirect2Rmv=0 |
---|
[2160] | 31 | while [ $# -gt 0 ] |
---|
| 32 | do |
---|
| 33 | case $1 in |
---|
[2161] | 34 | -h) cat <<fin |
---|
| 35 | script permettant de finaliser l'operation de surpack |
---|
| 36 | 1- creer la liste des fichiers a effacer sur le store (tous les fichiers repackes) |
---|
| 37 | 2- copie l'ancienne simulation en $SIMU.BP (for before Pack) |
---|
| 38 | 3- copie sur le store la simulation repackee |
---|
| 39 | 4- efface dans $SIMU.BP les fichiers repackes |
---|
| 40 | |
---|
| 41 | Usage : |
---|
| 42 | -h : mode d'emploi |
---|
| 43 | -rmv : lance automatiquement la phase de copie sur le store et de remove des anciennes donnees. |
---|
| 44 | sinon le script s'arrete a la creation de la liste de fichiers a effacer. |
---|
| 45 | fin |
---|
| 46 | exit;; |
---|
[2160] | 47 | -rmv) execRmv=1 |
---|
| 48 | ;; |
---|
| 49 | *) echo "option non reconnue" |
---|
| 50 | exit |
---|
| 51 | ;; |
---|
| 52 | esac |
---|
| 53 | shift |
---|
| 54 | done |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | # liste des simus |
---|
[2161] | 59 | |
---|
[2160] | 60 | for CONFIG in $( awk '{print $1}' ${IGCM_DEM}/config_card.liste ) |
---|
| 61 | do |
---|
| 62 | PATH_SIMU=$( dirname $CONFIG ) |
---|
| 63 | |
---|
| 64 | # liste des tar RESTART et DEBUG a effacer |
---|
| 65 | config_card=$PATH_SIMU/config_card_* |
---|
| 66 | eval $(grep PATH_SIMUL_FULL ${config_card}) |
---|
| 67 | eval $(grep IGCM_DEM_SIMU ${config_card}) |
---|
| 68 | eval $(grep JobName ${config_card}) |
---|
| 69 | |
---|
| 70 | SIMU=${PATH_SIMUL_FULL} |
---|
[2161] | 71 | SIMU_BP=${SIMU}.BP |
---|
[2160] | 72 | |
---|
| 73 | LITTLE_PATH=`echo $PATH_SIMUL_FULL | sed "s%${INPUT_DMF_DATA}%%"` |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | cd ${USER_OUTPUT_PROGRESS} |
---|
| 77 | find . -name "removedFiles*" > liste_files.txt |
---|
[2162] | 78 | |
---|
[2160] | 79 | rmv_file_bis=${USER_OUTPUT_PROGRESS}/rmv_afterSurPack.txt |
---|
[2162] | 80 | rm -f ${rmv_file_bis} |
---|
[2161] | 81 | |
---|
[2160] | 82 | for removedfile in `awk '{print $0}' liste_files.txt`; do |
---|
| 83 | rmv_file=${removedfile} |
---|
[2161] | 84 | |
---|
| 85 | |
---|
[2160] | 86 | if [[ -f ${rmv_file_bis} ]] ; then |
---|
| 87 | cp ${rmv_file} ${rmv_file_bis} |
---|
| 88 | else |
---|
| 89 | cat ${rmv_file} >> ${rmv_file_bis} |
---|
| 90 | fi |
---|
| 91 | |
---|
| 92 | mkdir -p ${IGCM_DEM_SIMU}/restart_rmv |
---|
| 93 | rm -rf ${IGCM_DEM_SIMU}/restart_rmv/* |
---|
| 94 | for archive in `awk '{print $2}' ${IGCM_DEM_SIMU}/liste_restart_files_config.txt`; do |
---|
| 95 | not_rmv=0 |
---|
| 96 | ccc_hsm get $archive |
---|
| 97 | tar tf $archive > ${IGCM_DEM_SIMU}/restart_rmv/archive.rmv |
---|
| 98 | for fichier in `awk '{print $0}' ${IGCM_DEM_SIMU}/restart_rmv/archive.rmv`; do |
---|
| 99 | FindFile=`grep $fichier $rmv_file` |
---|
| 100 | if [ "X$FindFile" == "X" ]; then |
---|
| 101 | echo "$archive tar to be conserved" |
---|
| 102 | not_rmv=1 |
---|
| 103 | fi |
---|
| 104 | done |
---|
| 105 | if [ $not_rmv == 0 ] ; then |
---|
| 106 | echo "rm -f $archive" >> ${rmv_file_bis} |
---|
| 107 | fi |
---|
| 108 | rm -f ${IGCM_DEM_SIMU}/restart_rmv/archive.rmv |
---|
| 109 | done |
---|
| 110 | |
---|
| 111 | mkdir -p ${IGCM_DEM_SIMU}/debug_rmv |
---|
| 112 | rm -rf ${IGCM_DEM_SIMU}/debug_rmv/* |
---|
| 113 | for archive in `awk '{print $0}' ${IGCM_DEM_SIMU}/liste_debug_files_config.txt`; do |
---|
| 114 | not_rmv=0 |
---|
| 115 | ccc_hsm get $archive |
---|
| 116 | tar tf $archive > ${IGCM_DEM_SIMU}/debug_rmv/archive.rmv |
---|
| 117 | for fichier in `awk '{print $0}' ${IGCM_DEM_SIMU}/debug_rmv/archive.rmv`; do |
---|
| 118 | FindFile=`grep $fichier $rmv_file` |
---|
[2161] | 119 | if [ "X$FindFile" == "X" ]; then |
---|
| 120 | echo "$archive tar to be conserved" |
---|
| 121 | not_rmv=1 |
---|
| 122 | fi |
---|
[2160] | 123 | done |
---|
| 124 | if [ $not_rmv == 0 ] ; then |
---|
| 125 | echo "rm -f $archive" >> ${rmv_file_bis} |
---|
| 126 | fi |
---|
| 127 | rm -f ${IGCM_DEM_SIMU}/debug_rmv/archive.rmv |
---|
| 128 | done |
---|
| 129 | done |
---|
[2161] | 130 | sed -i -e "s%${SIMU}\/%${SIMU_BP}\/%g" ${rmv_file_bis} |
---|
[2162] | 131 | echo "grep ${JobName} ${rmv_file_bis} > ${rmv_file_bis}.tmp" |
---|
| 132 | grep ${JobName} ${rmv_file_bis} > ${rmv_file_bis}.tmp; mv ${rmv_file_bis}.tmp ${rmv_file_bis} |
---|
[2160] | 133 | chmod 755 ${rmv_file_bis} |
---|
[2161] | 134 | |
---|
[2162] | 135 | |
---|
| 136 | |
---|
| 137 | if [[ $execRmv == 1 ]] ; then |
---|
[2160] | 138 | # sauver l'ancienne version |
---|
[2161] | 139 | mv ${SIMU} ${SIMU_BP} |
---|
[2160] | 140 | #copier sur le store la nouvelle |
---|
| 141 | mv ${OUTPUT_STORE}${LITTLE_PATH} ${SIMU} |
---|
| 142 | #copie du repertoire Exe qui ne change pas |
---|
[2162] | 143 | mv ${SIMU_BP}/Exe ${SIMU}/. |
---|
[2160] | 144 | # effacer dans l'ancienne version les fichiers de rmv_file_bis |
---|
| 145 | ${rmv_file_bis} |
---|
[2162] | 146 | #creation de la liste des fichiers restant |
---|
| 147 | find ${SIMU_BP} -printf "%y %s %p \n" > ${USER_OUTPUT_PROGRESS}/lastFiles_afterSurPack.txt |
---|
| 148 | |
---|
[2160] | 149 | fi |
---|
| 150 | done |
---|
| 151 | |
---|
[2161] | 152 | |
---|