Freeze Image on Device

When scaling to production, provisioning each device manually could be a time-consuming task. JFrog Connect enables you to register devices automatically by embedding the Connect Agent in your device.

This page describes how to install the Connect Agent on a fleet of devices without the need to register each device manually.

Prerequisites

You need the following before starting the procedure:

  • Devices meet minimum hardware, OS, and software requirements as described in Connect Agent

  • Internet connectivity with the devices

  • JFrog Connect account created and a project defined as described in Create JFrog Connect Account

Register a Single Device

Complete the following steps:

  1. Install Connect Agent on a single device by completing the procedure in Register a Device.

  2. Disconnect the device from the Internet.

Prepare the Settings File

  1. Delete the settings.json file at the path indicated below: /etc/connect/service/settings.json

  2. Create a new settings.json file in the same location and add the following content: {"user_token":"<user_token>", "project_name":"<project_name>", "device_name":"", "device_group":"", "software_version":"", "device_token":""}

  3. Change the <user_token> to your account token. (You can find your token in the Connect web UI under Settings.)

  4. Change the <project_name> to the project you want the device to be registered to. (You can find your projects in the Connect web UI under Settings.)

  5. (Optional) You could set the value of <device_name> to “$HOSTNAME” or to some other variable. Then the device name that appears in the web UI will be the host name of each device (or a different name depending on the variable you use for the <device_name> value.

  6. Save the file. Do not reconnect the device to the Internet until you have duplicated the image.

Duplicate and Distribute the Image

  1. Duplicate this device image, and burn it on other SD cards or eMMC flashes.

  2. Boot a new device that has the duplicated image. Connect Agent will automatically recognize that it is running on new hardware and will register the device as a new device.

  3. Repeat the step above for all of the devices with the new image.

Tip: For some agent sub-versions, the branding and name of Connect is defined as Upswift. If the directory/service name/ of Connect does not exist, check for a directory called Upswift.

The new devices now appear in the Web UI on the Devices page. You can view them there and edit any of the details as necessary.

Set Device Name and Group Automatically

You can set the device name and group automatically either before or after the devices are registered.

After the device registers to the platform, the settings.json file is encrypted and you will not be able to modify it anymore.

Set after Registration

The device name and group can be changed using Connect REST API - Change Device Details. By using the API, you can run a script on the device that will change the name and group after device registration.

Set before Registration

You can set the device name and group by setting the <device_name> and <device_group> keys in the settings.json file before the device registers to the platform. This means that you are creating a unique settings file for each device, so it is recommended to write a script that will generate the files.

Tip: If you use this method, ensure that the groups you use already exist.

In order to set the device name and group correctly, we recommend including the following steps in your script:

  1. Run a script on the device boot using crontab or init.d.

  2. Check if /etc/connect/service/settings.json already exists. If it exists, finish the script.

  3. If it doesn't exist, generate the device name (by any method you would like).

  4. Create the /etc/connect/service/settings.json file including the correct values.

  5. Change the file permissions by running chmod 777 /etc/connect/service/settings.json

If no device name or group has been defined, the Connect Agent will register the device with a generic name “New device” to the group “Production”.

Get Device Token

If you are using the REST API, you will need the device token. To receive the device token, run the agent binary with the flag --print-token. The command is:

/etc/connect/service/ConnectAgent --print-token

What’s Next?

Learn how to build an image that includes your OS and the Connect Agent binary.

Last updated