forked from Botts-Innovative-Research/OSHConnect-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy_go_publishers.sh
More file actions
135 lines (115 loc) · 4.11 KB
/
deploy_go_publishers.sh
File metadata and controls
135 lines (115 loc) · 4.11 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
135
#!/bin/bash
# deploy_go_publishers.sh — Deploy updated publisher code and set up Go server publishers on VM
set -e
SRC=/tmp/OSHConnect-Python/publishers
HOME_DIR=/home/ubuntu
GO_URL="https://129-80-248-53.sslip.io/csapi-go"
echo "=== Updating existing publisher directories ==="
declare -A PUBS=(
[nws-publisher]=nws
[ndbc-publisher]=ndbc
[coops-publisher]=coops
[usgs-water-publisher]=usgs_water
[usgs-nims-publisher]=usgs_nims
[usgs-eq-publisher]=usgs_eq
)
for dir_name in "${!PUBS[@]}"; do
pub=${PUBS[$dir_name]}
target=$HOME_DIR/$dir_name/publishers
if [ -d "$target" ]; then
cp -f $SRC/__init__.py $target/
cp -f $SRC/bootstrap_helpers.py $target/
cp -rf $SRC/$pub/* $target/$pub/
echo " Updated $dir_name ($pub)"
else
echo " SKIP $dir_name (not found)"
fi
done
# Update opensky (in OSHConnect-Python dir)
if [ -d "$HOME_DIR/OSHConnect-Python/publishers/opensky" ]; then
cp -f $SRC/__init__.py $HOME_DIR/OSHConnect-Python/publishers/
cp -f $SRC/bootstrap_helpers.py $HOME_DIR/OSHConnect-Python/publishers/
cp -rf $SRC/opensky/* $HOME_DIR/OSHConnect-Python/publishers/opensky/
echo " Updated OSHConnect-Python (opensky)"
fi
echo ""
echo "=== Creating Go publisher directories ==="
# Create Go publisher directories for publishers that don't have one yet
# (usgs-eq and opensky already have Go services)
declare -A GO_PUBS=(
[nws-publisher-go]=nws
[ndbc-publisher-go]=ndbc
[coops-publisher-go]=coops
[aviation-wx-publisher-go]=aviation_wx
[usgs-water-publisher-go]=usgs_water
[usgs-nims-publisher-go]=usgs_nims
[iss-publisher-go]=iss
[met-office-datahub-publisher-go]=met_office_datahub
)
for dir_name in "${!GO_PUBS[@]}"; do
pub=${GO_PUBS[$dir_name]}
target=$HOME_DIR/$dir_name/publishers
mkdir -p $target/$pub
cp -f $SRC/__init__.py $target/
cp -f $SRC/bootstrap_helpers.py $target/
cp -f $SRC/base.py $target/ 2>/dev/null || true
cp -rf $SRC/$pub/* $target/$pub/
echo " Created $dir_name ($pub)"
done
# Aviation WX also needs to be updated in the existing SH directory
# (it doesn't have one — check)
if [ ! -d "$HOME_DIR/aviation-wx-publisher" ]; then
echo " Note: No existing aviation-wx-publisher SH directory found"
fi
echo ""
echo "=== Running bootstraps against Go server ==="
# Run each bootstrap against the Go server. OSH_PASS is intentionally required
# from the caller's environment so server credentials are not stored in git.
export OSH_ADDRESS=${OSH_ADDRESS:-129-80-248-53.sslip.io}
export OSH_PORT=${OSH_PORT:-443}
export OSH_USER=${OSH_USER:-os4csapi}
: "${OSH_PASS:?Set OSH_PASS in the shell or a host-local environment file before running this script}"
export OSH_PASS
export OSH_BASE_URL=${OSH_BASE_URL:-$GO_URL}
# NWS bootstrap
echo "-- NWS Bootstrap --"
cd $HOME_DIR/nws-publisher-go
python3 -m publishers.nws.bootstrap_nws 2>&1 | tail -20
echo ""
# NDBC bootstrap (includes buoycam)
echo "-- NDBC Bootstrap --"
cd $HOME_DIR/ndbc-publisher-go
python3 -m publishers.ndbc.bootstrap_ndbc 2>&1 | tail -20
echo ""
# CO-OPS bootstrap
echo "-- CO-OPS Bootstrap --"
cd $HOME_DIR/coops-publisher-go
python3 -m publishers.coops.bootstrap_coops 2>&1 | tail -20
echo ""
# Aviation WX bootstrap
echo "-- Aviation WX Bootstrap --"
cd $HOME_DIR/aviation-wx-publisher-go
python3 -m publishers.aviation_wx.bootstrap_aviation_wx 2>&1 | tail -20
echo ""
# USGS Water bootstrap
echo "-- USGS Water Bootstrap --"
cd $HOME_DIR/usgs-water-publisher-go
python3 -m publishers.usgs_water.bootstrap_usgs_water 2>&1 | tail -20
echo ""
# USGS NIMS bootstrap
echo "-- USGS NIMS Bootstrap --"
cd $HOME_DIR/usgs-nims-publisher-go
python3 -m publishers.usgs_nims.bootstrap_usgs_nims 2>&1 | tail -20
echo ""
# ISS bootstrap
echo "-- ISS Bootstrap --"
cd $HOME_DIR/iss-publisher-go
python3 -m publishers.iss.bootstrap_iss 2>&1 | tail -20
echo ""
# Met Office DataHub bootstrap (requires MET_OFFICE_LAND_OBSERVATIONS_API_KEY
# only for publisher runtime/probe, not for resource bootstrap)
echo "-- Met Office DataHub Bootstrap --"
cd $HOME_DIR/met-office-datahub-publisher-go
python3 -m publishers.met_office_datahub.bootstrap_met_office_datahub 2>&1 | tail -20
echo ""
echo "=== Bootstrap complete ==="