forked from SonarSource/docker-sonarqube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·49 lines (43 loc) · 1 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
#!/bin/bash
# Enable globstar for Searching recursively
shopt -s globstar
# Reset the Option Index in case getopts has been used previously in the same shell.
OPTIND=1
function show_help() {
echo "update.sh help"
echo ""
echo "This Script will update a given Version in all Dockerfiles present under the current directory"
echo "If the old version can not be found, it does nothing"
echo ""
echo "usage:"
echo "update.sh <old version> <new version>"
echo ""
echo "example:"
echo "update.sh -o 8.9.1.44547 -n 9.0.0.12345"
exit 0
}
##########
## Main ##
##########
OLD_VERSION=""
NEW_VERSION=""
while getopts ":h:o:n:" o; do
case "${o}" in
o)
OLD_VERSION=${OPTARG}
;;
n)
NEW_VERSION=${OPTARG}
;;
h)
show_help
;;
*)
show_help
;;
esac
done
shift $((OPTIND-1))
for i in ./**/Dockerfile; do
sed -i "s/${OLD_VERSION}/${NEW_VERSION}/g" $i
done