-
Notifications
You must be signed in to change notification settings - Fork 128
/
deploy.sh
executable file
·71 lines (56 loc) · 1.46 KB
/
deploy.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
#!/bin/bash
set -e
SCRIPT_PATH=$(dirname ${BASH_SOURCE[0]})
source $SCRIPT_PATH/base.sh
DEPLOY_TYPE="$1"
if [[ -z "$DEPLOY_TYPE" ]] || [[ "$DEPLOY_TYPE" != "simple" && "$DEPLOY_TYPE" != "simple-report" && "$DEPLOY_TYPE" != "full" ]]; then
echo "ERROR - Usage: $0 <simple|full>"
exit 1
fi
if [ "$DEPLOY_TYPE" = "simple" ]; then
COMPLETE=0
REPORT=0
elif [ "$DEPLOY_TYPE" = "simple-report" ]; then
COMPLETE=0
REPORT=1
elif [ "$DEPLOY_TYPE" = "full" ]; then
COMPLETE=1
REPORT=1
fi
function upload_table_file() {
table=$1
log "[$table] Copying data to static file server"
s3cmd put data/output/${table}.csv.gz s3://dataset/$DATASET/${table}.csv.gz
}
function update_table() {
table=$1
log "[$table] Executing update command"
ssh $BRASILIO_SSH_USER@$BRASILIO_SSH_SERVER "$BRASILIO_UPDATE_COMMAND $DATASET $table"
}
function update_dataset_list() {
dataset=$1
log "[$dataset] Executing update file list"
ssh $BRASILIO_SSH_USER@$BRASILIO_SSH_SERVER "$BRASILIO_UPDATE_FILE_LIST_COMMAND $DATASET"
}
log "Cleaning data path and collecting data"
if [ "$COMPLETE" = "1" ]; then
./run-obitos.sh
fi
./run.sh
source $SCRIPT_PATH/.env
if [ "$COMPLETE" = "1" ]; then
for table in boletim caso caso_full obito_cartorio; do
upload_table_file $table
update_table $table
done
else
for table in boletim caso caso_full; do
upload_table_file $table
update_table $table
done
fi
update_dataset_list "covid19"
time python ocupacao.py
if [ "$REPORT" = "1" ]; then
./report.sh
fi