generated from Kong/template-github-release
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·65 lines (54 loc) · 1.59 KB
/
build.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
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
set -eo pipefail
if [ -n "${DEBUG:-}" ]; then
set -x
fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export $(grep -v '^#' $SCRIPT_DIR/.env | xargs)
function main() {
echo '--- installing openssl ---'
mkdir -p /tmp/build
with_backoff curl --fail -sSLo openssl.tar.gz "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"
tar -xzvf openssl.tar.gz
pushd openssl-${OPENSSL_VERSION}
eval ./config \
-g shared \
-DPURIFY no-threads \
--prefix=/usr/local/kong \
--openssldir=/usr/local/kong no-unit-test '-Wl,-rpath,'\''$(LIBRPATH)'\'',--enable-new-dtags' && \
make -j2 && \
make install_sw DESTDIR=/tmp/build
popd
echo '--- installed openssl ---'
}
# Retries a command a configurable number of times with backoff.
#
# The retry count is given by ATTEMPTS (default 5), the initial backoff
# timeout is given by TIMEOUT in seconds (default 1.)
#
# Successive backoffs double the timeout.
function with_backoff {
local max_attempts=${ATTEMPTS-5}
local timeout=${TIMEOUT-5}
local attempt=1
local exitCode=0
while (( $attempt < $max_attempts ))
do
if "$@"
then
return 0
else
exitCode=$?
fi
echo "Failure! Retrying in $timeout.." 1>&2
sleep $timeout
attempt=$(( attempt + 1 ))
timeout=$(( timeout * 2 ))
done
if [[ $exitCode != 0 ]]
then
echo "You've failed me for the last time! ($@)" 1>&2
fi
return $exitCode
}
main