blob: d3aad43f367078c5fe4f72978e5f52a154de339b (
plain)
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
|
#!/bin/bash
# We want to catch any command failure, and exit immediately
set -e
# Download helper for scp
# Call it with:
# $1: URL
# $2: output file
# And this environment:
# SCP : the scp command to call
url="${1}"
output="${2}"
tmp_dl="$( mktemp "${BUILD_DIR}/.XXXXXX" )"
tmp_output="$( mktemp "${output}.XXXXXX" )"
ret=1
if ${SCP} "${url}" "${tmp_dl}"; then
if mv "${tmp_dl}" "${tmp_output}"; then
mv "${tmp_output}" "${output}"
ret=0
fi
fi
# Cleanup
rm -f "${tmp_dl}" "${tmp_output}"
exit ${ret}
|