Skip to content

Commit dfa9698

Browse files
authored
Publish Version 0.1
0 parents  commit dfa9698

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

ssh-sync

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/sh
2+
3+
local=$(echo $1 | cut -f 1 -d ",")
4+
remote=$(echo $1 | cut -f 2 -d ",")
5+
6+
tmp=/tmp/${$}-scp-sync
7+
mkdir tmp
8+
scp -pr $2:$remote $tmp
9+
10+
sync() {
11+
12+
contents=$(ls -F $1)
13+
14+
for i in $contents; do
15+
16+
if [[ $(echo $i | grep "/$") != "" ]]; then
17+
18+
sync $1/$i $2/$i $3
19+
20+
else
21+
22+
files=$(echo "$files $i" | sed "s/\*$//")
23+
24+
fi
25+
26+
done
27+
28+
29+
for i in $files; do
30+
31+
( test ${1}/${i} -nt ${tmp}/${i} &&
32+
scp -p ${1}/${i} ${3}:${2}/${i} ) ||
33+
( test ${1}/${i} -ot ${tmp}/${i} &&
34+
mv ${tmp}/${i} ${1}/${i} )
35+
36+
done
37+
38+
}
39+
40+
sync $local $remote $2

0 commit comments

Comments
 (0)