blob: a66bda5b3c8ed1e25bfbf00d9002249c31177bae (
plain)
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
|
#!/bin/bash
echo "Disconnect old bridge"
# Disconnect - may fail if not there
sudo tedge disconnect c8y
# From now on exit if a command exits with a non-zero status.
# Commands above are allowed to fail
set -e
echo "Configuring Bridge"
URL=$(echo $C8YURL | cut -c 9- - )
sudo tedge cert remove
sudo tedge cert create --device-id=$C8YDEVICE
sudo tedge cert show
sudo tedge config set c8y.url $URL
sudo tedge config set c8y.root.cert.path /etc/ssl/certs
sudo tedge config set az.url $IOTHUBNAME.azure-devices.net
sudo tedge config set az.root.cert.path /etc/ssl/certs/Baltimore_CyberTrust_Root.pem
sudo tedge config list
# Note: This will always upload a new certificate. From time to time
# we should delete the old ones in c8y
sudo -E tedge cert upload c8y --user $C8YUSERNAME
cat /etc/mosquitto/mosquitto.conf
python3 -m venv ~/env-c8y-api
source ~/env-c8y-api/bin/activate
pip3 install c8y-api
# Delete the device (ignore error)
set +e
python3 ./ci/delete_current_device_c8y.py --tenant $C8YTENANT --user $C8YUSERNAME --device $C8YDEVICE --url $C8YURL
set -e
# Give Cumolocity time to process the cert deletion
sleep 2
# Connect and disconnect so that we can retrive a new device ID
sudo tedge connect c8y
sudo tedge disconnect c8y
# Give Cumolocity time to process the cert deletion
sleep 2
# Retrieve the Cumulocity device ID
export C8YDEVICEID=$(python3 ./ci/find_device_id.py --tenant $C8YTENANT --user $C8YUSERNAME --device $C8YDEVICE --url $C8YURL)
echo "The current device ID is (read from home directory): " $C8YDEVICEID
deactivate
|