forked from dm-academy/Calavera
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalavera.build.sh
executable file
·61 lines (56 loc) · 1.35 KB
/
calavera.build.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
#!/bin/bash
BASE=`dirname $0`
NIC="eth0"
name="dnsmasq"
export MY_IP=$(ifconfig $NIC | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}')
[ ! -d dnsmasq.hosts ] && mkdir dnsmasq.hosts
[ -e dnsmasq.hosts/calavera ] && rm dnsmasq.hosts/calavera
$BASE/setns.sh
echo "$MY_IP "`hostname`" "`hostname -f` > dnsmasq.hosts/myself
echo "-- Destroying current environment"
docker ps -a --filter "name=dnsmasq" |grep dnsmasq > /dev/null 2>&1
if [ $? -eq "0" ]
then
echo -n " -- Removing dnsmasq container :"
docker stop dnsmasq > /dev/null
docker rm dnsmasq > /dev/null
echo "Ok"
fi
# Start dnsmasq server
echo -n " -- Starting dnsmasq container :"
docker run -v="$(pwd)/dnsmasq.hosts:/dnsmasq.hosts" --name=${name} -p=${MY_IP}':53:5353/udp' -d sroegner/dnsmasq > /tmp/out 2>&1
if [ $? -ne 0 ]
then
echo "Error"
cat /tmp/out
exit 1
else
echo "Ok"
fi
docker kill -s HUP dnsmasq
echo -n " -- Stopping all running nodes :"
vagrant halt -f > /tmp/out 2>&1
if [ $? -ne 0 ]
then
echo "Error"
cat /tmp/out
exit 1
else
echo "Ok"
fi
echo -n " -- Removing all nodes :"
vagrant destroy -f > /tmp/out 2>&1
if [ $? -ne 0 ]
then
echo "Error"
cat /tmp/out
exit 1
else
echo "Ok"
fi
#[ -d .vagrant ] && rm -rf .vagrant
echo "-- Re-creating the environment"
for NODE in cerebro brazos hombros espina manos cara
do
./calavera.up.sh ${NODE}
done