For more details, see version section of the script.
| ... | ... |
@@ -1,9 +1,9 @@ |
| 1 | 1 |
#!/bin/bash |
| 2 | 2 |
# Title: git-sync.sh |
| 3 |
-# Version: 2.1 |
|
| 3 |
+# Version: 2.2 |
|
| 4 | 4 |
# Author: Frédéric CHEVALIER <fcheval@txbiomedgenetics.org> |
| 5 | 5 |
# Created in: 2014-09-03 |
| 6 |
-# Modified in: 2015-03-12 |
|
| 6 |
+# Modified in: 2016-01-07 |
|
| 7 | 7 |
# Licence: GPL v3 |
| 8 | 8 |
|
| 9 | 9 |
|
| ... | ... |
@@ -20,6 +20,7 @@ aim="Synchronize files from a git server on this terminal." |
| 20 | 20 |
# Versions # |
| 21 | 21 |
#==========# |
| 22 | 22 |
|
| 23 |
+# v2.2 - 2016-01-07: process of list file improved (tmp list not needed anymore) / Timestamp added to the downloaded file to avoid interference with several script instance running at the same time |
|
| 23 | 24 |
# v2.1 - 2015-03-12: evaluation of the variables created from the list in order to use environment variables (ie, $HOME) / directoy checked instead of created otherwise may lead to unwanted path if error in list file / usage message updated |
| 24 | 25 |
# v2.0 - 2015-02-27: error function improved / info function added / file installed and directory created if not already present / modification of file permission can be specified in the file list and apply to the file |
| 25 | 26 |
# v1.3 - 2014-12-04: warning and error functions improved |
| ... | ... |
@@ -137,9 +138,9 @@ then |
| 137 | 138 |
error "The option -l is required. Exiting...\n$(usage)\n" 1 |
| 138 | 139 |
fi |
| 139 | 140 |
|
| 140 |
-# Temporary list |
|
| 141 |
-mydate=$(date +%N) |
|
| 142 |
-tmp_list="/tmp/$(basename $list)-$mydate" |
|
| 141 |
+ |
|
| 142 |
+# Timestamp |
|
| 143 |
+myts=$(date +%N) |
|
| 143 | 144 |
|
| 144 | 145 |
|
| 145 | 146 |
|
| ... | ... |
@@ -154,21 +155,25 @@ then |
| 154 | 155 |
fi |
| 155 | 156 |
|
| 156 | 157 |
|
| 157 |
-# Remove comments from list file |
|
| 158 |
-sed "/^\s*#/d;s/\s*#.*$//" "$list" > "$tmp_list" |
|
| 159 |
-sed -i "/^$/d" "$tmp_list" |
|
| 160 |
- |
|
| 161 |
- |
|
| 162 | 158 |
# Synchronization |
| 163 | 159 |
while read line |
| 164 | 160 |
do |
| 165 | 161 |
|
| 162 |
+ # Remove comments from list file |
|
| 163 |
+ line=$(echo "$line" | sed "/^\s*#/d;s/\s*#.*$//") |
|
| 164 |
+ |
|
| 165 |
+ # Skip if empty line |
|
| 166 |
+ if [[ -z "$line" ]] |
|
| 167 |
+ then |
|
| 168 |
+ continue |
|
| 169 |
+ fi |
|
| 170 |
+ |
|
| 166 | 171 |
# Get paths |
| 167 | 172 |
eval mysrc=$(echo "$line" | cut -d ";" -f 1 | sed -e "s/^ *//" -e "s/ *$//") |
| 168 | 173 |
eval mydst=$(echo "$line" | cut -d ";" -f 2 | sed -e "s/^ *//" -e "s/ *$//") |
| 169 | 174 |
eval mymod=$(echo "$line" | cut -d ";" -f 3 | sed -e "s/^ *//" -e "s/ *$//") |
| 170 | 175 |
|
| 171 |
- mydst_tmp="/tmp/${mydst##*/}"
|
|
| 176 |
+ mydst_tmp="/tmp/${mydst##*/}-$myts"
|
|
| 172 | 177 |
|
| 173 | 178 |
|
| 174 | 179 |
# Check if mydst variable is empty or contain directory |
| ... | ... |
@@ -234,11 +239,7 @@ do |
| 234 | 239 |
continue |
| 235 | 240 |
fi |
| 236 | 241 |
|
| 237 |
-done < "$tmp_list" |
|
| 238 |
- |
|
| 239 |
- |
|
| 240 |
-# Remove temporary list |
|
| 241 |
-rm "$tmp_list" |
|
| 242 |
+done < "$list" |
|
| 242 | 243 |
|
| 243 | 244 |
|
| 244 | 245 |
exit 0 |