-
Notifications
You must be signed in to change notification settings - Fork 5
/
update.sh
executable file
·57 lines (52 loc) · 1.12 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
local=.
remote="[email protected]:~/Trill_SC"
dryrun=1
lineargs1="-auz"
lineargs2="-e ssh --exclude .git --exclude .gitignore --exclude build --exclude .DS_Store --progress"
# argument parsing
PARAMS=""
while (( "$#" )); do
case "$1" in
--) # end argument parsing
shift
break
;;
--remote|-r)
# Remote directory
remote=$2
shift 2
;;
--nodry|-n)
# Not doing a dry run!
dryrun=0
shift
;;
push|pull)
action=$1
shift
;;
*) # preserve positional arguments
echo "Error: Unsupported argument $1" >&2
exit 1
;;
esac
done
if [ "$action" == "push" ]; then
src=$local
dest=$remote
lineargs2=$lineargs2" --delete" # delete files on push, but not on pull
elif [ "$action" == "pull" ]; then
src=$remote
dest=$local
else
echo "SYNTAX ERROR: expecting './update.sh push|pull --nodry? -r REMOTEPATH'"
exit 1
fi
if [ $dryrun -eq 1 ]; then
# dry run by default unless --nodry flag is specified
lineargs1=$lineargs1"vni"
fi
cmdargs="$lineargs1 $lineargs2 $src/ $dest"
rsync $cmdargs
echo "rsync $cmdargs"