Skip to content

Commit d8c076e

Browse files
committed
Fix do_copy_concentratord_config. Fix indentation.
1 parent 59fab87 commit d8c076e

File tree

1 file changed

+79
-79
lines changed

1 file changed

+79
-79
lines changed

layers/targets/meta-raspberrypi/recipes-core/gateway-config/files/gateway-config.sh

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ do_setup_ic880a() {
7878
do_main_menu
7979
elif [ $RET -eq 0 ]; then
8080
case "$FUN" in
81-
1) do_copy_concentratord_config "sx1301" "imst_ic880a_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";
81+
1) do_copy_concentratord_config "sx1301" "imst_ic880a_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";
8282
esac
8383
fi
8484
}
@@ -106,7 +106,7 @@ do_setup_imst_lite() {
106106
do_main_menu
107107
elif [ $RET -eq 0 ]; then
108108
case "$FUN" in
109-
1) do_copy_concentratord_config "sx1301" "imst_ic880a_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";
109+
1) do_copy_concentratord_config "sx1301" "imst_ic880a_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";
110110
esac
111111
fi
112112
}
@@ -121,7 +121,7 @@ do_setup_pislora() {
121121
do_main_menu
122122
elif [ $RET -eq 0 ]; then
123123
case "$FUN" in
124-
1) do_copy_concentratord_config "sx1301" "generic_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";;
124+
1) do_copy_concentratord_config "sx1301" "generic_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";;
125125
2) do_select_us915_block "sx1301" "generic_us915" "";;
126126
esac
127127
fi
@@ -157,7 +157,7 @@ do_setup_rhf0m301() {
157157
do_main_menu
158158
elif [ $RET -eq 0 ]; then
159159
case "$FUN" in
160-
1) do_copy_concentratord_config "sx1301" "generic_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";;
160+
1) do_copy_concentratord_config "sx1301" "generic_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";;
161161
2) do_select_us915_block "sx1301" "generic_us915" "";;
162162
esac
163163
fi
@@ -173,7 +173,7 @@ do_setup_lorago_port() {
173173
do_main_menu
174174
elif [ $RET -eq 0 ]; then
175175
case "$FUN" in
176-
1) do_copy_concentratord_config "sx1301" "generic_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";;
176+
1) do_copy_concentratord_config "sx1301" "generic_eu868" "" "eu868" "0" && do_copy_chirpstack_ns_config "eu868";;
177177
2) do_select_us915_block "sx1301" "generic_us915" "";;
178178
esac
179179
fi
@@ -197,8 +197,8 @@ do_setup_semtech_corecell() {
197197

198198
do_select_us915_block() {
199199
# $1: concentratord version
200-
# $2: model
201-
# $3: model flags
200+
# $2: model
201+
# $3: model flags
202202
FUN=$(dialog --title "Channel-plan configuration" --menu "Select the US915 channel-block:" 15 60 8 \
203203
1 "Channels 0 - 7 + 64" \
204204
2 "Channels 8 - 15 + 65" \
@@ -214,22 +214,22 @@ do_select_us915_block() {
214214
do_main_menu
215215
elif [ $RET -eq 0 ]; then
216216
case "$FUN" in
217-
1) do_copy_concentratord_config $1 $2 $3 "us915" "0" && do_copy_chirpstack_ns_config "us915_0";;
218-
2) do_copy_concentratord_config $1 $2 $3 "us915" "1" && do_copy_chirpstack_ns_config "us915_1";;
219-
3) do_copy_concentratord_config $1 $2 $3 "us915" "2" && do_copy_chirpstack_ns_config "us915_2";;
220-
4) do_copy_concentratord_config $1 $2 $3 "us915" "3" && do_copy_chirpstack_ns_config "us915_3";;
221-
5) do_copy_concentratord_config $1 $2 $3 "us915" "4" && do_copy_chirpstack_ns_config "us915_4";;
222-
6) do_copy_concentratord_config $1 $2 $3 "us915" "5" && do_copy_chirpstack_ns_config "us915_5";;
223-
7) do_copy_concentratord_config $1 $2 $3 "us915" "6" && do_copy_chirpstack_ns_config "us915_6";;
224-
8) do_copy_concentratord_config $1 $2 $3 "us915" "7" && do_copy_chirpstack_ns_config "us915_7";;
217+
1) do_copy_concentratord_config "$1" "$2" "$3" "us915" "0" && do_copy_chirpstack_ns_config "us915_0";;
218+
2) do_copy_concentratord_config "$1" "$2" "$3" "us915" "1" && do_copy_chirpstack_ns_config "us915_1";;
219+
3) do_copy_concentratord_config "$1" "$2" "$3" "us915" "2" && do_copy_chirpstack_ns_config "us915_2";;
220+
4) do_copy_concentratord_config "$1" "$2" "$3" "us915" "3" && do_copy_chirpstack_ns_config "us915_3";;
221+
5) do_copy_concentratord_config "$1" "$2" "$3" "us915" "4" && do_copy_chirpstack_ns_config "us915_4";;
222+
6) do_copy_concentratord_config "$1" "$2" "$3" "us915" "5" && do_copy_chirpstack_ns_config "us915_5";;
223+
7) do_copy_concentratord_config "$1" "$2" "$3" "us915" "6" && do_copy_chirpstack_ns_config "us915_6";;
224+
8) do_copy_concentratord_config "$1" "$2" "$3" "us915" "7" && do_copy_chirpstack_ns_config "us915_7";;
225225
esac
226226
fi
227227
}
228228

