Skip to content

Commit

Permalink
add workaround for thin-edge/thin-edge.io#2389
Browse files Browse the repository at this point in the history
Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
  • Loading branch information
reubenmiller committed Oct 30, 2023
1 parent 4e81df0 commit d85422e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions images/alpine-s6/cont-init.d/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,21 @@ if [ -n "$EXTERNAL_ID" ]; then
tedge config set http.bind.address "$EXTERNAL_ID"
tedge config set c8y.proxy.bind.address "$EXTERNAL_ID"
fi

# register device
TOPIC_ROOT=$(tedge config get mqtt.topic_root)
TOPIC_ID=$(tedge config get mqtt.device_topic_id)

# FIXME: Remove once https://github.com/thin-edge/thin-edge.io/issues/2389 is resolved
# A manual registration before the service starts up seems to prevent duplicate registration messages
case "$TOPIC_ID" in
device/main//)
;;
*)
echo "manually registering child-device" >&2
name=$(echo "$TOPIC_ID" | cut -d/ -f2)
body=$(printf '{"@type":"child-device","name":"%s"}' "$name")
tedge mqtt pub -r "$TOPIC_ROOT/$TOPIC_ID" "$body"
sleep 1
;;
esac

0 comments on commit d85422e

Please sign in to comment.