forked from GRIDAPPSD/gridappsd-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstop.sh
executable file
·97 lines (81 loc) · 2.15 KB
/
stop.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
#!/bin/bash
usage () {
/bin/echo "Usage: $0 [-c|w]"
/bin/echo " -c remove containers and downloaded dump files and mysql database"
/bin/echo " -w remove containers and mysql database, preserve downloaded dump files"
exit 2
}
clean_up () {
echo " "
echo "Removing docker containers"
docker-compose down
# remove the dump files if -c option
if [ $cleanup -eq 1 ]; then
if [ -f $data_dir/$mysql_file ] ; then
echo " "
echo "Removing mysql dump file"
rm "$data_dir/$mysql_file"
fi
# download may sometimes fail and create a directory
if [ -d $data_dir/$mysql_file ] ; then
echo " "
echo "Removing mysql dump file"
rmdir "$data_dir/$mysql_file"
fi
echo " "
for blazegraph_file in $blazegraph_models; do
if [ -f $data_dir/$blazegraph_file ] ; then
echo "Removing blazegraph import file $blazegraph_file"
rm "$data_dir/$blazegraph_file"
fi
# download may sometimes fail and create a directory
if [ -d $data_dir/$blazegraph_file ] ; then
echo " "
echo "Removing blazegraph import file $blazegraph_file"
rmdir "$data_dir/$blazegraph_file"
fi
done
fi
if [ -f .env ] ; then
echo " "
echo "Removing the docker .env file"
rm .env
fi
if [ -d gridappsdmysql ] ; then
echo " "
if [ -O gridappsdmysql ] ; then
echo "Removing mysql database files"
rm -r gridappsdmysql
else
echo "Error: unable to remove gridappsdmysql, please run the following command."
echo "sudo rm -r gridappsdmysql"
fi
fi
}
blazegraph_models="EPRI_DPV_J1.xml IEEE123.xml R2_12_47_2.xml ieee8500.xml"
mysql_file="gridappsd_mysql_dump.sql"
data_dir="dumps"
cleanup=0
# parse options
while getopts cw option ; do
case $option in
c) # Cleanup downloads and containers and dump files
cleanup=1
;;
w) # Cleanup downloads and containers
cleanup=2
;;
*) # Print Usage
usage
;;
esac
done
shift `expr $OPTIND - 1`
echo " "
echo "Shutting down the docker containers"
docker-compose stop
if [ $cleanup -gt 0 ]; then
clean_up
fi
echo " "
exit 0