Statistiques
| Révision :

chimie4psmn / submit / clean_up.sh @ 16

Historique | Voir | Annoter | Télécharger (583 octet)

1 16 tjiang
#!/bin/bash
2 16 tjiang
#How to use this script:
3 16 tjiang
#The usage is similar to the command rsync,
4 16 tjiang
#clean_up files_to_be_synced destination
5 16 tjiang
set -euo pipefail # strict mode
6 16 tjiang
set -x # Trace each command, can be commented
7 16 tjiang
8 16 tjiang
#number of files to be synced
9 16 tjiang
narg=$(($#-1))
10 16 tjiang
11 16 tjiang
#files to be synced
12 16 tjiang
files=${@:1:$narg}
13 16 tjiang
14 16 tjiang
pwd=$(pwd)
15 16 tjiang
#echo "${files}"
16 16 tjiang
rsync -r -c $@
17 16 tjiang
18 16 tjiang
#If exit code is 0 (succeed), then delete the files
19 16 tjiang
if [[ $? -ne 0 ]]
20 16 tjiang
then
21 16 tjiang
   echo "Failed copying back all the data. Please verify manually."
22 16 tjiang
   echo "The directory is: ${pwd}"
23 16 tjiang
   exit 1
24 16 tjiang
else
25 16 tjiang
   rm $files
26 16 tjiang
   echo "deleting ${files}"
27 16 tjiang
   echo "Done"
28 16 tjiang
fi