-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_openwebrx.bash
executable file
·265 lines (210 loc) · 5.8 KB
/
install_openwebrx.bash
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
#!/bin/bash
set -e
SCRIPT_PATH=`realpath "$0"`
SCRIPT_DIR=`dirname "$SCRIPT_PATH"`
BUILD_DIR="$SCRIPT_DIR/build"
export MAKEOPTS="-j `nproc --all`"
function install_prerequisites()
{
sudo apt-get -y install git build-essential cmake python3 python3-setuptools
sudo apt-get -y install rtl-sdr netcat libsndfile-dev librtlsdr-dev automake autoconf libtool pkg-config fftw3-dev libsamplerate0-dev libudev-dev
}
function install_cdr()
{
echo "Install csdr"
cd "$BUILD_DIR"
[[ ! -d csdr ]] && git clone --depth=1 -b master https://github.com/jketterl/csdr.git
cd csdr
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=release ..
make $MAKEOPTS
sudo make install
cd ..
sudo ldconfig
}
function install_pycdr()
{
echo "Install csdr"
cd "$BUILD_DIR"
[[ ! -d pycsdr ]] && git clone https://github.com/jketterl/pycsdr.git
cd pycsdr
sudo ./setup.py install install_headers
cd ..
}
function install_js8py()
{
echo "Install js8py library from source"
cd "$BUILD_DIR"
[[ ! -d js8py ]] && git clone --depth=1 -b master https://github.com/jketterl/js8py.git
cd js8py
sudo python3 setup.py install
cd ..
}
function install_owrx_connector()
{
echo "Install owrx_connector from source"
cd "$BUILD_DIR"
[[ ! -d owrx_connector ]] && git clone --depth=1 -b master https://github.com/jketterl/owrx_connector.git
cd owrx_connector
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=release ..
make $MAKEOPTS
sudo make install
cd ../..
sudo ldconfig
}
function install_digital_voice()
{
echo "Install codecserver (for digital voice)"
sudo apt-get -y install sox libprotobuf-dev protobuf-compiler
cd "$BUILD_DIR"
[[ ! -d codecserver ]] && git clone --depth=1 -b master https://github.com/jketterl/codecserver.git
cd codecserver
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=release ..
make $MAKEOPTS
sudo make install
cd ../..
sudo ldconfig
}
function setup_codecserver_users()
{
echo "Create codecserver user and set permissions for serial devices"
sudo bash -c "id -u codecserver >/dev/null 2>&1 || adduser --system --group --no-create-home --home /nonexistent --quiet codecserver"
sudo bash -c "id -u codecserver >/dev/null 2>&1 || usermod -aG dialout codecserver"
}
function install_digiham()
{
echo "Install digiham from source"
cd "$BUILD_DIR"
[[ ! -d digiham ]] && git clone --depth=1 -b master https://github.com/jketterl/digiham.git
cd digiham
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=release ..
make $MAKEOPTS
sudo make install
cd ../..
}
function install_codec2()
{
echo "Install codec2 from source"
cd "$BUILD_DIR"
[[ ! -d codec2 ]] && git clone --depth=1 https://github.com/drowe67/codec2.git
cd codec2
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=release ..
make $MAKEOPTS
sudo make install
# manually install freedv_rx since it's not part of the default install package
sudo install -m 0755 src/freedv_rx /usr/local/bin
cd ../..
sudo ldconfig
}
function install_m17_cxx_daemod()
{
echo "m17-cxx-demod"
sudo apt-get -y install libboost-program-options-dev
cd "$BUILD_DIR"
[[ ! -d m17-cxx-demod ]] && git clone --depth=1 https://github.com/mobilinkd/m17-cxx-demod.git
cd m17-cxx-demod
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=release ..
make $MAKEOPTS
sudo make install
cd ../..
}
function install_drm()
{
echo "Install optional dependencies for DRM"
sudo apt-get -y install qt5-default libpulse0 libfaad2 libopus0 libpulse-dev libfaad-dev libopus-dev libfftw3-dev wget
cd "$BUILD_DIR"
[[ ! -f $BUILD_DIR/dream-2.1.1-svn808.tar.gz ]] && wget https://downloads.sourceforge.net/project/drm/dream/2.1.1/dream-2.1.1-svn808.tar.gz
[[ ! -d "$BUILD_DIR/dream" ]] && tar xvfz dream-2.1.1-svn808.tar.gz
cd dream
qmake CONFIG+=console
make $MAKEOPTS
sudo make install
cd ..
}
function install_direwolf()
{
echo "Install optional packages for Packet / APRS"
sudo apt-get -y install direwolf
}
function install_sox()
{
echo "Install sox"
sudo apt-get -y install sox
}
function setup_openwebrx()
{
echo "Prepare data storage"
if [[ -d "/var/lib/openwebrx" ]]; then
echo "/var/lib/openwebrx directory exists. Do nothing to prevent data loss"
return 0
fi
sudo mkdir -p /var/lib/openwebrx
echo "Craete openwebrx user"
sudo bash -c "id -u openwebrx || useradd -m openwebrx -G plugdev -m"
echo "Change /var/lib/openwebrx owner to openwebrx:openwebrx"
sudo chown openwebrx:openwebrx /var/lib/openwebrx
echo "Create empty users.json"
sudo bash -c "echo [] > /var/lib/openwebrx/users.json"
echo "Change owner/group for users.json to openwebrx:openwebrx"
sudo chown openwebrx:openwebrx /var/lib/openwebrx/users.json
echo "users.json 0600"
sudo chmod 0600 /var/lib/openwebrx/users.json
echo "Create admin user for openwebrx"
cd openwebrx
sudo ./openwebrx.py admin adduser admin
#./openwebrx.py
}
function install_openwebrx()
{
echo "Clone openwebrx"
cd "$BUILD_DIR"
[[ ! -d openwebrx ]] && git clone --depth=1 -b master https://github.com/jketterl/openwebrx.git
}
function create_service_openwebrx()
{
echo "Create openwebrx service file"
if [[ -f "/etc/systemd/system/openwebrx.service" ]]; then
echo "/etc/systemd/system/openwebrx.service file found, do nothing"
return 0
fi
sudo bash -c "echo '[Unit]
Description=OpenWebRX WebSDR receiver
[Service]
Type=simple
User=openwebrx
Group=openwebrx
ExecStart=$BUILD_DIR/openwebrx/openwebrx.py
Restart=always
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/openwebrx.service"
sudo systemctl daemon-reload
sudo systemctl enable openwebrx
}
# ------------------------------------------------------------------------
install_prerequisites
install_cdr
install_pycdr
install_js8py
install_owrx_connector
install_digital_voice
setup_codecserver_users
install_digiham
install_codec2
install_m17_cxx_daemod
install_drm
install_direwolf
install_sox
install_openwebrx
setup_openwebrx
create_service_openwebrx