Skip to content

Installing Robotair with the Installation Script

Estimated time to read: 8 minutes

This guide walks you through the Robotair installation script step by step. We’ve designed it to be transparent, so you know exactly what’s happening at every stage. By understanding the script's operations, you can confidently run it on your system.


Overview

The Robotair installation script simplifies the setup process for the Robotair client application. It performs the following tasks:

  1. Handles User Inputs: Accepts the robot ID and robot token as arguments.
  2. Checks and Installs Dependencies: Verifies and installs necessary software components.
  3. Configures Systemd Services: Sets up user-level systemd services for Robotair.
  4. Starts the Robotair Client: Initializes the Robotair client application.

By automating these steps, the script ensures a smooth installation experience and reduces the potential for errors.


Prerequisites

Before running the script, ensure the following:

  • You are using a debian based operating system (e.g., Ubuntu).
  • You have user-level permissions to install software and configure services.
  • You have your Robot ID and Robot Token ready.

Installation Methods

There are two methods to install the Robotair client:

  1. Quick Installation via Curl: Ideal for quick setups.
  2. Manual Installation: Offers more control and transparency over the installation process.

Quick Installation via Curl


You can install the Robotair client quickly by running the following command in your terminal:

  1. Run the Installation Command:

    curl -sSL get.robotair.io | bash -s <robot_id> <robot_token>
    
    • Replace <robot_id> with your actual Robot ID.
    • Replace <robot_token> with your actual Robot Token.
  2. Monitor the Installation Process:

    • The script will run and display messages indicating its progress.
    • If any step fails, the script will exit with an error message.
  3. Verify the Installation:

    • After the script completes, you can check the status of the Robotair service:

      systemctl --user status robotair.service
      

Manual Installation


If you prefer to understand each step of the installation or need more control, follow the manual installation instructions detailed below.

  1. Prepare Your Environment:

    • Ensure you are running a Unix-like operating system.
    • Verify that you have the necessary permissions to install software and configure services.
    • Obtain your Robot ID and Robot Token from the Robotair platform.
  2. Download the Script:

    • Download the installation script from https://get.robotair.io/
    • Save the installation script as (install.sh) to your local machine.
    • Ensure the script has execution permissions:

      chmod +x install.sh
      
  3. Run the Script with Required Arguments:

    ./install.sh <robot_id> <robot_token> [-v|--verbose]
    
    • Replace <robot_id> with your actual Robot ID.
    • Replace <robot_token> with your actual Robot Token.
    • Optionally, add -v or --verbose to enable detailed output.
  4. Monitor the Installation Process:

    • The script will display messages indicating its progress.
    • If any step fails, the script will exit with an error message.
  5. Verify the Installation:

    • After the script completes, you can check the status of the Robotair service:

      systemctl --user status robotair.service
      
  6. Review the Script (Optional but Recommended):

    • Open the script in a text editor to review the commands and functions.
    • Ensure you're comfortable with the actions it will perform.

Script Breakdown

Variable Definitions

The script begins by defining several variables used throughout the installation process:
  • URLs and Package Names:

    • PIP_URL: The URL for the Python package index hosting Robotair's packages.
    • HOST_URL: The host URL required for SSH operations (github.com).
    • PACKAGE_NAME: The name of the Robotair client package (robotair-client).
  • Python Configuration:

    • PYTHON_MINIMUM_VERSION: The minimum required Python version (3.8.0).
  • Service and Socket Configuration:

    • SERVICE_NAME, SERVICE_DESCRIPTION: Names and descriptions for the systemd service.
    • SOCKET_NAME, SOCKET_DESCRIPTION, SOCKET_PATH: Names, descriptions, and paths for the systemd socket.
  • Color Codes:

    • Variables like RED, GREEN, YELLOW, etc., are used to format terminal output for better readability.

Utility Functions

