1 |
9800
|
aaronmk
|
#!/bin/bash -e
|
2 |
|
|
. "$(dirname "${BASH_SOURCE[0]}")"/util.sh
|
3 |
|
|
|
4 |
|
|
if self_not_included; then
|
5 |
|
|
|
6 |
|
|
alias use_sync='declare prefix=sync_; import_vars; unset prefix'
|
7 |
|
|
|
8 |
9889
|
aaronmk
|
upload() # usage: local_dir=... remote_url=server:dir upload [opt|path]...
|
9 |
9800
|
aaronmk
|
# requires put from https://uutils.googlecode.com/svn/trunk/bin/put
|
10 |
|
|
{
|
11 |
9893
|
aaronmk
|
echo_func; kw_params local_dir remote_url; echo_vars swap
|
12 |
9800
|
aaronmk
|
|
13 |
9889
|
aaronmk
|
# change path args to --includes
|
14 |
9890
|
aaronmk
|
local has_includes= args=()
|
15 |
9889
|
aaronmk
|
local a; for a in "$@"; do
|
16 |
|
|
if starts_with -- "$a"; then args+=("$a") # option, so leave as is
|
17 |
|
|
else # path
|
18 |
|
|
# also need to --include parent dirs for each --include path
|
19 |
|
|
path_parents "$(base_dir="$local_dir" canon_rel_path "$a")"
|
20 |
|
|
args+=("${dirs[@]/#/--include=/}") # prepend each with --include=/
|
21 |
9890
|
aaronmk
|
has_includes=1
|
22 |
9889
|
aaronmk
|
fi
|
23 |
|
|
done
|
24 |
9890
|
aaronmk
|
set -- "${args[@]}" ${has_includes:+--exclude="**"}
|
25 |
9811
|
aaronmk
|
|
26 |
9890
|
aaronmk
|
src="$local_dir" dest="$remote_url" command put "$@"
|
27 |
9800
|
aaronmk
|
}
|
28 |
|
|
|
29 |
|
|
fi
|