-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild-panel.sh
More file actions
executable file
·112 lines (93 loc) · 3.11 KB
/
build-panel.sh
File metadata and controls
executable file
·112 lines (93 loc) · 3.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
#!/bin/bash
# Build and Deploy Panel Script
# This script builds the HORNETS-Relay-Panel and copies it to the web directory
set -e
# --- Config ---
CONFIG_FILE="config.yaml"
# -------------
echo "Building HORNETS-Relay-Panel..."
# Check if config.yaml exists and read port early
CONFIG_EXISTS=0
BASE_PORT=""
if [ -f "$CONFIG_FILE" ]; then
CONFIG_EXISTS=1
PARSED_PORT=$(grep "port:" "$CONFIG_FILE" | grep -v "http" | head -1 | sed 's/.*port:\s*//' | tr -d '[:space:]')
if [ -n "$PARSED_PORT" ]; then
BASE_PORT="$PARSED_PORT"
WEB_PORT=$((BASE_PORT + 2))
echo "Config found - Base port: $BASE_PORT - Web panel port: $WEB_PORT"
fi
fi
if [ "$CONFIG_EXISTS" -eq 0 ]; then
echo "No config.yaml found - relay will generate it on first run."
fi
# Build the RELAY using root build.sh
if [ ! -f "build.sh" ]; then
echo "ERROR: Root build.sh not found."
exit 1
fi
echo "Running root build.sh (relay)..."
./build.sh
# If config didn't exist, run relay briefly to generate it
if [ "$CONFIG_EXISTS" -eq 0 ]; then
if [ -f "./hornet-storage" ]; then
echo "Starting relay briefly to generate config.yaml..."
./hornet-storage &
RELAY_PID=$!
sleep 3
kill $RELAY_PID 2>/dev/null || true
fi
if [ -f "$CONFIG_FILE" ]; then
PARSED_PORT=$(grep "port:" "$CONFIG_FILE" | grep -v "http" | head -1 | sed 's/.*port:\s*//' | tr -d '[:space:]')
if [ -n "$PARSED_PORT" ]; then
BASE_PORT="$PARSED_PORT"
fi
fi
if [ -z "$BASE_PORT" ]; then
echo "WARNING: Could not read port from config.yaml, using default 11000"
BASE_PORT="11000"
fi
WEB_PORT=$((BASE_PORT + 2))
echo "Config generated - Base port: $BASE_PORT - Web panel port: $WEB_PORT"
fi
# Remove old panel source to get latest changes
echo "Removing old panel source..."
rm -rf panel-source
# Clone fresh copy from local path
echo "Cloning latest panel source..."
git clone https://github.com/HORNET-Storage/HORNETS-Relay-Panel.git ./panel-source
# Navigate to panel source directory
cd panel-source
# Update .env files with the correct web port
echo "Updating .env files with port $WEB_PORT..."
for envfile in .env.development .env.production; do
if [ -f "$envfile" ]; then
if grep -q "REACT_APP_BASE_URL=" "$envfile"; then
sed -i "s|REACT_APP_BASE_URL=http://localhost:[0-9]*|REACT_APP_BASE_URL=http://localhost:$WEB_PORT|g" "$envfile"
else
echo "REACT_APP_BASE_URL=http://localhost:$WEB_PORT" >> "$envfile"
fi
fi
done
# Install dependencies
echo "Installing dependencies..."
yarn install
# Build the project
echo "Building panel..."
# Clear any existing build first
rm -rf build
# Build with production optimizations disabled to avoid syntax errors
GENERATE_SOURCEMAP=false NODE_ENV=production yarn build
# Copy built files to web directory
echo "Copying files to web directory..."
cd ..
mkdir -p web
rm -rf web/*
cp -r panel-source/build/* web/
echo "Panel built and deployed successfully!"
echo "The panel is now available at your relay's root URL"
echo ""
echo "To test the panel:"
echo "1. Start your relay server: ./hornet-storage"
echo "2. Visit http://localhost:$WEB_PORT"
echo "3. The panel should load automatically"