-
Notifications
You must be signed in to change notification settings - Fork 0
/
override.sh
executable file
·50 lines (40 loc) · 1.2 KB
/
override.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
#!/bin/sh
upload() {
destination=$1
payload=$2
private_key_file=$(mktemp /tmp/private-key-file.XXXXXX)
cat <<EOF > $private_key_file
$(jq -r '.source.private_key // ""' < $payload)
EOF
args="-privateKey=${private_key_file}"
email=$(jq -r '.source.email // ""' < $payload)
if [ ! -z "${email}" ]; then
args="${args} -email=${email}"
fi
bucket=$(jq -r '.source.bucket // ""' < $payload)
if [ ! -z "${bucket}" ]; then
args="${args} -bucket=${bucket}"
fi
prefix=$(jq -r '.params.prefix // ""' < $payload)
if [ ! -z "${prefix}" ]; then
args="${args} -prefix=${prefix}"
else
prefix=$(jq -r '.source.prefix // ""' < $payload)
if [ ! -z "${prefix}" ]; then
args="${args} -prefix=${prefix}"
fi
fi
public=$(jq -r '.params.public // ""' < $payload)
if [ ! -z "${public}" ]; then
args="${args} -public=${public}"
fi
dir=$(jq -r '.params.dir // ""' < $payload)
if [ ! -z "${dir}" ]; then
args="${args} ${dir}"
fi
pwd=$(jq -r '.params.pwd // ""' < $payload)
if [ -n "$pwd" ]; then
cd $pwd
fi
eval /opt/bin/gstore ${args}
}