-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathstop.sh
More file actions
executable file
·134 lines (114 loc) · 3.13 KB
/
Copy pathstop.sh
File metadata and controls
executable file
·134 lines (114 loc) · 3.13 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# Source common utilities
source "$(dirname "$0")/utils.sh"
init_docker_compose
usage () {
/bin/echo "Usage: $0 [-c|w] [-s]"
/bin/echo " -c remove containers and downloaded dump files and mysql database"
/bin/echo " -s services only mode (stop services started with run.sh -s)"
/bin/echo " -w remove containers and mysql database, preserve downloaded dump files"
exit 2
}
clean_up () {
echo " "
echo "Removing docker containers"
$DOCKER_COMPOSE_CMD $compose_files 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
for blazegraph_file in $blazegraph_models; do
if [ -f $data_dir/$blazegraph_file ] ; then
echo " "
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 [ -f conf/viz.config ] ; then
echo " "
echo "Removing the remote viz configuration file"
rm conf/viz.config
fi
if [ -f docker-compose.d/viz.yml ] ; then
echo " "
echo "Removing the remote viz compose file"
rm docker-compose.d/viz.yml
fi
if [ -f docker-compose.d/no-autostart.yml ] ; then
echo " "
echo "Removing the no-autostart compose file"
rm docker-compose.d/no-autostart.yml
fi
for dbdir in $database_dirs; do
if [ -d $dbdir ] ; then
echo " "
if [ -O $dbdir ] ; then
echo "Removing $dbdir database files"
rm -r $dbdir
else
echo "Error: unable to remove $dbdir, please run the following command."
echo "sudo rm -r $dbdir"
fi
fi
done
}
blazegraph_models="EPRI_DPV_J1.xml IEEE123.xml R2_12_47_2.xml IEEE8500.xml ieee8500.xml"
mysql_file="$MYSQL_FILE"
data_dir="$DATA_DIR"
cleanup=0
services_only=0
database_dirs="gridappsdmysql gridappsd"
# parse options
while getopts csw option ; do
case $option in
c) # Cleanup downloads and containers and dump files
cleanup=1
;;
s) # Services only mode
services_only=1
;;
w) # Cleanup downloads and containers
cleanup=2
;;
*) # Print Usage
usage
;;
esac
done
# Set compose files based on mode
if [ $services_only -eq 1 ]; then
compose_files="-f docker-compose-services.yml"
else
compose_files=$(get_compose_files)
fi
echo "Compose files: $compose_files"
shift `expr $OPTIND - 1`
echo " "
echo "Shutting down the docker containers"
$DOCKER_COMPOSE_CMD $compose_files stop
if [ $cleanup -gt 0 ]; then
clean_up
fi
echo " "
exit 0