-
Notifications
You must be signed in to change notification settings - Fork 123
/
install.sh
executable file
·120 lines (98 loc) · 2.12 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
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
#!/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
SCRIPT_COMMON_FILE=$(pwd)/rak/rak/shell_script/rak_common.sh
source $SCRIPT_COMMON_FILE
print_help()
{
echo "--help Print help info."
echo ""
echo "--chirpstack=[install/not_install]"
echo " Chirpstack, default value is install"
echo ""
exit
}
rpi_model=`do_get_rpi_model`
ARGS=`getopt -o "" -l "help,img,chirpstack:" -- "$@"`
eval set -- "${ARGS}"
INSTALL_CHIRPSTACK=1
CREATE_IMG=""
while true; do
case "${1}" in
--help)
shift;
print_help
;;
--img)
shift;
CREATE_IMG="create_img"
;;
--chirpstack)
shift;
if [[ -n "${1}" ]]; then
if [ "not_install" = "${1}" ]; then
INSTALL_CHIRPSTACK=0
elif [ "install" = "${1}" ]; then
INSTALL_CHIRPSTACK=1
else
echo "invalid value"
exit
fi
if [ $rpi_model -ne 3 ] && [ $rpi_model -ne 4 ]; then
INSTALL_CHIRPSTACK=1
fi
shift;
fi
;;
--)
shift;
break;
;;
esac
done
if [[ $CREATE_IMG != "create_img" ]]; then
# select gw model
./choose_model.sh
fi
apt update
pushd rak
./install.sh $CREATE_IMG
sleep 1
popd
set +e
write_json_chirpstack_install $INSTALL_CHIRPSTACK
set -e
pushd ap
./install.sh $CREATE_IMG
sleep 1
popd
if [ "$INSTALL_CHIRPSTACK" = 1 ]; then
pushd chirpstack
./install.sh $CREATE_IMG
sleep 1
popd
fi
pushd lte
./install.sh $CREATE_IMG
sleep 1
popd
pushd lora
./install.sh $CREATE_IMG
sleep 1
popd
if [ "$CREATE_IMG" = "create_img" ]; then
pushd /usr/local/rak
mv bin bin_bak
popd
fi
pushd sysconf
./install.sh $CREATE_IMG
sleep 1
popd
echo_success "*********************************************************"
echo_success "* The RAKwireless gateway is successfully installed! *"
echo_success "*********************************************************"