-
Notifications
You must be signed in to change notification settings - Fork 0
/
lin-docker.sh
146 lines (132 loc) · 4.64 KB
/
lin-docker.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
#
# Use: lin-docker.sh [command] [Password] [Docker-Hub release]
# Put AuditTool in a Docker architecture
#
#./lin-docker.sh -u [Password Active Directory] [Docker-Hub release]
#./lin-dcoker.sh -b [Docker-Hub release]
#./lin-dcoker.sh -p [Password Docker-Hub]
#./lin-dcoker.sh -m [Password Active Directory]
#
# Possible commands:
#
# -h, --help Help
# -m, --meteor Launch meteor, without Docker, for testing [Password Active Directory]
# -b, --build Build audittool docker image [New Docker-Hub release]
# -p, --push Push audittool image to Docker Hub [Password Docker Hub] [Docker release]
# -u, --dockerup Docker-compose up [Password Active Directory] [Docker release]
# -d, --delete Delete all (containers, images, volumes, networks)
# -s, --stop docker-compose stop, useful when containers are started like service/ademon
#
# Useful command for ubuntu 17: newgrp docker
#
# Useful command for bash to containet: docker exec -ti <container> bash
while [[ $# -gt 0 ]]
do
key="$1"
passwd="$2"
release="$3"
statusJreport=`curl -s --head http://localhost:5488 | head -n 1 | grep "HTTP/1.[01] [23].."`
case $key in
-d|--delete)
echo "Delete All"
echo "Ferma tutti i containers"
docker-compose down
echo "Elimina tutti i containers"
docker rm $(docker container ls -a -q) -f
echo "Elimina tutti i volumi"
docker volume prune -f
echo "Elimina tutte le immagini"
docker rmi $(docker images -a -q)
shift # past argument
shift # past argument
;;
-b|--build)
echo "build"
# cd ~/AuditTool
if [ ! -f ~/AuditTool/.gitignore ]; then
echo ".gitignore not found!"
else
rm .gitignore
fi
rm -rf .git
rm -fR AuditTool
wget http://www.meteorkitchen.com/api/getapp/json/Tqq4JcxsuGEBZrben -O AuditTool.json
meteor-kitchen AuditTool.json AuditTool
cd AuditTool
cp ../docker/Dockerfile .
cp ../docker/.dockerignore .
export TAG=$passwd && docker-compose -f ../docker/docker-compose-dev.yml build --force-rm --no-cache
shift # past argument
shift # past argument
exit 1
;;
-m|--meteor)
echo "meteor"
# cd ~/AuditTool
if [ -z "$statusJreport" ]; then
echo 'Jsreport not installed: no pdf reports !' >&2
else
echo 'Jsreport found !'
fi
if [ ! -f ~/AuditTool/.gitignore ]; then
echo ".gitignore not found!"
else
rm .gitignore
fi
rm -rf .git
rm -fR AuditTool
wget http://www.meteorkitchen.com/api/getapp/json/Tqq4JcxsuGEBZrben -O AuditTool.json
meteor-kitchen AuditTool.json AuditTool
cd AuditTool
meteor
shift # past argument
shift # past argument
;;
-p|--push)
echo "Push image to Docker Hub"
docker login -password $passwd -username mttstt
docker push mttstt/audittool
shift # past argument
shift # past argument
;;
-u|--dockerup)
echo "Docker up like a service (-d)"
export TAG=$release && export passwdAD=$passwd && docker-compose -f docker/docker-compose.yml up -d
exit 1
shift # past argument
shift # past argument
;;
-s|--stop)
echo "Stopping AuditTool container daemon"
docker-compose -f docker/docker-compose.yml stop
shift # past argument
shift # past argument
;;
-b|--bye)
echo "bye"
echo "bye"
shift # past argument
shift # past argument
;;
*) # unknown option
echo "Use: lin-docker.sh [command] [Password] [Docker HUB release]"
echo "Put AuditTool in a Docker architecture"
echo ""
echo "./lin-docker.sh -u [Password Active Directory] [Docker-Hub release]"
echo "./lin-dcoker.sh -b [New Docker-Hub release]"
echo "./lin-dcoker.sh -p [Password Docker-Hub]"
echo ""
echo "Possible commands:"
echo ""
echo "-h, --help Help"
echo "-m, --meteor Launch meteor, without Docker (for testing) [Password Active Directory]"
echo "-b, --build Build audittool docker image [New Docker-Hub release]"
echo "-p, --push Push audittool image to Docker Hub [Password Docker Hub] [Docker-Hub release]"
echo "-u, --dockerup Docker-compose up [Password Active Directory] [DockerHub release]"
echo "-d, --delete Delete all (containers, images, volumes, networks)"
echo "-s, --stop Stop Audittol container daemon"
shift # past argument# Options:
;;
esac
done