-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstall_orp.sh
executable file
·376 lines (350 loc) · 14.2 KB
/
install_orp.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
#!/usr/bin/bash
################################################################################
# SCRIPT CONTRIBUTORS:
# Aaron Crawford (N3MBH), Richard Neese (N4CNR), Dan Loranger (KG7PAR),
# Dana Rawding (N1OFZ), John Tetreault (KC1KVT), Bob Ruddy (W3RCR)
################################################################################
############################
# Set Debian OS Release
############################
REQUIRED_OS_VER="12"
REQUIRED_OS_NAME="BookWorm"
############################
#System arch checking (New)
############################
system_arch="$(dpkg --print-architecture)"
############################
# Set config.txt path
############################
if [ $REQUIRED_OS_VER >=12 ]; then
RPI_config_text_path="/boot/firmware/config.txt"
else
RPI_config_text_path="/boot/config.txt"
fi
############################
#Get rpi-board id (New)
############################
rpi_board="$(cat /proc/cpuinfo | grep -i Revision)"
################################################################################
# DEFINABLE VARIABLES EDIT (start)
################################################################################
############################
# ORP Version Displayed on Login Page
############################
ORP_VERSION="3.0.x (Dev)"
############################
# ORP Gui Install Version (New)
# What version to pull from git
############################
ORP_GUI_VERSION="3.0.x-DEV"
############################
# set build / install log dir (New)
############################
log_dir="/var/log/"
############################
# set build work base dir (New)
############################
base_dir="/usr/src/"
############################
# set build work dir (New)
############################
wrk_dir="/usr/src/scripts"
############################
# File System Requirements
############################
MIN_PARTITION_SIZE="3000"
MIN_DISK_SIZE="4GB"
############################
# Upload size limit for php
############################
UPLOAD_SIZE="25M"
############################
# path to install web gui in
############################
WWW_PATH="/var/www"
############################
# set gui name for db_archive
############################
GUI_NAME="openrepeater"
############################
# PHP ini config file
############################
PHP_INI="/etc/php/8.2/fpm/php.ini"
############################
# SVXLink Settings
############################
# SVXLINK VERSION - Must match versioning
# at https://github.com/sm0svx/svxlink/releases
############################
SVXLINK_VER="24.02"
SCRIPT_DIR="$(dirname $(realpath "$0"))"
############################
# Set path for svxlink sound files
############################
SVXLINK_SOUNDS_DIR="/usr/share/svxlink/sounds"
############################
# Enable the g_cdc ethernet/usb console
# otg_gcdc_enable=yes uses g_cdc usb ethernet/usb serial console
# otg_gcdc_enable=no uses g_serial usb serial console only
# default = no = g_serial
############################
otg_gcdc_enable=no
############################
# SET Default WIFI Regional Domain
# Used to set what wifi channels available in your region
# Used for wifi hotspot setup/configuration at install
# Default = US
############################
WIFI_DOMAIN="US"
################################################################################
# DEFINABLE VARIABLES EDIT (stop)
################################################################################
################################################################################
# PRE-INSTALL configuration
################################################################################
########################################################
# Make sure function scripts are executable.
########################################################
chmod +x functions/*
########################################################
#Include ORP/SvxLink Build Menus file
########################################################
source "${BASH_SOURCE%/*}/functions/install_menus.sh"
########################################################
#Include Main Functions File & RPI functions
########################################################
source "${BASH_SOURCE%/*}/functions/functions_base.sh"
########################################################
#Install and configure SvxLink
########################################################
source "${BASH_SOURCE%/*}/functions/functions_svxlink.sh"
########################################################
#Change the MOTD file output
########################################################
source "${BASH_SOURCE%/*}/functions/functions_motd.sh"
########################################################
#Disable un needed functions in OpenRepeater install
########################################################
source "${BASH_SOURCE%/*}/functions/functions_rpi.sh"
########################################################
#Enable ICS Cards and sound support
########################################################
source "${BASH_SOURCE%/*}/functions/functions_ics.sh"
#source "${BASH_SOURCE%/*}/functions/board_drivers_loader"
########################################################
#Enable otg serial console zero/w/w2
########################################################
source "${BASH_SOURCE%/*}/functions/functions_otg.sh"
########################################################
#Enable UART for serial console
########################################################
source "${BASH_SOURCE%/*}/functions/functions_uart.sh"
########################################################
#Include AutoHotSpot Functions
########################################################
source "${BASH_SOURCE%/*}/functions/functions_AutoHotSpot.sh"
########################################################
#Include X86 dummy sound driver Functions
########################################################
source "${BASH_SOURCE%/*}/functions/functions_dummysnd.sh"
########################################################
#Enable i2c on raspi
########################################################
source "${BASH_SOURCE%/*}/functions/functions_i2c.sh"
########################################################
#Install orp and deps
########################################################
source "${BASH_SOURCE%/*}/functions/functions_orp.sh"
########################################################
#Install Nginx and Php
########################################################
source "${BASH_SOURCE%/*}/functions/functions_web.sh"
########################################################
#Cleanup
########################################################
source "${BASH_SOURCE%/*}/functions/functions_cleanup.sh"
########################################################
########################################################
# OS Patches
########################################################
source "${BASH_SOURCE%/*}/functions/functions_os_patches.sh"
### INITIAL FUNCTIONS ####
check_root
check_os
retrieve_system_ip
check_internet
# Start Time
START_TIME=$(date +%s)
################################################################################
# USER INPUT
################################################################################
menu_welcome_message
express_build_menu
if [ "$INPUT_EXPRESS_INSTALL" == "yes" ]; then
HOSTNAME="openrepeater"
INPUT_INSTALL_TYPE="ORP"
INPUT_SVXLINK_CONTRIBS=""
INPUT_SVXLINK_INSTALL_TYPE="svx_released"
else
menu_hostname
menu_build_type
if [ "$INPUT_INSTALL_TYPE" == "ORP" ]; then
menu_orp_file_loc
fi
menu_svxlink_build_type
menu_contrib_modules
fi
################################################################################
# MAIN SCRIPT - Run Functions and Save to Log
################################################################################
(
fixup_dtoverlay_linking
########################################################
# grab date for build date/start build time
########################################################
date
########################################################
# Update system locales
########################################################
config_locale
########################################################
# Update system hostname
########################################################
set_hostname "$HOSTNAME"
########################################################
# Update system hostname
########################################################
set_wifi_domain
####################################################
# add serial console to allow access where no
# network avaible. Rpi zero/w/w2 (New)
####################################################
#otg_console
########################################################
### SVXLINK FUNCTIONS
########################################################
install_svxlink_source "$INPUT_SVXLINK_INSTALL_TYPE" "$INPUT_SVXLINK_CONTRIBS"
########################################################
# fixup the RepeaterLogic so IDs work correctly
########################################################
logic_fixup '../../../usr/share/svxlink/events.d/RepeaterLogic.tcl' 'proc repeater_down' '/usr/share/svxlink/events.d/RepeaterLogic.tcl'
### allow a few seconds for the file system to catch up since we are working on the same file as before
sleep 5
logic_fixup '../../../usr/share/svxlink/events.d/RepeaterLogic.tcl' 'proc repeater_up' '/usr/share/svxlink/events.d/RepeaterLogic.tcl'
########################################################
# fixup a typo in the svxlink source that breaks the gpio service
########################################################
fix_svxlink_gpio
########################################################
# install scripts to set device permissions (hidraw/serial)
########################################################
install_device_permission_scripts
########################################################
# Enable ALSA zerofill for svxlink
########################################################
force_async_audio_zerfill
########################################################
# install copy of repo with all the synthetic voice files
########################################################
install_svxlink_sounds
########################################################
# cards with gpio expanders will need to have the i2c bus enabled.
########################################################
enable_i2c
########################################################
# need some asound.conf tweaks to keep the channels seperated
########################################################
set_ics_asound
####################################################
#Enable dummy sound drive x86/amd64 (new)
####################################################
dummysnd_setup
####################################################
#Enable raspi serial console uart pins
#(moved to its own function)
####################################################
enable_uart
########################################################
### OPEN REPEATER INSTALL FUCNTIONS
#######################################################
if [ "$INPUT_INSTALL_TYPE" = "ORP" ]; then
####################################################
#install Nginx and Dependencies
####################################################
install_webserver
####################################################
# install Extra Dependencies
####################################################
install_orp_dependancies
####################################################
# wait for network to catch up
####################################################
wait_for_network
####################################################
# Install Gui from Github
####################################################
install_orp_from_github
####################################################
# Add ORP Release version to sqlite db
####################################################
update_versioning
####################################################
# update www-data used to sudo
####################################################
modify_www-data
####################################################
### ENDING FUNCTIONS ###
####################################################
####################################################
#Disable functions on pi not needed by Repeater
####################################################
rpi_disables
####################################################
#Change the motd file for ORP
####################################################
set_motd
####################################################
#AutoHotSpot_Autosetup (New)
####################################################
#AutoHotSpot_Autosetup
fi
########################################################
# Need to add some settings to load drivers to enable
# interface card or they won't load up properly.
########################################################
if INPUT_INSTALL_TYPE="ORP"; then
#This only works if the ORP files are in place
source "/usr/sbin/board_drivers_loader"
prepare_svxlink_gpio_up
# load the 1x first as it supports the majority of the install
# base that used dedicated controller boards. UI can
# overwrite this later in the wizard
load_drivers_pi_repeater_1x_v1
else
config_ics_controllers
fi
####################################################
#Post Build Cleanup
####################################################
build_cleanup
####################################################
#Post SYSTEM IP
####################################################
post_system_ip
########################################################
#grab date for build date/finish build time
########################################################
date
#Reporting Output Log Files
) 2> >(tee "$log_dir"/orp_error.log) | tee "$log_dir"/orp_install.log
################################################################################
# POST INSTALL REPORT
################################################################################
# End Time & Build Time
################################################################################
END_TIME=$(date +%s)
BUILD_TIME="Build Time: $(((END_TIME-START_TIME)/60)) minutes"
echo "---------------------------------"
menu_end_message "$BUILD_TIME"
echo "---------------------------------"
#reboot