229229
do_select_au915_block() {
230230
# $1: concentratord version
231-
# $2: model
232-
# $3: model flags
231+
# $2: model
232+
# $3: model flags
233233
FUN=$(dialog --title "Channel-plan configuration" --menu "Select the AU915 channel-block:" 15 60 8 \
234234
1 "Channels 0 - 7 + 64" \
235235
2 "Channels 8 - 15 + 65" \
@@ -245,21 +245,21 @@ do_select_au915_block() {
245245
do_main_menu
246246
elif [ $RET -eq 0 ]; then
247247
case "$FUN" in
248-
1) do_copy_concentratord_config $1 $2 $3 "au915" "0" && do_copy_chirpstack_ns_config "au915_0";;
249-
2) do_copy_concentratord_config $1 $2 $3 "au915" "1" && do_copy_chirpstack_ns_config "au915_1";;
250-
3) do_copy_concentratord_config $1 $2 $3 "au915" "2" && do_copy_chirpstack_ns_config "au915_2";;
251-
4) do_copy_concentratord_config $1 $2 $3 "au915" "3" && do_copy_chirpstack_ns_config "au915_3";;
252-
5) do_copy_concentratord_config $1 $2 $3 "au915" "4" && do_copy_chirpstack_ns_config "au915_4";;
253-
6) do_copy_concentratord_config $1 $2 $3 "au915" "5" && do_copy_chirpstack_ns_config "au915_5";;
254-
7) do_copy_concentratord_config $1 $2 $3 "au915" "6" && do_copy_chirpstack_ns_config "au915_6";;
255-
8) do_copy_concentratord_config $1 $2 $3 "au915" "7" && do_copy_chirpstack_ns_config "au915_7";;
248+
1) do_copy_concentratord_config "$1" "$2" "$3" "au915" "0" && do_copy_chirpstack_ns_config "au915_0";;
249+
2) do_copy_concentratord_config "$1" "$2" "$3" "au915" "1" && do_copy_chirpstack_ns_config "au915_1";;
250+
3) do_copy_concentratord_config "$1" "$2" "$3" "au915" "2" && do_copy_chirpstack_ns_config "au915_2";;
251+
4) do_copy_concentratord_config "$1" "$2" "$3" "au915" "3" && do_copy_chirpstack_ns_config "au915_3";;
252+
5) do_copy_concentratord_config "$1" "$2" "$3" "au915" "4" && do_copy_chirpstack_ns_config "au915_4";;
253+
6) do_copy_concentratord_config "$1" "$2" "$3" "au915" "5" && do_copy_chirpstack_ns_config "au915_5";;
254+
7) do_copy_concentratord_config "$1" "$2" "$3" "au915" "6" && do_copy_chirpstack_ns_config "au915_6";;
255+
8) do_copy_concentratord_config "$1" "$2" "$3" "au915" "7" && do_copy_chirpstack_ns_config "au915_7";;
256256
esac
257257
fi
258258
}
259259

260260
do_set_concentratord() {
261-
monit stop chirpstack-concentratord
262-
sed -i "s/CONCENTRATORD_VERSION=.*/CONCENTRATORD_VERSION=\"$1\"/" /etc/default/chirpstack-concentratord
261+
monit stop chirpstack-concentratord
262+
sed -i "s/CONCENTRATORD_VERSION=.*/CONCENTRATORD_VERSION=\"$1\"/" /etc/default/chirpstack-concentratord
263263
}
264264

