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.2 |
|
| 4 |
-# Author: Frédéric CHEVALIER <fcheval@txbiomedgenetics.org> |
|
| 3 |
+# Version: 2.3 |
|
| 4 |
+# Author: Frédéric CHEVALIER <fcheval@txbiomed.org> |
|
| 5 | 5 |
# Created in: 2014-09-03 |
| 6 |
-# Modified in: 2016-01-07 |
|
| 6 |
+# Modified in: 2016-01-17 |
|
| 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.3 - 2016-01-17: email address updated / version in usage message / temporary files removed after downloading if present but error or after dry-run / "a" included in the list of checked letter for chmod |
|
| 23 | 24 |
# 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 |
| 24 | 25 |
# 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 |
| 25 | 26 |
# 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 |
| ... | ... |
@@ -30,6 +31,8 @@ aim="Synchronize files from a git server on this terminal." |
| 30 | 31 |
# v0.1 - 2014-09-23: dry-run option added / no check certifcate option added for wget |
| 31 | 32 |
# v0.0 - 2014-09-03: creation |
| 32 | 33 |
|
| 34 |
+version=$(grep -i -m 1 "version" "$0" | cut -d ":" -f 2 | sed "s/ *//") |
|
| 35 |
+ |
|
| 33 | 36 |
|
| 34 | 37 |
|
| 35 | 38 |
#===========# |
| ... | ... |
@@ -52,6 +55,8 @@ function usage {
|
| 52 | 55 |
|
| 53 | 56 |
Aim: $aim |
| 54 | 57 |
|
| 58 |
+Version: $version |
|
| 59 |
+ |
|
| 55 | 60 |
Options: |
| 56 | 61 |
-l, --list Text file containing both remote and local path of |
| 57 | 62 |
a given file for synchronization. |
| ... | ... |
@@ -159,11 +164,7 @@ fi |
| 159 | 164 |
while read line |
| 160 | 165 |
do |
| 161 | 166 |
|
| 162 |
-<<<<<<< HEAD |
|
| 163 |
- # Remove comments from list file |
|
| 164 |
-======= |
|
| 165 | 167 |
# Remove comments from line |
| 166 |
->>>>>>> git-sync.sh |
|
| 167 | 168 |
line=$(echo "$line" | sed "/^\s*#/d;s/\s*#.*$//") |
| 168 | 169 |
|
| 169 | 170 |
# Skip if empty line |
| ... | ... |
@@ -205,6 +206,7 @@ do |
| 205 | 206 |
if [[ $? != 0 ]] |
| 206 | 207 |
then |
| 207 | 208 |
warning "${mydst##*/}: An error occured during the downloading. Skipping..."
|
| 209 |
+ [[ -f "$mydst_tmp" ]] && rm "$mydst_tmp" |
|
| 208 | 210 |
continue |
| 209 | 211 |
# Check if destination file exists |
| 210 | 212 |
elif [[ ! -e "$mydst" ]] |
| ... | ... |
@@ -225,6 +227,7 @@ do |
| 225 | 227 |
if [[ $dry == 1 ]] |
| 226 | 228 |
then |
| 227 | 229 |
info "${mydst##*/}: new version available."
|
| 230 |
+ rm "$mydst_tmp" |
|
| 228 | 231 |
else |
| 229 | 232 |
mv "$mydst_tmp" "$mydst" |
| 230 | 233 |
info "${mydst##*/} updated."
|
| ... | ... |
@@ -234,10 +237,10 @@ do |
| 234 | 237 |
fi |
| 235 | 238 |
fi |
| 236 | 239 |
|
| 237 |
- if [[ -z $dry && -n "$mymod" && -n $(echo "$mymod" | sed -n "/[u,o,g,][+,-][r,w,x,s,t,S,T]/p") ]] |
|
| 240 |
+ if [[ -z $dry && -n "$mymod" && -n $(echo "$mymod" | sed -n "/[a,u,o,g,][+,-][r,w,x,s,t,S,T]/p") ]] |
|
| 238 | 241 |
then |
| 239 | 242 |
chmod "$mymod" "$mydst" |
| 240 |
- elif [[ -z $dry && -n "$mymod" && -z $(echo "$mymod" | sed -n "/[u,o,g,][+,-][r,w,x,s,t,S,T]/p") ]] |
|
| 243 |
+ elif [[ -z $dry && -n "$mymod" && -z $(echo "$mymod" | sed -n "/[a,u,o,g,][+,-][r,w,x,s,t,S,T]/p") ]] |
|
| 241 | 244 |
then |
| 242 | 245 |
warning "${mydst##*/}: Impossible to change permission, \"$mymod\" does not follow the syntax of the chmod command (see help)."
|
| 243 | 246 |
continue |