forked from Stack-Box/stackbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack_box.sh
More file actions
62 lines (50 loc) · 1.28 KB
/
stack_box.sh
File metadata and controls
62 lines (50 loc) · 1.28 KB
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
#!/bin/bash
echo " _ _ _"
echo " ___| |_ __ _ ___| | _| |__ _____ __"
echo "/ __| __/ _ |/ __| |/ / '_ \ / _ \ \/ /"
echo "\__ \ || (_| | (__| <| |_) | (_) > <"
echo '|___/\__\__,_|\___|_|\_\_.__/ \___/_/\_\'
echo "\n"
args="$*"
beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
python_version=$(python --version)
python3_version=$(python3 --version)
if beginswith "Python 3" "$python_version" ;
then
python stack.py $args
elif beginswith "Python 3" "$python3_version";
then
python3 stack.py $args
else
echo "Unable to find a python 3 installation"
fi
docker-compose down > logs/docker-compose-down-log.txt
echo "\n"
docker-compose build > logs/docker-compose-build-log.txt
echo "\n"
docker-compose up -d --remove-orphans
containers=$(docker ps --format '{{.Names}}')
ports="$(docker ps --format '{{.Ports}}')"
service_ports=()
for port in $ports;
do
if beginswith "0.0.0.0" "$port";
then
port1=$(echo "$port" | awk -F[:-] '{print $2}')
service_ports+=("$port1")
fi
done
i=-1
echo "\n"
for container in $containers;
do
i=$i+1
if [ "$container" != "registry" ];
then
if beginswith "stackbox" "$container";
then
tmp=${container%"_1"}
echo ${tmp#"stackbox_"} is up at http://localhost:${service_ports[i]}
fi
fi
done