-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjust-exe.sh
executable file
·50 lines (50 loc) · 1.1 KB
/
just-exe.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
#!/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-spark-master" ]
then
docker exec -it hadoop-spark-master /bin/bash -c "start-all.sh && service mysql start"
docker exec -it hadoop-spark-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-spark-slave1" "hadoop-spark-slave2" "hadoop-spark-master")
# for list in ${lists[@]}
# do
# if [ $list = "hadoop-master" ]
# then
# echo $list
# fi
# 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