-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-gatewayrs.sh
More file actions
executable file
·61 lines (51 loc) · 1.48 KB
/
start-gatewayrs.sh
File metadata and controls
executable file
·61 lines (51 loc) · 1.48 KB
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
#!/bin/bash
rm -f settings.toml
rm -f /etc/helium_gateway/settings.toml
echo "Checking for I2C device"
mapfile -t data < <(i2cdetect -y 1)
for i in $(seq 1 ${#data[@]}); do
# shellcheck disable=SC2206
line=(${data[$i]})
# shellcheck disable=SC2068
if echo ${line[@]:1} | grep -q 60; then
echo "ECC is present."
ECC_CHIP=True
fi
done
if [[ -v REGION_OVERRIDE ]]
then
echo 'region = "'"${REGION_OVERRIDE}\"" >> settings.toml
else
echo "REGION_OVERRIDE not set"
exit 1
fi
if [[ -v ECC_CHIP ]]
then
echo "Using ECC for public key."
echo 'keypair = "ecc://i2c-1:96&slot=0"' >> settings.toml
elif [ -f "/var/data/gateway_key.bin" ]
then
echo "Key file already exists"
echo 'keypair = "/var/data/gateway_key.bin"' >> settings.toml
else
echo "Copying key file to persistent storage"
if ! PUBLIC_KEYS=$(/usr/bin/helium_gateway -c /etc/helium_gateway key info)
then
echo "Can't get miner key info"
exit 1
else
cp /etc/helium_gateway/gateway_key.bin /var/data/gateway_key.bin
echo 'keypair = "/var/data/gateway_key.bin"' >> settings.toml
fi
fi
cat /etc/helium_gateway/settings.toml.template >> settings.toml
cp settings.toml /etc/helium_gateway/settings.toml
# if ! PUBLIC_KEYS=$(/usr/bin/helium_gateway -c /etc/helium_gateway key info)
# then
# echo "Can't get miner key info"
# exit 1
# else
# echo "$PUBLIC_KEYS" > /var/data/key_json
# fi
# python3 /opt/nebra-gatewayrs/keys.py
/usr/bin/helium_gateway -c /etc/helium_gateway server