summaryrefslogtreecommitdiffstats
path: root/ci/configure_bridge.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/configure_bridge.sh')
-rwxr-xr-xci/configure_bridge.sh40
1 files changed, 39 insertions, 1 deletions
diff --git a/ci/configure_bridge.sh b/ci/configure_bridge.sh
index 5c1f9c77..a66bda5b 100755
--- a/ci/configure_bridge.sh
+++ b/ci/configure_bridge.sh
@@ -1,15 +1,25 @@
+#!/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 thin-edge-io.eu-latest.cumulocity.com
+sudo tedge config set c8y.url $URL
sudo tedge config set c8y.root.cert.path /etc/ssl/certs
@@ -24,3 +34,31 @@ sudo tedge config list
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
+