Skip to content

Commit 906ae33

Browse files
committed
fix: bootstrap_helpers reads OSH_BASE_URL for Go server, fix ISS bootstrap get_config
1 parent b7e551f commit 906ae33

3 files changed

Lines changed: 130 additions & 2 deletions

File tree

deploy_go_publishers.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
# deploy_go_publishers.sh — Deploy updated publisher code and set up Go server publishers on VM
3+
set -e
4+
5+
SRC=/tmp/OSHConnect-Python/publishers
6+
HOME_DIR=/home/ubuntu
7+
GO_URL="https://129-80-248-53.sslip.io/csapi-go"
8+
9+
echo "=== Updating existing publisher directories ==="
10+
11+
declare -A PUBS=(
12+
[nws-publisher]=nws
13+
[ndbc-publisher]=ndbc
14+
[coops-publisher]=coops
15+
[usgs-water-publisher]=usgs_water
16+
[usgs-nims-publisher]=usgs_nims
17+
[usgs-eq-publisher]=usgs_eq
18+
)
19+
20+
for dir_name in "${!PUBS[@]}"; do
21+
pub=${PUBS[$dir_name]}
22+
target=$HOME_DIR/$dir_name/publishers
23+
if [ -d "$target" ]; then
24+
cp -f $SRC/__init__.py $target/
25+
cp -f $SRC/bootstrap_helpers.py $target/
26+
cp -rf $SRC/$pub/* $target/$pub/
27+
echo " Updated $dir_name ($pub)"
28+
else
29+
echo " SKIP $dir_name (not found)"
30+
fi
31+
done
32+
33+
# Update opensky (in OSHConnect-Python dir)
34+
if [ -d "$HOME_DIR/OSHConnect-Python/publishers/opensky" ]; then
35+
cp -f $SRC/__init__.py $HOME_DIR/OSHConnect-Python/publishers/
36+
cp -f $SRC/bootstrap_helpers.py $HOME_DIR/OSHConnect-Python/publishers/
37+
cp -rf $SRC/opensky/* $HOME_DIR/OSHConnect-Python/publishers/opensky/
38+
echo " Updated OSHConnect-Python (opensky)"
39+
fi
40+
41+
echo ""
42+
echo "=== Creating Go publisher directories ==="
43+
44+
# Create Go publisher directories for publishers that don't have one yet
45+
# (usgs-eq and opensky already have Go services)
46+
declare -A GO_PUBS=(
47+
[nws-publisher-go]=nws
48+
[ndbc-publisher-go]=ndbc
49+
[coops-publisher-go]=coops
50+
[aviation-wx-publisher-go]=aviation_wx
51+
[usgs-water-publisher-go]=usgs_water
52+
[usgs-nims-publisher-go]=usgs_nims
53+
[iss-publisher-go]=iss
54+
)
55+
56+
for dir_name in "${!GO_PUBS[@]}"; do
57+
pub=${GO_PUBS[$dir_name]}
58+
target=$HOME_DIR/$dir_name/publishers
59+
mkdir -p $target/$pub
60+
cp -f $SRC/__init__.py $target/
61+
cp -f $SRC/bootstrap_helpers.py $target/
62+
cp -f $SRC/base.py $target/ 2>/dev/null || true
63+
cp -rf $SRC/$pub/* $target/$pub/
64+
echo " Created $dir_name ($pub)"
65+
done
66+
67+
# Aviation WX also needs to be updated in the existing SH directory
68+
# (it doesn't have one — check)
69+
if [ ! -d "$HOME_DIR/aviation-wx-publisher" ]; then
70+
echo " Note: No existing aviation-wx-publisher SH directory found"
71+
fi
72+
73+
echo ""
74+
echo "=== Running bootstraps against Go server ==="
75+
76+
# Run each bootstrap against the Go server
77+
export OSH_ADDRESS=129-80-248-53.sslip.io
78+
export OSH_PORT=443
79+
export OSH_USER=os4csapi
80+
export OSH_PASS=ogc134mm
81+
export OSH_BASE_URL=$GO_URL
82+
83+
# NWS bootstrap
84+
echo "-- NWS Bootstrap --"
85+
cd $HOME_DIR/nws-publisher-go
86+
python3 -m publishers.nws.bootstrap_nws 2>&1 | tail -20
87+
echo ""
88+
89+
# NDBC bootstrap (includes buoycam)
90+
echo "-- NDBC Bootstrap --"
91+
cd $HOME_DIR/ndbc-publisher-go
92+
python3 -m publishers.ndbc.bootstrap_ndbc 2>&1 | tail -20
93+
echo ""
94+
95+
# CO-OPS bootstrap
96+
echo "-- CO-OPS Bootstrap --"
97+
cd $HOME_DIR/coops-publisher-go
98+
python3 -m publishers.coops.bootstrap_coops 2>&1 | tail -20
99+
echo ""
100+
101+
# Aviation WX bootstrap
102+
echo "-- Aviation WX Bootstrap --"
103+
cd $HOME_DIR/aviation-wx-publisher-go
104+
python3 -m publishers.aviation_wx.bootstrap_aviation_wx 2>&1 | tail -20
105+
echo ""
106+
107+
# USGS Water bootstrap
108+
echo "-- USGS Water Bootstrap --"
109+
cd $HOME_DIR/usgs-water-publisher-go
110+
python3 -m publishers.usgs_water.bootstrap_usgs_water 2>&1 | tail -20
111+
echo ""
112+
113+
# USGS NIMS bootstrap
114+
echo "-- USGS NIMS Bootstrap --"
115+
cd $HOME_DIR/usgs-nims-publisher-go
116+
python3 -m publishers.usgs_nims.bootstrap_usgs_nims 2>&1 | tail -20
117+
echo ""
118+
119+
# ISS bootstrap
120+
echo "-- ISS Bootstrap --"
121+
cd $HOME_DIR/iss-publisher-go
122+
python3 -m publishers.iss.bootstrap_iss 2>&1 | tail -20
123+
echo ""
124+
125+
echo "=== Bootstrap complete ==="

publishers/bootstrap_helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def get_config():
5353

5454
scheme = "http" if port == "80" else "https"
5555
default_url = f"{scheme}://{addr}/{root}/api"
56-
base_url = os.environ.get("BOOTSTRAP_URL", default_url)
56+
base_url = os.environ.get("BOOTSTRAP_URL",
57+
os.environ.get("OSH_BASE_URL", default_url))
5758

5859
return {
5960
"base_url": base_url,

publishers/iss/bootstrap_iss.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ def main():
288288
add_bootstrap_args(parser)
289289
args = parser.parse_args()
290290

291-
base_url, auth = get_config()
291+
config = get_config()
292+
base_url = config["base_url"]
293+
auth = _auth_header(config["user"], config["password"])
292294
dry_run = args.dry_run
293295
stats = {"created": 0, "skipped": 0, "deleted": 0, "errors": 0}
294296

0 commit comments

Comments
 (0)