forked from coreruleset/modsecurity-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion.sh
More file actions
executable file
·36 lines (33 loc) · 788 Bytes
/
version.sh
File metadata and controls
executable file
·36 lines (33 loc) · 788 Bytes
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
#!/bin/sh
#
# Expects a semver "MODSEC_VERSION=version" in a Dockerfile,
# parses it into <major>.<minor>.<patch>
#
TARGET="${1%%/}"
TYPE="$2"
# Variant allows us to generate variants like '-alpine'
VARIANT="$3"
[ -z "$TARGET" ] && {
echo "Usage: $0 <directory> [-v|-vv|-vvv|-vvvv]"
exit 1
}
version=$(grep -m1 "ARG MODSEC_VERSION" "$TARGET/Dockerfile${VARIANT}" | cut -f2 -d=)
major="${version%%.*}"
patch="${version##*.}"
nomaj="${version#$major.}"
minor="${nomaj%.$patch}"
humanized="${TARGET#*-}"
variant="${VARIANT}"
case "$TYPE" in
-v)
echo "${major}${variant}"
;;
-vv)
echo "${major}.${minor}${variant}"
;;
-vvv)
echo "${major}.${minor}.${patch}${variant}"
;;
*)
echo "${humanized}${variant}"
esac