-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhotspot-config-online-6-6
296 lines (265 loc) · 10.9 KB
/
hotspot-config-online-6-6
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
TERM=xterm-256color
FILE=/usr/sbin/fmchip-monitor
if [ ! -f $FILE ]; then
echo "Your image is outdated please upgrade !!!"
exit;
fi
run() {
exec=$1
printf "\x1b[38;5;104m --> ${exec}\x1b[39m\n"
eval ${exec}
}
say () {
say=$1
printf "\x1b[38;5;220m${say}\x1b[38;5;255m\n"
}
systemctl stop fmchip-monitor
CHIPVERSION=$(sa818 --port /dev/ttyAMA0 version 2>&1 | awk '{print $6}')
if [[ "${CHIPVERSION}" == "V1.2" ]]; then
say "CHIP version V1.2 detected disabling chip monitor"
systemctl stop fmchip-monitor
systemctl disable fmchip-monitor
else
say "old CHIP version detected enabling chip monitor"
systemctl enable fmchip-monitor
systemctl start fmchip-monitor
fi
OLDCPVOL=$(grep volume /usr/sbin/hotspot | awk '{ print $6}'| tail -n 1)
OLDRFVOL=$(grep Capture /usr/sbin/hotspot_volume | awk '{ print $4}'| tail -n 1 | sed 's/%$//')
OLDAFVOL=$(grep Headphone /usr/sbin/hotspot_volume | awk '{ print $4}'| tail -n 1 | sed 's/%$//')
OLDFREQ=$(grep freq /usr/sbin/hotspot | awk '{ print $8}')
OLDCTCSS=$(grep ctcss /usr/sbin/hotspot | awk '{ print $10}' | awk -F',' '{print $1}')
OLDCTCSSMAPPING=$(cat /etc/svxlink/svxlink.conf | grep CTCSS_TO_TG | head -n 1 | tr "=" "\n" | tail -n 1)
OLDCALL=$(cat /etc/svxlink/svxlink.conf | grep CALL | head -n 1 | tr "=" "\n" | tail -n 1)
OLDTGS=$(cat /etc/svxlink/svxlink.conf | grep MONITOR_TGS | head -n 1 | tr "=" "\n" | tail -n 1)
OLDLOCATION=$(grep -i location /etc/svxlink/node_info.json | awk '{ print $2}' | tr "," "\n" | tr -cd '[:alnum:]._-')
OLDLAT=$(grep -i lat /etc/svxlink/node_info.json | awk '{ print $2}' | tr "," "\n" | tr -cd '[:alnum:]._-')
OLDLON=$(grep -i lon /etc/svxlink/node_info.json | awk '{ print $2}' | tr "," "\n" | tr -cd '[:alnum:]._-')
OLDLOC=$(grep -i loc /etc/svxlink/node_info.json | awk '{ print $2}' | tr "," "\n" | tail -n 1 | tr -cd '[:alnum:]._-')
QSYTIMEOUT=$(cat /etc/svxlink/svxlink.conf | grep QSY_PENDING_TIMEOUT | head -n 1 | tr "=" "\n" | tail -n 1)
if [[ "${OLDTGS}" == *"--"* ]]; then
OLDTGS=8
fi
if [[ "${OLDLAT}" == *"--"* ]]; then
OLDLAT="50.4707972"
fi
if [[ "${OLDLON}" == *"--"* ]]; then
OLDLON="3.8624516"
fi
if [[ "${OLDLOC}" == *"--"* ]]; then
OLDLOC="JO10VK"
fi
if [[ "${OLDCALL}" == *"--"* ]]; then
OLDCALL="ON0RFG"
fi
OLDSVXREFL=$(cat /etc/svxlink/svxlink.conf | grep HOSTS | head -n 1 | tr "=" "\n" | tail -n 1)
if [[ "${OLDSVXREFL}" == *"--"* ]]; then
OLDSVXREFL="hostname"
fi
if [[ "${OLDSVXREFL}" == "34.77.14.144" ]]; then
OLDSVXREFL="hotspots.rf.guru"
fi
OLDSVXCALL=$(cat /etc/svxlink/svxlink.conf | grep CALLSIGN | tr "=" "\n" | grep \" | tr -cd '[:alnum:]._-')
if [[ "${OLDSVXCALL}" == *"--"* ]]; then
OLDSVXCALL="ON0RFG"
fi
OLDSVXPWD=$(cat /etc/svxlink/svxlink.conf | grep AUTH_KEY | head -n 1 | tr "=" "\n" | tail -n 1 | tr -cd '[:alnum:]._-')
if [[ "${OLDSVXPWD}" == *"--"* ]]; then
OLDSVXPWD="secret"
fi
gum style --border normal --margin "1" --padding "1 2" --border-foreground "#04B575" "$(gum style --foreground 3 'RF.')Guru $(gum style --foreground 3 '-') Hotspot Config"
gum style --foreground "#04B575" "Callsign:"
CALL=$(gum input --value "${OLDCALL}")
if [[ "${CALL}" == "" ]]; then
CALL=${OLDCALL}
fi
gum style --foreground 212 "${CALL}"
gum style --foreground "#04B575" "SVXLink Reflector <IP> or <FQDN>:"
REFLECTOR=$(gum input --value "${OLDSVXREFL}")
if [[ "${REFLECTOR}" == "" ]]; then
REFLECTOR=${OLDSVXREFL}
fi
if [[ "${REFLECTOR}" == "34.77.14.144" ]]; then
REFLECTOR="hotspots.rf.guru"
fi
gum style --foreground 212 "${REFLECTOR}"
gum style --foreground "#04B575" "SVXLINK Reflector User Callsign:"
SVXCALL=$(gum input --value "${OLDSVXCALL}")
if [[ "${SVXCALL}" == "" ]]; then
SVXCALL=${OLDSVXCALL}
fi
gum style --foreground 212 "${SVXCALL}"
gum style --foreground "#04B575" "SVXLink Reflector password:"
SVXPWD=$(gum input --value "${OLDSVXPWD}")
if [[ "${SVXPWD}" == "" ]]; then
SVXPWD=${OLDSVXPWD}
fi
gum style --foreground 212 "${SVXPWD}"
gum style --foreground "#04B575" "Band:"
BAND=$(gum choose "70cm" "2m")
gum style --foreground 212 "${BAND}"
gum style --foreground "#04B575" "Frequency:"
if [ "${BAND}" = "70cm" ]; then
if [[ "${OLDFREQ}" == "" ]]; then
OLDFREQ="439.100"
fi
if (( $(echo "${OLDFREQ} > 400" |bc -l) )); then
FREQ=$(gum input --value "${OLDFREQ}")
else
FREQ=$(gum input --value "439.100")
fi
fi
if [ "${BAND}" = "2m" ]; then
if [[ "${OLDFREQ}" == "" ]]; then
OLDFREQ="145.250"
fi
if (( $(echo "${OLDFREQ} < 400" |bc -l) )); then
FREQ=$(gum input --value "${OLDFREQ}")
else
FREQ=$(gum input --value "145.250")
fi
fi
gum style --foreground 212 "${FREQ}"
gum style --foreground "#04B575" "Enter CTCSS tone mapping (<tone>:<talkgroup>,...):"
if [[ "${OLDCTCSSMAPPING}" == "" ]]; then
OLDCTCSSMAPPING="67.0:8400,69.3:8,71.9:23,74.4:9000,77.0:50,79.7:51,82.5:52,85.4:53,88.5:54,91.5:55"
fi
CTCSSMAPPING=$(gum input --value "${OLDCTCSSMAPPING}")
gum style --foreground 212 "${CTCSSMAPPING}"
gum style --foreground "#04B575" "CTCSS on tx:"
CTCSSTX=$(gum choose "Yes" "No")
gum style --foreground 212 "${CTCSSTX}"
if [[ "${CTCSSTX}" == "Yes" ]]; then
gum style --foreground "#04B575" "Enter CTCSS TX tone:"
if [[ "${OLDCTCSS}" == "" ]]; then
OLDCTCSS="88.5"
fi
CTCSS=$(gum input --value "${OLDCTCSS}")
gum style --foreground 212 "${CTCSS}"
fi
gum style --foreground "#04B575" "Enter Location:"
if [[ "${OLDLOCATION}" == "" ]]; then
OLDLOCATION="Saint Ghislain"
fi
LOCATION=$(gum input --value "${OLDLOCATION}")
gum style --foreground 212 "${LOCATION}"
gum style --foreground "#04B575" "Enter Latitude:"
if [[ "${OLDLAT}" == "" ]]; then
OLDLAT="50.4707972"
fi
LAT=$(gum input --value "${OLDLAT}")
gum style --foreground 212 "${LAT}"
gum style --foreground "#04B575" "Enter Longitude:"
if [[ "${OLDLON}" == "" ]]; then
OLDLON="3.8624516"
fi
LON=$(gum input --value "${OLDLON}")
gum style --foreground 212 "${LON}"
gum style --foreground "#04B575" "Enter Gridsquare:"
if [[ "${OLDLOC}" == "" ]]; then
OLDLOC="JO10VK"
fi
LOC=$(gum input --value "${OLDLOC}")
gum style --foreground 212 "${LOC}"
gum style --foreground "#04B575" "Hide Location info ?:"
HIDDEN=$(gum choose "False" "True")
gum style --foreground 212 "${HIDDEN}"
gum style --foreground "#04B575" "Enter talk groups to monitor:"
if [[ "${OLDTGS}" == "" ]]; then
OLDTGS=8
fi
TGS=$(gum input --value "${OLDTGS}")
gum style --foreground 212 "${TGS}"
gum style --foreground "#04B575" "Enter AF output volume [50-80] (default 65):"
AFVOL=$(gum input --value "${OLDAFVOL}")
if [[ "${AFVOL}" == "" ]]; then
AFVOL=65
fi
gum style --foreground 212 "${AFVOL}"
gum style --foreground "#04B575" "Enter RF input volume [17-23] (default 19):"
RFVOL=$(gum input --value "${OLDRFVOL}")
if [[ "${RFVOL}" == "" ]]; then
RFVOL=19
fi
gum style --foreground 212 "${RFVOL}"
gum style --foreground "#04B575" "Enter RF compression [1-8] (default 2):"
CPVOL=$(gum input --value "${OLDCPVOL}")
if [[ "${CPVOL}" == "" ]]; then
RFVOL=2
fi
gum style --foreground 212 "${CPVOL}"
EPOCH=$(date +%s)
gum confirm "Commit changes?"
RESULT=$?
if [ $RESULT -eq 0 ]; then
say "Backup old config"
run "cp /etc/svxlink/svxlink.conf /tmp/svxlink.conf.${EPOCH}"
run "cp /etc/svxlink/node_info.json /tmp/node_info.json.${EPOCH}"
run "rm -f /tmp/svxlink.conf"
say "Downloading latest sa818 firmware module"
run "wget -O /usr/local/bin/sa818 https://raw.githubusercontent.com/Guru-RF/SA818/main/sa818.py > /dev/null 2>&1"
run "chmod +x /usr/local/bin/sa818"
say "Downloading fmchip-monitor"
run "wget -O /usr/sbin/fmchip-monitor https://raw.githubusercontent.com/Guru-RF/SVXSpot/master/fmchip-monitor.py > /dev/null 2>&1"
run "chmod +x /usr/sbin/fmchip-monitor"
say "Downloading latest config template"
run "wget -O /tmp/svxlink.conf https://raw.githubusercontent.com/Guru-RF/SVXSpot/master/svxlink-6.6.conf > /dev/null 2>&1"
run "wget -O /tmp/node_info.json https://raw.githubusercontent.com/Guru-RF/SVXSpot/master/node_info.json > /dev/null 2>&1"
say "Applying configuration"
cp /tmp/svxlink.conf /etc/svxlink/svxlink.conf
cp /tmp/node_info.json /etc/svxlink/node_info.json
perl -i -pe "s/--HOST--/${REFLECTOR}/g" /etc/svxlink/svxlink.conf
perl -i -pe "s/--TONE--/${TONE}/g" /etc/svxlink/svxlink.conf
perl -i -pe "s/--CALL--/${CALL}/g" /etc/svxlink/svxlink.conf
perl -i -pe "s/--CTCSSMAPPING--/${CTCSSMAPPING}/g" /etc/svxlink/svxlink.conf
perl -i -pe "s/--TGS--/${TGS}/g" /etc/svxlink/svxlink.conf
perl -i -pe "s/--CALL--/${CALL}/g" /etc/svxlink/node_info.json
perl -i -pe "s/--SVXCALL--/${SVXCALL}/g" /etc/svxlink/svxlink.conf
perl -i -pe "s/--SVXPWD--/${SVXPWD}/g" /etc/svxlink/svxlink.conf
perl -i -pe "s/--LOCATION--/${LOCATION}/g" /etc/svxlink/node_info.json
perl -i -pe "s/--LAT--/${LAT}/g" /etc/svxlink/node_info.json
perl -i -pe "s/--LON--/${LON}/g" /etc/svxlink/node_info.json
perl -i -pe "s/--LOC--/${LOC}/g" /etc/svxlink/node_info.json
perl -i -pe "s/--HIDDEN--/${HIDDEN,,}/g" /etc/svxlink/node_info.json
rm /usr/sbin/hotspot
say "Configuring hotspot"
echo "#!/bin/bash" > /usr/sbin/hotspot
echo "" >> /usr/sbin/hotspot
if [[ "${CTCSSTX}" == "Yes" ]]; then
echo "sa818 --port /dev/ttyAMA0 radio --bw 1 --frequency ${FREQ} --ctcss ${CTCSS},0 --tail close --squelch 8" >> /usr/sbin/hotspot
else
echo "sa818 --port /dev/ttyAMA0 radio --bw 1 --frequency ${FREQ} --squelch 8" >> /usr/sbin/hotspot
fi
echo "sa818 --port /dev/ttyAMA0 filters --emphasis disable --highpass disable --lowpass disable" >> /usr/sbin/hotspot
echo "sa818 --port /dev/ttyAMA0 volume --level ${CPVOL}" >> /usr/sbin/hotspot
chmod +x /usr/sbin/hotspot
/usr/sbin/hotspot
say "Configuring hotspot volume"
echo "#!/bin/bash" > /usr/sbin/hotspot_volume
echo "" >> /usr/sbin/hotspot_volume
echo "# audio to radio Module" >> /usr/sbin/hotspot_volume
echo "amixer set 'Headphone' ${AFVOL}%" >> /usr/sbin/hotspot_volume
echo "# audio from radio Module" >> /usr/sbin/hotspot_volume
echo "amixer set 'Capture' ${RFVOL}%" >> /usr/sbin/hotspot_volume
echo "" >> /usr/sbin/hotspot_volume
echo "
# Disable ALC en Deemphasis
amixer cset iface=MIXER,name='DAC Deemphasis Switch' 0
amixer cset iface=MIXER,name='ALC Function' 0
amixer cset iface=MIXER,name='ALC Target' 0
amixer cset iface=MIXER,name='ALC Mode' 1
amixer cset iface=MIXER,name='ALC Attack' 0
amixer cset iface=MIXER,name='ALC Decay' 0
amixer cset iface=MIXER,name='ALC Hold Time' 0
amixer cset iface=MIXER,name='ALC Max Gain' 0
amixer cset iface=MIXER,name='ALC Min Gain' 0
amixer cset iface=MIXER,name='ADC High Pass Filter Switch' 0" >> /usr/sbin/hotspot_volume
/usr/sbin/hotspot_volume > /dev/null 2>&1
systemctl restart svxlink
systemctl restart fmchip-monitor
say "Send any CTCSS tone to ${FREQ} with D1# to activate the parrot (to test audio levels)"
say "Send CTCSS tone mapped to a channel to switch talkgroup (only when there is no traffic and you are in TG0)"
say "You here a small two-tone when we are back in listening mode on TG0, when there is traffic on a monitored it will be automaticaly activated !"
else
gum style --foreground "#04B575" "Abort!"
fi