-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
81 lines (60 loc) · 1.72 KB
/
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
#!/bin/bash
# Stop on the first sign of trouble
set -e
if [ $UID != 0 ]; then
echo "ERROR: Operation not permitted. Forgot sudo?"
exit 1
fi
#$1=create_img
SCRIPT_COMMON_FILE=$(pwd)/rak/rak/shell_script/rak_common.sh
source $SCRIPT_COMMON_FILE
rpi_model=`do_get_rpi_model`
ARGS=`getopt -o "" -l "help,img,chirpstack:" -- "$@"`
eval set -- "${ARGS}"
INSTALL_CHIRPSTACK=1
CREATE_IMG=""
# select gw model
#./choose_model.sh $CREATE_IMG
JSON_FILE=./rak/rak/rak_gw_model.json
RAK_GW_JSON=./rak/rak/gateway-config-info.json
INSTALL_LTE=0
function echo_yellow()
{
echo -e "\033[1;33m$1\033[0m"
}
echo_yellow "---------------------------------------------------"
echo_yellow "----------------RAK2247(USB)-----------------------"
echo_yellow "---------------------------------------------------"
GW_MODEL=RAK2247
function do_set_spi_to_json()
{
JSON_FILE=./rak/rak/rak_gw_model.json
linenum=`sed -n "/spi/=" $JSON_FILE`
sed -i "${linenum}c\\\\t\"spi\": \"$1\"" $JSON_FILE
}
do_set_spi_to_json 0
linenum=`sed -n "/gw_model/=" $JSON_FILE`
sed -i "${linenum}c\\\\t\"gw_model\": \"$GW_MODEL\"," $JSON_FILE
linenum=`sed -n "/install_lte/=" $RAK_GW_JSON`
sed -i "${linenum}c\\\\t\"install_lte\": \"$INSTALL_LTE\"," $RAK_GW_JSON
apt update
pushd rak
./install.sh $CREATE_IMG
sleep 1
popd
set +e
write_json_chirpstack_install $INSTALL_CHIRPSTACK
set -e
if [ "$INSTALL_CHIRPSTACK" = 1 ]; then
pushd chirpstack
./install.sh $CREATE_IMG
sleep 1
popd
fi
pushd lora
./install.sh $CREATE_IMG
sleep 1
popd
echo_success "*********************************************************"
echo_success "* The RAKwireless gateway is successfully installed! *"
echo_success "*********************************************************"