-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_rteqc
More file actions
executable file
·111 lines (85 loc) · 3.13 KB
/
Copy pathrun_rteqc
File metadata and controls
executable file
·111 lines (85 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
#!/bin/bash
HOSTNAME="$(hostname)"
EVENT="2014p051675"
DBDUR="730"
function usage(){
cat <<EOF
Usage: $0 [Options]
Build or run RTEQcorrscan RCET images.
Optional Arguments:
-h, --help Show this message.
-b, --build Build the containers.
-s, --sim Run a simulation.
-e, --eventid Event ID for simulation (default $EVENT).
-d, --db-duration DB duration (days) for simulation (default $DBDUR)
-c, --clean Clean old containers.
-r, --run Run the real-time system.
-t, --trigger [trigger-id]
Trigger the running system on an old event.
--stop [trigger-id]
Stop the system for a given trigger ID
EOF
}
if [[ $# -eq 0 ]] ; then
usage
exit 1
fi
while [ $# -gt 0 ]
do
case "$1" in
-h | --help) usage; exit 0;;
-b | --build) BUILD=true;;
-s | --sim) SIM=true;;
-e | --eventid) EVENT=$2;shift;;
-r | --run) RUN=true;;
-c | --clean) CLEAN=true;;
-d | --db-duration) DBDUR=$2;shift;;
-t | --trigger) TRIGGER=true; TRIGGER_EVENTID=$2;shift;;
--stop) STOP=true; TRIGGER_EVENTID=$2;shift;;
-*) echo "Unknown args: $1"; usage; exit 1;;
esac
shift
done
if [ "${CLEAN}" == "true" ]; then
echo "Cleaning"
if [ "${SIM}" == "true" ]; then
TRIGGER_ID=${EVENT} DB_LEN=${DBDUR} docker compose -f compositions/simulation-docker-compose.yml --env-file env_files/${HOSTNAME}_sim.env down
else
docker compose -f compositions/docker-compose.yml --env-file env_files/${HOSTNAME}_rt.env down
fi
exit 0
fi
if [ "${BUILD}" == "true" ]; then
echo "Building for ${HOSTNAME}"
if [ "${SIM}" == "true" ]; then
TRIGGER_ID=${EVENT} DB_LEN=${DBDUR} docker compose -f compositions/simulation-docker-compose.yml --env-file env_files/${HOSTNAME}_sim.env build
else
docker compose -f compositions/docker-compose.yml --env-file env_files/${HOSTNAME}_rt.env build
fi
exit 0
fi
if [ "${SIM}" == "true" ]; then
if [ "${RUN}" == "true" ]; then
echo "Cannot run and simulate"
exit 1
fi
echo "Running simulation for ${EVENT}"
TRIGGER_ID=${EVENT} DB_LEN=${DBDUR} docker compose -f compositions/simulation-docker-compose.yml --env-file env_files/${HOSTNAME}_sim.env up -d
exit 0
fi
if [ "${RUN}" == "true" ]; then
echo "Running real-time"
docker compose -f compositions/docker-compose.yml --env-file env_files/${HOSTNAME}_rt.env up
exit 0
fi
if [ "${TRIGGER}" == "true" ]; then
echo "Triggering on event ${TRIGGER_EVENTID}"
docker exec -it rteqc-real-time sh -c "curl https://service.geonet.org.nz/fdsnws/event/1/query?eventid=${TRIGGER_EVENTID} -o /tmp/outputs/detections/manual_triggers/${TRIGGER_EVENTID}.xml"
exit 0
fi
if [ "${STOP}" == "true" ]; then
echo "Stopping event ${TRIGGER_EVENTID}"
docker exec -it rteqc-real-time sh -c "touch /tmp/outputs/detections/${TRIGGER_EVENTID}/kill_${TRIGGER_EVENTID}"
docker exec -it rteqc-real-time sh -c "touch /tmp/outputs/detections/${TRIGGER_EVENTID}/.stopfile"
exit 0
fi