Install Tik CLI

Table of Contents

Install tik CLI

The tik CLI is the core application that runs on each Tiktag Edge Node. It is responsible for interacting with the node’s hardware (scanners, sensors via BLE), capturing real-time Resource Usage Event Records, writing them to the local Immudb database, and publishing these events to the cloud NATS Cluster via JetStream for replication.

This guide is intended for members of the Device Provisioning Team responsible for setting up new Edge Nodes.

Prerequisites

Before installing the tik CLI, ensure you have the following set up:

  • Tiktag Edge Node Hardware: A NanoPi NEO Air/M4 device properly assembled with integrated scanner and ESP32 components, connected to power and the network.
  • Operating System: A compatible Linux distribution installed and running on the NanoPi (e.g., Armbian, FriendlyCore). You should have SSH access or a terminal session with the device.
  • Go Runtime: Go 1.18 or later installed on the NanoPi.
  • Local Immudb Server: An instance of the Immudb Server installed and running on the NanoPi, configured for local access (e.g., default ports).
  • Local NATS Server (Optional but Recommended): An instance of the NATS Server installed and running locally if you are using a local NATS for queuing before publishing to the cloud cluster. If connecting directly to the cloud NATS cluster, ensure network connectivity is configured.

Tip

It is highly recommended to fully set up and verify the base Linux OS, Go runtime, and local Immudb/NATS servers before attempting to install tik CLI. Consult the respective installation guides for these components.

Warning

Some installation and configuration steps may require root or sudo privileges on the Edge Node. Proceed with caution and ensure you understand the commands you are executing.

Installation Steps

The tik CLI is distributed as a single binary for the Linux ARM architecture compatible with the NanoPi.

  1. Download the Binary: Download the latest tik binary for Linux ARM from the official releases page. You can do this directly on the NanoPi using wget or curl.

    # Example using wget (replace URL with the actual release URL)
    wget [https://github.com/tiktagus/tiktag-etcd/releases/download/v1.0.0/tik_linux_arm](https://github.com/tiktagus/tiktag-etcd/releases/download/v1.0.0/tik_linux_arm)
    
    Download Latest tik Binary
  2. Make the Binary Executable: Grant execute permissions to the downloaded file.

    chmod +x ./tik_linux_arm
    
  3. Move the Binary to a PATH Directory: Move the executable to a directory included in the system’s PATH (e.g., /usr/local/bin) so you can run it from anywhere. This step usually requires sudo.

    sudo mv ./tik_linux_arm /usr/local/bin/tik
    

Info

For developers contributing to tik CLI, you can also build the binary directly from source code on a development machine using cross-compilation and then transfer it to the NanoPi. Consult the project’s README for build instructions.

Initial Configuration

The tik CLI requires configuration to connect to the local Immudb server, the cloud NATS Cluster, and potentially receive initial settings. Configuration can typically be provided via a configuration file or environment variables.

  • Using a Configuration File
  • Using Environment Variables

tik.yaml Configuration File

Create a configuration file (e.g., tik.yaml) on the Edge Node. A common location is /etc/tik/tik.yaml or $HOME/.config/tik/tik.yaml.

# /etc/tik/tik.yaml or ~/.config/tik/tik.yaml

immudb:
  address: "127.0.0.1:3322" # Default Immudb address
  database: "defaultdb"
  username: "immudb"
  password: "your_immudb_password" # Replace with your Immudb password
  # Add TLS config if Immudb is secured

nats:
  endpoints: "nats://your-cloud-nats-cluster.example.com:4222" # Replace with your cloud NATS endpoints
  # Or if using local NATS: "nats://127.0.0.1:4222"
  nkey_file: "/etc/tik/nats_nkey.txt" # Path to NATS NKey file for authentication (Recommended)
  # Or Username/Password:
  # username: "your_nats_username"
  # password: "your_nats_password"
  # Add TLS config if NATS is secured

edge_node:
  id: "node_nano_abcdef123456" # Unique identifier for this edge node (NanoPi serial?)
  project_name: "ProjectVolta" # The project this node belongs to
  # Add other local settings as needed

# Optional: Initial Cloud Discovery Endpoint (if not using fixed NATS endpoint)
# discovery_endpoint: "[https://cloud.tiktag.app/api/v1/discover/nats](https://cloud.tiktag.app/api/v1/discover/nats)"

You can also configure the tik CLI using environment variables. This is useful for temporary or dynamic configurations.

export IMMUDb_ADDRESS="127.0.0.1:3322"
export IMMUDb_DATABASE="defaultdb"
export IMMUDb_USERNAME="immudb"
export IMMUDb_PASSWORD="your_immudb_password"

export NATS_ENDPOINTS="nats://your-cloud-nats-cluster.example.com:4222"
export NATS_NKEY_FILE="/etc/tik/nats_nkey.txt"

export EDGE_NODE_ID="node_nano_abcdef123456"
export EDGE_NODE_PROJECT_NAME="ProjectVolta"