Browse code

git-sync.sh - v2.1 - Eval added and small updates

For more details, see version section of the script.

Fred authored on12/03/2015 23:46:56
Showing1 changed files
... ...
@@ -1,9 +1,9 @@
1 1
 #!/bin/bash
2 2
 # Title: git-sync.sh
3
-# Version: 2.0
3
+# Version: 2.1
4 4
 # Author: Frédéric CHEVALIER <fcheval@txbiomedgenetics.org>
5 5
 # Created in: 2014-09-03
6
-# Modified in: 2015-02-27
6
+# Modified in: 2015-03-12
7 7
 # Licence: GPL v3
8 8
 
9 9
 
... ...
@@ -12,7 +12,7 @@
12 12
 # Aims #
13 13
 #======#
14 14
 
15
-aim="Synchronize files from git server (master branch) on this terminal."
15
+aim="Synchronize files from a git server on this terminal."
16 16
 
17 17
 
18 18
 
... ...
@@ -20,6 +20,7 @@ aim="Synchronize files from git server (master branch) on this terminal."
20 20
 # Versions #
21 21
 #==========#
22 22
 
23
+# 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
23 24
 # 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
24 25
 # v1.3 - 2014-12-04: warning and error functions improved
25 26
 # v1.2 - 2014-09-24: temp file bug corrected / check if local file exist
... ...
@@ -46,7 +47,7 @@ function test_dep {
46 47
 # Usage message
47 48
 function usage {
48 49
     echo -e "
49
-    \e[32m${0##*/}\e[00m -l|--list list -d|--dry-run -h|--help
50
+    \e[32m${0##*/}\e[00m -l|--list file -d|--dry-run -h|--help
50 51
 
51 52
 Aim: $aim
52 53
 
... ...
@@ -163,9 +164,9 @@ while read line
163 164
 do
164 165
 
165 166
     # Get paths
166
-    mysrc=$(echo "$line" | cut -d ";" -f 1 | sed -e "s/^ *//" -e "s/ *$//")
167
-    mydst=$(echo "$line" | cut -d ";" -f 2 | sed -e "s/^ *//" -e "s/ *$//")
168
-    mymod=$(echo "$line" | cut -d ";" -f 3 | sed -e "s/^ *//" -e "s/ *$//")
167
+    eval mysrc=$(echo "$line" | cut -d ";" -f 1 | sed -e "s/^ *//" -e "s/ *$//")
168
+    eval mydst=$(echo "$line" | cut -d ";" -f 2 | sed -e "s/^ *//" -e "s/ *$//")
169
+    eval mymod=$(echo "$line" | cut -d ";" -f 3 | sed -e "s/^ *//" -e "s/ *$//")
169 170
 
170 171
     mydst_tmp="/tmp/${mydst##*/}"
171 172
 
... ...
@@ -177,8 +178,8 @@ do
177 178
         continue
178 179
     elif [[ $(echo "$mydst" | grep "/") && ! -d "${mydst%/*}" ]]
179 180
     then
180
-        info "${mydst##*/}: ${mydst%/*} directory created."
181
-        mkdir "${mydst%/*}"
181
+        warning "${mydst##*/}: ${mydst%/*} directory does not exist. Skipping..."
182
+        continue
182 183
     fi
183 184
 
184 185
     # Check if remote path is http