-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·98 lines (87 loc) · 3.06 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# shellcheck disable=SC2076
[ -f .settings ] && . .settings
while getopts ":f" option; do
case $option in
f)
force="1"
;;
*)
;;
esac
done
set -e
docker pull alpine:latest
alpine_layer="$(docker inspect --format '{{join .RootFS.Layers ""}}' alpine:latest)"
echo
images="$(grep "glider-" Dockerfile | awk '{print $NF}')"
#images="glider-openconnect "
to_build=""
if [ "${force}" = "1" ]; then
echo "Building forced"
to_build="${images}"
checkup="$(./updater_glider.sh 1)"
glider_url="$(grep 'file:' <<<"$checkup" | awk '{print $2}')"
glider_sum="$(grep 'chks:' <<<"$checkup" | awk '{print $2}')"
else
echo "GLIDER"
checkup="$(./updater_glider.sh 1)"
if [[ ! "${checkup}" =~ "Already" ]]; then
current_version="$(grep 'latest:' <<<"$checkup" | awk '{print $2}')"
for i in ${images}; do
image_version="$(docker run --rm -it --name tmp --entrypoint /glider asharlohmar/"${i}" --help | tr ',' ' ' | grep -E ' [0-9]+\.[0-9]+\.[0-9]+ ' | awk '{print $2}')"
if [[ ! "$image_version" =~ "$current_version" ]] && [[ ! " ${to_build} " =~ " ${i} " ]]; then
to_build="${to_build} ${i} "
fi
done
else
head -n 1 <<<"$checkup"
fi
glider_url="$(grep 'file:' <<<"$checkup" | awk '{print $2}')"
glider_sum="$(grep 'chks:' <<<"$checkup" | awk '{print $2}')"
echo
echo "FORTIVPN"
checkup="$(./updater_openfortivpn.sh 1)"
if [[ ! "${checkup}" =~ "Already" ]]; then
./updater_openfortivpn.sh
current_version="$(strings files_extra/openfortivpn | grep -E 'openfortivpn .*[0-9]' | awk '{print $2}' )"
for i in ${images}; do
if [[ "${i}" =~ fortivpn ]]; then
image_version="$(docker run --rm -it --name tmp --entrypoint /openfortivpn asharlohmar/"${i}" --version)"
if [[ ! "$image_version" =~ "$current_version" ]] && [[ ! " ${to_build} " =~ " ${i} " ]]; then
to_build="${to_build} ${i} "
fi
fi
done
else
echo "${checkup[*]}"
fi
echo
echo "ALPINE"
for i in ${images}; do
name="asharlohmar/${i%}"
if [ -z "$(docker images --format '{{.Repository}}' "${name}:latest")" ]; then
docker pull "${name}:latest" || true
fi
if docker inspect --format '{{.RootFS.Layers}}' "${name}" | grep -q "${alpine_layer}"; then
echo "${name} is at the latest alpine"
else
echo "${name} needs alpine update"
[[ ! " ${to_build} " =~ " ${i} " ]] && to_build="${to_build} ${i}"
fi
done
echo
fi
echo "BUILDING: ${to_build}"
tag="$(date "+%Y%m%d")"
for i in ${to_build}; do
name="asharlohmar/${i%}"
docker build \
--build-arg glider_url="${glider_url}" \
--build-arg glider_sum="${glider_sum}" \
--force-rm --rm --pull \
-t "${name}:latest" -t "${name}:${tag}" \
--target "${i}" .
done
[ -z "${to_build}" ] && echo "Nothing to build"
echo "Done"