-
Notifications
You must be signed in to change notification settings - Fork 10
/
update.sh
executable file
·74 lines (61 loc) · 2.4 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
set -e
if test -z "$1"; then
echo "Missing branch as first argument"
exit 1
fi
if ! test -d "$1"; then
echo "Cannot find $1 dedicated directory"
exit 1
fi
cd "$1"
HAPROXY_BRANCH="$1"
DOCKERFILE="Dockerfile"
HAPROXY_SRC_URL="http://www.haproxy.org/download"
if ! test -f "$DOCKERFILE"; then
echo "Cannot find $DOCKERFILE"
exit 1
fi
HAPROXY_MINOR=$(curl -sfSL "${HAPROXY_SRC_URL}/${HAPROXY_BRANCH}/src/" 2>/dev/null | \
grep -o "<a href=\"haproxy-${HAPROXY_BRANCH}.*\.tar\.gz\">" | \
sed -r -e 's!.*"haproxy-([^"/]+)\.tar\.gz".*!\1!' | sort -r -V | head -1)
HAPROXY_SHA256=$(curl -sfSL "${HAPROXY_SRC_URL}/${HAPROXY_BRANCH}/src/haproxy-${HAPROXY_MINOR}.tar.gz.sha256" 2>/dev/null | \
awk '{print $1}')
if [ -z "${HAPROXY_MINOR}" ]; then
HAPROXY_MINOR=$(curl -sfSL "${HAPROXY_SRC_URL}/${HAPROXY_BRANCH}/src/devel/" 2>/dev/null | \
grep -o "<a href=\"haproxy-${HAPROXY_BRANCH}.*\.tar\.gz\">" | \
sed -r -e 's!.*"haproxy-([^"/]+)\.tar\.gz".*!\1!' | sort -r -V | head -1)
HAPROXY_SHA256=$(curl -sfSL "${HAPROXY_SRC_URL}/${HAPROXY_BRANCH}/src/devel/haproxy-${HAPROXY_MINOR}.tar.gz.sha256" | \
awk '{print $1}')
fi
if [ -z "${HAPROXY_MINOR}" ]; then
echo "Could not identify latest HAProxy release for ${HAPROXY_BRANCH} branch"
exit 1
fi
if [ -z "${HAPROXY_SHA256}" ]; then
echo "Could not get SHA256 for HAProxy release ${HAPROXY_MINOR}"
exit 1
fi
DATAPLANE_SRC_URL="https://api.github.com/repos/haproxytech/dataplaneapi/releases/latest"
DATAPLANE_MINOR=$(curl -sfSL "$DATAPLANE_SRC_URL" | \
grep '"tag_name":' | \
sed -E 's/.*"v?([^"]+)".*/\1/')
if [ -z "${DATAPLANE_MINOR}" ]; then
echo "Could not identify latest HAProxy Dataplane release"
exit 1
fi
DATAPLANE_SRC_URL="https://api.github.com/repos/haproxytech/dataplaneapi/releases"
DATAPLANE_V2_MINOR=$(curl -sfSL "$DATAPLANE_SRC_URL" | \
grep '"tag_name":.*"v2' | \
sed -E 's/.*"v?([^"]+)".*/\1/' | \
sort -V | \
tail -1
)
sed -r -i -e "s!^(ENV HAPROXY_SRC_URL) .*!\1 ${HAPROXY_SRC_URL}!;
s!^(ENV HAPROXY_BRANCH) .*!\1 ${HAPROXY_BRANCH}!;
s!^(ENV HAPROXY_MINOR) .*!\1 ${HAPROXY_MINOR}!;
s!^(LABEL Version) .*!\1 ${HAPROXY_MINOR}!;
s!^(ENV HAPROXY_SHA256) .*!\1 ${HAPROXY_SHA256}!
s!^(ENV DATAPLANE_MINOR) .*!\1 ${DATAPLANE_MINOR}!
s!^(ENV DATAPLANE_V2_MINOR) .*!\1 ${DATAPLANE_V2_MINOR}!" \
"$DOCKERFILE"