265265
do_prompt_concentrator_reset_pin() {
@@ -274,7 +274,7 @@ do_prompt_concentrator_reset_pin() {
274274
}
275275

276276
do_set_concentrator_reset_pin() {
277-
sed -i "s/CONCENTRATOR_RESET=.*/CONCENTRATOR_RESET=\"yes\"/" /etc/default/chirpstack-concentratord
277+
sed -i "s/CONCENTRATOR_RESET=.*/CONCENTRATOR_RESET=\"yes\"/" /etc/default/chirpstack-concentratord
278278
sed -i "s/CONCENTRATOR_RESET_PIN=.*/CONCENTRATOR_RESET_PIN=$1/" /etc/default/chirpstack-concentratord
279279
}
280280

@@ -283,47 +283,47 @@ do_set_concentratord_power_en_pin() {
283283
}
284284

285285
do_copy_concentratord_config() {
286-
# $1 concentratord version
287-
# $2 model
288-
# $3 model flags
289-
# $4 region
290-
# $5 sub-band
286+
# $1 concentratord version
287+
# $2 model
288+
# $3 model flags
289+
# $4 region
290+
# $5 sub-band
291291
RET=0
292292
if [ -f "/etc/chirpstack-concentratord/$1/global.toml" ] || [ -f "/etc/chirpstack-concentratord/$1/band.toml"] || [ -f "/etc/chirpstack-concentratord/$1/channels.toml" ]; then
293293
dialog --yesno "A ChirpStack Concentratord configuration file already exists. Do you want to overwrite it?" 6 60
294294
RET=$?
295295
fi
296296

297297
if [ $RET -eq 0 ]; then
298-
cp /etc/chirpstack-concentratord/$1/examples/global.toml /etc/chirpstack-concentratord/$1/global.toml
299-
cp /etc/chirpstack-concentratord/$1/examples/$4.toml /etc/chirpstack-concentratord/$1/band.toml
300-
cp /etc/chirpstack-concentratord/$1/examples/$4_$5.toml /etc/chirpstack-concentratord/$1/channels.toml
301-
302-
RET=$?
303-
if [ $RET -eq 0 ]; then
304-
# set model
305-
sed -i "s/model=.*/model=\"${2}\"/" /etc/chirpstack-concentratord/$1/global.toml
306-
307-
# set model flags
308-
IFS=' '; read -ra model_flags <<< $3
309-
model_flags_str=""
310-
for i in "${model_flags[@]}"; do model_flags_str="$model_flags_str\"$i\","; done
311-
sed -i "s/model_flags=.*/model_flags=[$model_flags_str]/" /etc/chirpstack-concentratord/$1/global.toml
312-
313-
# set gateway id
314-
GWID_MIDFIX="fffe"
315-
GWID_BEGIN=$(ip link show eth0 | awk '/ether/ {print $2}' | awk -F\: '{print $1$2$3}')
316-
GWID_END=$(ip link show eth0 | awk '/ether/ {print $2}' | awk -F\: '{print $4$5$6}')
317-
sed -i "s/gateway_id=.*/gateway_id=\"${GWID_BEGIN}${GWID_MIDFIX}${GWID_END}\"/" /etc/chirpstack-concentratord/$1/global.toml
318-
319-
dialog --title "Channel-plan configuration" --msgbox "Channel-plan configuration has been copied." 5 60
320-
do_restart_chirpstack_concentratord
321-
fi
298+
cp /etc/chirpstack-concentratord/$1/examples/global.toml /etc/chirpstack-concentratord/$1/global.toml
299+
cp /etc/chirpstack-concentratord/$1/examples/$4.toml /etc/chirpstack-concentratord/$1/band.toml
300+
cp /etc/chirpstack-concentratord/$1/examples/$4_$5.toml /etc/chirpstack-concentratord/$1/channels.toml
301+
302+
# set model
303+
sed -i "s/model=.*/model=\"${2}\"/" /etc/chirpstack-concentratord/$1/global.toml
304+
305+
# set model flags
306+
IFS=' '; read -ra model_flags <<< $3
307+
model_flags_str=""
308+
for i in "${model_flags[@]}"; do model_flags_str="$model_flags_str\"$i\","; done
309+
sed -i "s/model_flags=.*/model_flags=[$model_flags_str]/" /etc/chirpstack-concentratord/$1/global.toml
310+
311+
# set gateway id
312+
GWID_MIDFIX="fffe"
313+
GWID_BEGIN=$(ip link show eth0 | awk '/ether/ {print $2}' | awk -F\: '{print $1$2$3}')
314+
GWID_END=$(ip link show eth0 | awk '/ether/ {print $2}' | awk -F\: '{print $4$5$6}')
315+
sed -i "s/gateway_id=.*/gateway_id=\"${GWID_BEGIN}${GWID_MIDFIX}${GWID_END}\"/" /etc/chirpstack-concentratord/$1/global.toml
316+
317+
dialog --title "Channel-plan configuration" --msgbox "Channel-plan configuration has been copied." 5 60
322318
fi
319+
320+
# We do need to restart because it was stopped when setting the concentratord
321+
# version (sx1301 or sx1302).
322+
do_restart_chirpstack_concentratord
323323
}
324324

325325
do_copy_chirpstack_ns_config() {
326-
# $1 channel plan
326+
# $1 channel plan
327327
if [ ! -d /etc/chirpstack-network-server ]; then
328328
return;
329329
fi
@@ -358,22 +358,22 @@ do_edit_chirpstack_concentratord_config() {
358358
3>&1 1>&2 2>&3)
359359
RET=$?
360360
if [ $RET -eq 0 ]; then
361-
source /etc/default/chirpstack-concentratord
361+
source /etc/default/chirpstack-concentratord
362362

363363
case "$FUN" in
364-
1) nano "/etc/chirpstack-concentratord/${CONCENTRATORD_VERSION}/global.toml";;
365-
2) nano "/etc/chirpstack-concentratord/${CONCENTRATORD_VERSION}/band.toml";;
366-
3) nano "/etc/chirpstack-concentratord/${CONCENTRATORD_VERSION}/channels.toml";;
364+
1) nano "/etc/chirpstack-concentratord/${CONCENTRATORD_VERSION}/global.toml";;
365+
2) nano "/etc/chirpstack-concentratord/${CONCENTRATORD_VERSION}/band.toml";;
366+
3) nano "/etc/chirpstack-concentratord/${CONCENTRATORD_VERSION}/channels.toml";;
367367
esac
368368
fi
369369
}
370370

