-
Notifications
You must be signed in to change notification settings - Fork 1
/
HBLink3_install.sh
436 lines (396 loc) · 10.9 KB
/
HBLink3_install.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
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#!/bin/bash
# K7ILO's HBlink3 Installer, V2.1 -----------------------------------------------------------------------------------
if [ "$EUID" -ne 0 ];
then
echo ""
echo " You must be root to run this script!! "
exit 1
fi
if [ ! -e "/etc/debian_version" ]
then
echo ""
echo " This script has been tested on NEWLY INSTALLED Debian 10 and 11 64-bit repo's only. "
echo " It is assumed you are doing the same. "
exit 0
fi
# Global Parameters -------------------------------------------------------------------------------------------------
VERSION=$(sed 's/\..*//' /etc/debian_version)
INSDIR=/opt
HBLINKDIR=$INSDIR/hblink3
DEP="git curl python3 python3-dev python3-pip sed"
HBLINKREPO=https://github.com/HBLink-org/hblink3.git
# Lets begin --------------------------------------------------------------------------------------------------------
if [ $VERSION = 10 ];
then
echo ""
echo " Debian 10 (Buster) is detected "
sleep 2
clear
echo ""
echo "-------------------------------------------------------------------------------"
echo " Downloading and installing the required software & dependencies from apt .... "
echo "-------------------------------------------------------------------------------"
sleep 2
apt update && apt install -y $DEP
apt autoremove && apt autoclean
sleep 2
elif [ $VERSION = 11 ];
then
echo ""
echo " Debian 11 (Bullseye) is detected "
sleep 2
clear
echo ""
echo "-------------------------------------------------------------------------------"
echo " Downloading and installing the required software & dependencies from apt .... "
echo "-------------------------------------------------------------------------------"
sleep 2
apt update && apt install -y $DEP
apt autoremove && apt autoclean
sleep 2
else
clear
echo "------------------------------------------------------------------------------------------"
echo " Operating system not supported! Please check your configuration or upgrade. Exiting .... "
echo "------------------------------------------------------------------------------------------"
exit 0
fi
# HBlink3 Installation ----------------------------------------------------------------------------------------------
clear
echo ""
echo " Now let's tackle installing HBlink3 .... "
sleep 2
echo ""
echo "--------------------------------------------------"
echo " First let's download the HBlink3 repository .... "
echo "--------------------------------------------------"
sleep 2
cd $INSDIR
git clone $HBLINKREPO
cd $HBLINKDIR
if [ -e bridge.py ]
then
echo ""
echo "---------------------------------------------------------------------"
echo " It looks like HBlink3 was downloaded correctly. Let's continue .... "
echo "---------------------------------------------------------------------"
else
echo "----------------------------------------------------------------------------------------------"
echo " I dont see the HBlink3 downlaod! Please check your configuration and try again. Exiting .... "
echo "----------------------------------------------------------------------------------------------"
exit 0
fi
echo ""
echo "----------------------------------------------------------------------"
echo " Installing required dependencies from the requirements.txt file .... "
echo "----------------------------------------------------------------------"
sleep 2
pip3 install -r requirements.txt
echo ""
echo " Done .... "
echo ""
echo "---------------------------------------------------------"
echo " Creating a working hblink.cfg file for testing "
echo " Refer to hblink-SAMPLE.cfg for explanations and options "
echo "---------------------------------------------------------"
sleep 2
cat << EOF > $HBLINKDIR/hblink.cfg
[GLOBAL]
PATH: ./
PING_TIME: 5
MAX_MISSED: 3
USE_ACL: True
REG_ACL: PERMIT:ALL
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[REPORTS]
REPORT: True
REPORT_INTERVAL: 60
REPORT_PORT: 4321
REPORT_CLIENTS: 127.0.0.1
[LOGGER]
LOG_FILE: /tmp/hblink.log
LOG_HANDLERS: file-timed,console-timed
LOG_LEVEL: DEBUG
LOG_NAME: HBlink
[ALIASES]
TRY_DOWNLOAD: True
PATH: ./
PEER_FILE: peer_ids.json
SUBSCRIBER_FILE: subscriber_ids.json
TGID_FILE: talkgroup_ids.json
PEER_URL: https://www.radioid.net/static/rptrs.json
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
STALE_DAYS: 7
[OBP-1]
MODE: OPENBRIDGE
ENABLED: False
IP:
PORT: 62035
NETWORK_ID: 3129100
PASSPHRASE: a_password
TARGET_IP: 1.2.3.4
TARGET_PORT: 62035
BOTH_SLOTS: True
USE_ACL: True
SUB_ACL: DENY:1
TGID_ACL: PERMIT:ALL
[MASTER-1]
MODE: MASTER
ENABLED: True
REPEAT: True
MAX_PEERS: 10
EXPORT_AMBE: False
IP:
PORT: 62030
PASSPHRASE: a_password
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[REPEATER-1]
MODE: PEER
ENABLED: False
LOOSE: False
EXPORT_AMBE: False
IP:
PORT: 54001
MASTER_IP: 172.16.1.1
MASTER_PORT: 54000
PASSPHRASE: homebrew
CALLSIGN: W1ABC
RADIO_ID: 312000
RX_FREQ: 449000000
TX_FREQ: 444000000
TX_POWER: 25
COLORCODE: 1
SLOTS: 1
LATITUDE: 38.0000
LONGITUDE: -095.0000
HEIGHT: 75
LOCATION: Anywhere, USA
DESCRIPTION: This is a cool repeater
URL: www.w1abc.org
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
OPTIONS:
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[XLX-1]
MODE: XLXPEER
ENABLED: False
LOOSE: True
EXPORT_AMBE: False
IP:
PORT: 54002
MASTER_IP: 172.16.1.1
MASTER_PORT: 62030
PASSPHRASE: a_password
CALLSIGN: W1ABC
RADIO_ID: 312000
RX_FREQ: 449000000
TX_FREQ: 444000000
TX_POWER: 25
COLORCODE: 1
SLOTS: 1
LATITUDE: 38.0000
LONGITUDE: -095.0000
HEIGHT: 75
LOCATION: Anywhere, USA
DESCRIPTION: This is a cool repeater
URL: www.w1abc.org
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
XLXMODULE: 4004
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[PARROT]
MODE: PEER
ENABLED: True
LOOSE: False
EXPORT_AMBE: False
IP:
PORT: 54111
MASTER_IP: 127.0.0.1
MASTER_PORT: 54112
PASSPHRASE: a_password
CALLSIGN: PARROT
RADIO_ID: 9999
RX_FREQ: 000000000
TX_FREQ: 000000000
TX_POWER: 1
COLORCODE: 1
SLOTS: 3
LATITUDE: 38.0000
LONGITUDE: -095.0000
HEIGHT: 0
LOCATION: PARROT Server: TG 9999
DESCRIPTION: PARROT Server: TG 9999
URL:
SOFTWARE_ID: 20170620
PACKAGE_ID: MMDVM_HBlink
GROUP_HANGTIME: 5
OPTIONS:
USE_ACL: True
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
EOF
echo ""
echo " Done .... "
echo ""
echo "-------------------------------------------------------"
echo " Creating a working rules.py file for testing "
echo " Refer to rules_SAMPLE.py for explanations and options "
echo "-------------------------------------------------------"
sleep 2
cat << EOF > $HBLINKDIR/rules.py
BRIDGES = {
'HBLink-Local-TG11': [
{'SYSTEM': 'MASTER-1', 'TS': 1, 'TGID': 11, 'ACTIVE': True, 'TIMEOUT': 30, 'TO_TYPE':'OFF', 'ON': [11], 'OFF': [55], 'RESET': []},
],
'HBLink-PARROT-TG9999': [
{'SYSTEM': 'PARROT', 'TS': 2, 'TGID': 9999, 'ACTIVE': True, 'TIMEOUT': 0, 'TO_TYPE':'NONE', 'ON': [], 'OFF': [], 'RESET': []},
{'SYSTEM': 'MASTER-1', 'TS': 2, 'TGID': 9999, 'ACTIVE': True, 'TIMEOUT': 0, 'TO_TYPE':'NONE', 'ON': [], 'OFF': [], 'RESET': []},
]
}
UNIT = ['ONE', 'TWO']
if __name__ == '__main__':
from pprint import pprint
pprint(BRIDGES)
print(UNIT)
EOF
echo ""
echo " Done .... "
echo ""
echo "------------------------------------------------------------------------"
echo " Creating a working playback.cfg file for the Echotest (PARROT) service "
echo "------------------------------------------------------------------------"
sleep 2
cat << EOF > $HBLINKDIR/playback.cfg
[GLOBAL]
PATH: ./
PING_TIME: 5
MAX_MISSED: 3
USE_ACL: True
REG_ACL: PERMIT:ALL
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
[REPORTS]
REPORT: True
REPORT_INTERVAL: 60
REPORT_PORT: 4322
REPORT_CLIENTS: 127.0.0.1
[LOGGER]
LOG_FILE: /tmp/hblink.log
LOG_HANDLERS: console-timed,file-timed
LOG_LEVEL: INFO
LOG_NAME: HBlink
[ALIASES]
TRY_DOWNLOAD: True
PATH: ./
PEER_FILE: peer_ids.json
SUBSCRIBER_FILE: subscriber_ids.json
TGID_FILE: talkgroup_ids.json
PEER_URL: https://www.radioid.net/static/rptrs.json
SUBSCRIBER_URL: https://www.radioid.net/static/users.json
STALE_DAYS: 7
[MASTER-1]
MODE: MASTER
ENABLED: True
REPEAT: False
MAX_PEERS: 10
EXPORT_AMBE: False
IP:
PORT: 54112
PASSPHRASE: a_password
GROUP_HANGTIME: 5
USE_ACL: True
REG_ACL: DENY:1
SUB_ACL: DENY:1
TGID_TS1_ACL: PERMIT:ALL
TGID_TS2_ACL: PERMIT:ALL
EOF
echo ""
echo " Done .... "
echo ""
echo "-------------------------------------------"
echo " Creating the directory for log files .... "
echo "-------------------------------------------"
sleep 2
mkdir /var/log/hblink
echo ""
echo " Done .... "
echo ""
echo "----------------------------------------------------------------------------------------------"
echo " Creating the service file and enabling the hblink service. It will auto-start on reboot .... "
echo "----------------------------------------------------------------------------------------------"
sleep 2
cat << EOF > /lib/systemd/system/hblink.service
[Unit]
Description=Start HBlink
After=multi-user.target
[Service]
ExecStart=/usr/bin/python3 /opt/hblink3/bridge.py
[Install]
WantedBy=multi-user.target
EOF
systemctl enable hblink
echo ""
echo " Done .... "
echo ""
echo "-----------------------------------------------------------------------------"
echo " Creating the service file for enabling and starting the parrot service .... "
echo "-----------------------------------------------------------------------------"
sleep 2
cat << EOF > /lib/systemd/system/parrot.service
[Unit]
Description=HB bridge all Service
After=network-online.target syslog.target
Wants=network-online.target
[Service]
StandardOutput=null
WorkingDirectory=/opt/hblink3
RestartSec=3
ExecStart=/usr/bin/python3 /opt/hblink3/playback.py -c /opt/hblink3/playback.cfg
Restart=on-abort
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
chmod +x $HBLINKDIR/playback.py
systemctl start parrot.service
systemctl enable parrot.service
clear
echo " All finished .... "
sleep 2
echo ""
echo "-------------------------------------------------------------------"
echo " If using a firewall configuration (Highly recommended), "
echo " open the needed network port #'s listed below .... "
echo " A script is OTW to install and setup UFW with these parameters. "
echo " 80/tcp "
echo " 443/tcp "
echo " 4321/tcp "
echo " 9000/tcp "
echo " 62030-62050/udp "
echo " Current SSH port/tcp "
echo "-------------------------------------------------------------------"
echo ""
echo ""
echo " Now check to see if the parrot service is running by: systemctl status parrot "
echo " Manually start and test hblink by typing: python3 /opt/hblink3/bridge.py "
echo " The installed configuration has 1 working Talk Group (TG11) and a working PARROT (Echotest, TG 9999) service "
echo " After confirming a good test, stop the test (control c) and start the hblink service: systemctl start hblink "
echo " or just reboot since PARROT and HBlink3 were enabled to start on system boot earlier. "
echo " 73 de K7ILO "