These functions modularize tasks for clarity and reusability:
  • print_message(type, message): Formats and displays messages based on the specified type (e.g., success, error, info).

  • handle_arguments(): Processes command-line arguments to extract the robot ID and robot token. It also handles the verbose flag.

  • run(command): Executes commands while suppressing their output.

  • check(command): Checks the exit status of commands.

  • dependency_installation(installed, install_function, message, skip_message): Determines whether to install a dependency based on its installation status.

  • service_configuration(configured, configure_function, skip_message): Manages the configuration of system services.

  • check_installation_status(status, success_msg, error_msg): Verifies if the installation steps were successful.

  • version_equal_or_newer_than(version1, version2): Compares two software version numbers.

Installation Functions

These functions ensure all necessary dependencies are installed:
  • install_python():

    • Checks for Python 3 installation.
    • Verifies the installed Python version meets the minimum requirement.
    • Note: If Python is not installed, the script exits with an error.
  • install_pip():

    • Installs pip if it's not already installed.
    • Downloads get-pip.py and runs it using the Python interpreter.
  • install_pipx():

    • Installs pipx using pip.
    • Ensures pipx is added to the user's PATH.
  • install_ensurepip():

    • Installs ensurepip via the system package manager (apt).
  • install_docker():

    • Installs Docker in rootless mode.
    • Installs uidmap and sets up a rootless Docker environment.
  • host_authenticity():

    • Adds the HOST_URL to the SSH known_hosts file to prevent authenticity prompts.
  • install_robotair_client():

    • Installs the robotair-client package using pipx.
    • Configures pip to use the specified PIP_URL.
  • configure_path():

    • Ensures the directory where pipx installs applications is in the user's PATH.

Service Configuration Functions

These functions set up and manage systemd services for the Robotair client:
  • socket_definition():

    • Creates a systemd socket unit file for the Robotair client.
    • Defines where the socket listens (e.g., /tmp/robotair.sock).
  • service_definition():

    • Creates a systemd service unit file for the Robotair client.
    • Sets up the execution environment and dependencies.
  • socket_activation():

    • Reloads systemd and enables the socket using systemctl --user.
  • service_activation():

    • Reloads systemd and enables the service using systemctl --user.

Step-by-Step Execution

1. Handling Command-Line Arguments

Handling Command-Line Arguments
  • Purpose: To obtain the necessary credentials (robot_id and robot_token) and set verbosity.
  • Process:
    • The script checks for the -v or --verbose flag.
    • It assigns the first two positional arguments to ROBOT_ID and ROBOT_TOKEN.
    • If these arguments are missing, the script exits with usage instructions.

2. Checking and Installing Dependencies

Checking and Installing Dependencies

For each dependency, the script:

  • Checks if it is installed using the check() function.
  • Installs it if not present using the respective installation function.

Dependencies are

  1. Python 3: Ensures Python 3 is installed and meets the minimum version requirement.

  2. pip: Installs pip if it's not found.

  3. pipx: Installs pipx if it's not found.

  4. ensurepip: Installs ensurepip using apt.

  5. Docker: Installs Docker in rootless mode if it's not found.

  6. SSH Host Authenticity: Adds HOST_URL to ~/.ssh/known_hosts if it's not already present.

  7. Robotair Client: Installs the robotair-client package via pipx if it's not already installed.

  8. PATH Configuration: Ensures the pipx binary directory is included in the user's PATH.

3. Configuring Systemd Services

Configuring Systemd Services
  • Socket Definition:

    • The script creates a socket unit file that defines where and how the Robotair client listens for connections.
  • Service Definition:

    • It creates a service unit file that specifies how to start and manage the Robotair client application.
  • Activation:

    • The script reloads systemd to recognize the new unit files.
    • It then enables and starts both the socket and the service using systemctl --user.

4. Starting the Robotair Client

Starting the Robotair Client
  • Execution:

    • The script runs the command:
    robotair start --force "$ROBOT_ID" "$ROBOT_TOKEN"
    
    • The --force flag ensures the client starts even if it's already running.