-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjust.sh
executable file
·48 lines (48 loc) · 1.03 KB
/
just.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
#!/bin/bash
start_container(){
names=$(docker ps -a | grep $1 | gawk '{print $1}')
if [ ! -n "$names" ]
then
echo "There is no container $1."
else
docker start $names
if [ $1==="hadoop-master" ]
then
docker exec -it hadoop-master /bin/bash -c "start-all.sh && service mysql start"
docker exec -it hadoop-master /bin/bash
fi
fi
}
stop_container(){
names=$(docker ps | grep $1 | gawk '{print $1}')
echo $name
if [ -z "$names" ]
then
echo "There is no running containers."
else
docker stop $names
fi
echo ""
}
lists=("hadoop-slave1" "hadoop-slave2" "hadoop-master")
# for list in ${lists[@]}
# do
# echo $list
# start_container $list
# done
case $1 in
start)
for list in ${lists[@]}
do
echo $list
start_container $list
done
;;
stop)
for list in ${lists[@]}
do
echo $list
stop_container $list
done
;;
esac