371371
do_edit_chirpstack_gateway_bridge_config() {
372-
nano /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
372+
nano /etc/chirpstack-gateway-bridge/chirpstack-gateway-bridge.toml
373373
}
374374

375375
do_restart_chirpstack_concentratord() {
376-
monit restart chirpstack-concentratord
376+
monit restart chirpstack-concentratord
377377
RET=$?
378378
if [ $RET -eq 0 ]; then
379379
dialog --title "Restart ChirpStack Concentratord" --msgbox "The ChirpStack Concentratord has been restarted." 5 60
@@ -393,37 +393,37 @@ do_restart_chirpstack_gateway_bridge() {
393393
}
394394

395395
do_configure_wifi() {
396-
NAME=$(dialog --title "Configure WIFI" --inputbox "Please enter the name of WiFi network: " 8 60 \
396+
NAME=$(dialog --title "Configure WIFI" --inputbox "Please enter the name of WiFi network: " 8 60 \
397397
3>&1 1>&2 2>&3)
398398
RET=$?
399-
if [ ! $RET -eq 0 ]; then
400-
do_main_menu
401-
fi
399+
if [ ! $RET -eq 0 ]; then
400+
do_main_menu
401+
fi
402402

403-
PASSWORD=$(dialog --title "Configure WIFI" --inputbox "Please enter the password: " 8 60 \
403+
PASSWORD=$(dialog --title "Configure WIFI" --inputbox "Please enter the password: " 8 60 \
404404
3>&1 1>&2 2>&3)
405405
RET=$?
406-
if [ ! $RET -eq 0 ]; then
407-
do_main_menu
408-
fi
409-
410-
dialog --title "Configure WIFI" --msgbox "The system will reboot to apply the new configuration." 5 60
406+
if [ ! $RET -eq 0 ]; then
407+
do_main_menu
408+
fi
409+
410+
dialog --title "Configure WIFI" --msgbox "The system will reboot to apply the new configuration." 5 60
411411

412-
cat > /var/lib/connman/wifi.config << EOF
412+
cat > /var/lib/connman/wifi.config << EOF
413413
[service_wifi]
414414
Type=wifi
415415
Name=$NAME
416416
Passphrase=$PASSWORD
417417
IPv4=dhcp
418418
EOF
419419

420-
sed -i "s/Tethering=true/Tethering=false/" /var/lib/connman/settings
421-
reboot
420+
sed -i "s/Tethering=true/Tethering=false/" /var/lib/connman/settings
421+
reboot
422422
}
423423

424424
if [ $EUID -ne 0 ]; then
425-
echo "This script must be run as root"
426-
exit 1
425+
echo "This script must be run as root"
426+
exit 1
427427
fi
428428

429429
do_main_menu

0 commit comments

Comments
 (0)