-
Notifications
You must be signed in to change notification settings - Fork 0
/
qd_generate_dockerfile.sh
executable file
·52 lines (40 loc) · 1.5 KB
/
qd_generate_dockerfile.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
#! /bin/bash
## AIMS : Generate a dockerfile based on theDockerfile.template
## USAGE : qd_generate_dockerfile.sh prog version
## NOTE : Dockerfile still need to be completed.
## NOTE : if Dockerfile already exists, it will be moved to a .bk file.
## AUTHORS : sletort@irisa.fr
set -o nounset
set -o errexit
# =========================================================
declare -r PROG="${1?What is your program name ?}"
declare -r VERSION="${2?What is the version of the program ?}"
# ---------------------------------------------------------
# =========================================================
function printVars ()
{
printf "╔═══════════════════════════════════ ═ ═ ═ ═\n"
printf "╟ - SCRIPT = $0\n"
printf "╟ - PROG = $PROG\n"
printf "╟ - VERSION = $VERSION\n"
printf "╚═══════════════════════════════════ ═ ═ ═ ═\n\n"
}
# =========================================================
function main ()
{
local -r OUTDIR="${PROG}/${VERSION}"
mkdir -p "$OUTDIR"
if [[ -e "$OUTDIR"/Dockerfile ]]
then
cp "$OUTDIR"/Dockerfile "$OUTDIR"/Dockerfile.bk
fi
local perle='s/XXXXX/'$PROG'/g;'
perle=$perle' s/VVVVV/'$VERSION'/g;'
perl -pe "$perle" Dockerfile.template > "$OUTDIR"/Dockerfile
}
# =========================================================
printVars
# your work.
main
#printf "End of %s.\n\n" $( basename $0 )
exit 0