-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·297 lines (249 loc) · 7.08 KB
/
install.sh
File metadata and controls
executable file
·297 lines (249 loc) · 7.08 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/bash
set -e
echo "🚀 Starting Between Threads installation"
# Configuration
APP_DIR="$HOME/Desktop/BetweenThreads"
SERVICE_PIGPIO="pigpiod-custom"
SERVICE_BT="between-threads"
SERVICE_DASHBOARD="between-threads-dashboard"
SERVICE_LIVESTREAM="between-threads-livestream"
USER_NAME=$(whoami)
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# ---------------------------
# 1. Create application directory
# ---------------------------
log_info "Creating application directory..."
mkdir -p "$APP_DIR"
cd "$APP_DIR"
# ---------------------------
# 2. Install system dependencies
# ---------------------------
log_info "Installing system dependencies..."
# Update package list
sudo apt-get update -qq
# Install essential tools
sudo apt-get install -y -qq \
git \
curl \
unzip \
wget \
build-essential \
python3 \
python3-pip \
nodejs \
npm \
ffmpeg
# Install uv if not present
UV_PATH="$HOME/.local/bin/uv"
if [ ! -f "$UV_PATH" ]; then
log_info "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
else
log_info "uv already installed"
fi
# ---------------------------
# 3. Clone repositories
# ---------------------------
log_info "Cloning repositories..."
# RaspberryPi-Software
if [ ! -d "RaspberryPi-Software" ]; then
git clone https://github.com/Between-Threads-Project/RaspberryPi-Software
else
log_warn "RaspberryPi-Software already exists, skipping clone"
fi
# Dashboard
if [ ! -d "Dashboard" ]; then
git clone https://github.com/Between-Threads-Project/Dashboard
else
log_warn "Dashboard already exists, skipping clone"
fi
# Live-Streaming
if [ ! -d "Live-Streaming" ]; then
git clone https://github.com/Between-Threads-Project/Live-Streaming
else
log_warn "Live-Streaming already exists, skipping clone"
fi
# ---------------------------
# 4. Install pigpio
# ---------------------------
log_info "Installing pigpio..."
cd ~
if [ ! -d "pigpio-master" ]; then
wget -O pigpio-master.zip https://github.com/joan2937/pigpio/archive/master.zip
unzip pigpio-master.zip
cd pigpio-master
make -j$(nproc)
sudo make install
else
log_warn "pigpio already installed, skipping build"
fi
# ---------------------------
# 5. Install Python dependencies
# ---------------------------
log_info "Installing Python dependencies..."
# RaspberryPi-Software dependencies
cd "$APP_DIR/RaspberryPi-Software"
if [ -f "pyproject.toml" ]; then
"$UV_PATH" sync
else
log_error "pyproject.toml not found in RaspberryPi-Software"
exit 1
fi
# Live-Streaming (Node.js application, no build needed)
cd "$APP_DIR/Live-Streaming"
if [ -f "server.js" ]; then
log_info "Live-Streaming files verified"
else
log_error "server.js not found in Live-Streaming"
exit 1
fi
# ---------------------------
# 6. Install Dashboard dependencies
# ---------------------------
log_info "Installing Dashboard dependencies..."
cd "$APP_DIR/Dashboard"
if [ -f "package.json" ]; then
npm install --silent
npm run build
else
log_error "package.json not found in Dashboard"
exit 1
fi
# ---------------------------
# 7. Create systemd services
# ---------------------------
log_info "Creating systemd services..."
# pigpio service
sudo tee /etc/systemd/system/${SERVICE_PIGPIO}.service > /dev/null <<EOF
[Unit]
Description=Pigpio Daemon
After=network.target
[Service]
ExecStart=/usr/local/bin/pigpiod
Type=forking
PIDFile=/run/pigpio.pid
Restart=always
User=root
[Install]
WantedBy=multi-user.target
EOF
# Between Threads main service
sudo tee /etc/systemd/system/${SERVICE_BT}.service > /dev/null <<EOF
[Unit]
Description=Between Threads - Raspberry Pi Software
After=network.target ${SERVICE_PIGPIO}.service
Requires=${SERVICE_PIGPIO}.service
[Service]
WorkingDirectory=$APP_DIR/RaspberryPi-Software
ExecStart=$UV_PATH run web.server
Restart=always
User=$USER_NAME
Environment=PATH=$HOME/.local/bin:$PATH
[Install]
WantedBy=multi-user.target
EOF
# Dashboard service
sudo tee /etc/systemd/system/${SERVICE_DASHBOARD}.service > /dev/null <<EOF
[Unit]
Description=Between Threads - Dashboard
After=network.target
[Service]
WorkingDirectory=$APP_DIR/Dashboard
ExecStart=/usr/bin/npm run start
Restart=always
User=$USER_NAME
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
EOF
# Live-Streaming service
sudo tee /etc/systemd/system/${SERVICE_LIVESTREAM}.service > /dev/null <<EOF
[Unit]
Description=Between Threads - Live Streaming
After=network.target
[Service]
WorkingDirectory=$APP_DIR/Live-Streaming
ExecStart=/usr/bin/node server.js
Restart=always
User=$USER_NAME
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
EOF
# ---------------------------
# 8. Enable and start services
# ---------------------------
log_info "Enabling and starting services..."
sudo systemctl daemon-reload
# Enable services to start on boot
sudo systemctl enable ${SERVICE_PIGPIO}
sudo systemctl enable ${SERVICE_BT}
sudo systemctl enable ${SERVICE_DASHBOARD}
sudo systemctl enable ${SERVICE_LIVESTREAM}
# Start services
sudo systemctl start ${SERVICE_PIGPIO}
sudo systemctl start ${SERVICE_BT}
sudo systemctl start ${SERVICE_DASHBOARD}
sudo systemctl start ${SERVICE_LIVESTREAM}
# ---------------------------
# 9. Verify installation
# ---------------------------
log_info "Verifying installation..."
echo ""
echo "Service status:"
echo "----------------"
# Check pigpio service
if sudo systemctl is-active --quiet ${SERVICE_PIGPIO}; then
echo -e "${GREEN}✓${NC} ${SERVICE_PIGPIO} is running"
else
echo -e "${RED}✗${NC} ${SERVICE_PIGPIO} is not running"
fi
# Check between-threads service
if sudo systemctl is-active --quiet ${SERVICE_BT}; then
echo -e "${GREEN}✓${NC} ${SERVICE_BT} is running"
else
echo -e "${RED}✗${NC} ${SERVICE_BT} is not running"
fi
# Check dashboard service
if sudo systemctl is-active --quiet ${SERVICE_DASHBOARD}; then
echo -e "${GREEN}✓${NC} ${SERVICE_DASHBOARD} is running"
else
echo -e "${RED}✗${NC} ${SERVICE_DASHBOARD} is not running"
fi
# Check live-streaming service
if sudo systemctl is-active --quiet ${SERVICE_LIVESTREAM}; then
echo -e "${GREEN}✓${NC} ${SERVICE_LIVESTREAM} is running"
else
echo -e "${RED}✗${NC} ${SERVICE_LIVESTREAM} is not running"
fi
echo ""
echo "Installation paths:"
echo "------------------"
echo "Application directory: $APP_DIR"
echo "RaspberryPi-Software: $APP_DIR/RaspberryPi-Software"
echo "Dashboard: $APP_DIR/Dashboard"
echo "Live-Streaming: $APP_DIR/Live-Streaming"
echo ""
echo "Access information:"
echo "------------------"
echo "Dashboard URL: http://$(hostname -I | awk '{print $1}'):3000"
echo "API URL: http://$(hostname -I | awk '{print $1}'):8000"
echo "Live Stream URL: http://$(hostname -I | awk '{print $1}'):8000"
echo "UDP ports: 5000, 5001 (for external hand recognition)"
echo ""
echo "${GREEN}✅ Installation complete!${NC}"
echo "All services are configured to start automatically on boot."