-
Notifications
You must be signed in to change notification settings - Fork 0
/
manipulate-images
executable file
·75 lines (66 loc) · 1.86 KB
/
manipulate-images
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
#! /usr/bin/env bash
# build, remove and (re|tag) images.
# author: João Paulo Júnior
# email: [email protected]
# github: github.com/ojpojao
USERNAME="ojpojao"
GITHASH=$(git log --format="%h" -n1)
ENGINE=""
function has_container_engine() {
for engine in docker podman
do
if [[ ! $(command -v ${engine}) ]]; then
echo "${engine} não está instalado"
else
echo "${engine} instalado"
ENGINE=${engine}
fi
done
if [[ -z ${ENGINE} ]]; then
echo "Não há nenhuma container engine no seu sistema!"
exit 1
fi
}
function build(){
for module in cwmp fs nbi ui
do
#${ENGINE} build -f ./Containerfiles/genieacs-${module}/Containerfile -t ${USERNAME}/genieacs-${module}:${GITHASH} .
${ENGINE} build -f ./Containerfiles/genieacs-${module}/Containerfile -t ${USERNAME}/genieacs-${module}:latest .
done
}
function remove(){
for module in cwmp fs nbi ui
do
#${ENGINE} image rm -f ${USERNAME}/genieacs-${module}:${GITHASH}
${ENGINE} image rm -f ${USERNAME}/genieacs-${module}:latest
done
}
#function release(){
# for module in cwmp fs nbi ui
# do
# ${ENGINE} tag ${USERNAME}/genieacs-${module}:${GITHASH} ${USERNAME}/genieacs-${module}:latest
# done
#}
function help(){
echo "
options:
build -> to create container image
remove -> to delete all container images
help -> this message
"
#echo"
#options:
# build -> to create container image
# remove -> to delete all container images
# release -> tag container image to latest release
# help -> this message
#"
}
function execute(){
#if [ $1 = "build" ] || [ $1 = "remove" ] || [ $1 = "release" ]; then
if [ $1 = "build" ] || [ $1 = "remove" ]; then
has_container_engine
fi
$1
}
execute $1