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:
- Handles User Inputs: Accepts the robot ID and robot token as arguments.
- Checks and Installs Dependencies: Verifies and installs necessary software components.
- Configures Systemd Services: Sets up user-level systemd services for Robotair.
- 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:
- Quick Installation via Curl: Ideal for quick setups.
- 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:
-
Run the Installation Command:
- Replace
<robot_id>
with your actual Robot ID. - Replace
<robot_token>
with your actual Robot Token.
- Replace
-
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.
-
Verify the Installation:
-
After the script completes, you can check the status of the 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.
-
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.
-
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:
- Download the installation script from
-
Run the Script with Required Arguments:
- 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.
- Replace
-
Monitor the Installation Process:
- The script will display messages indicating its progress.
- If any step fails, the script will exit with an error message.
-
Verify the Installation:
-
After the script completes, you can check the status of the Robotair service:
-
-
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.
- Variables like
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.
- Installs
-
install_pipx()
:- Installs
pipx
usingpip
. - Ensures
pipx
is added to the user'sPATH
.
- Installs
-
install_ensurepip()
:- Installs
ensurepip
via the system package manager (apt
).
- Installs
-
install_docker()
:- Installs Docker in rootless mode.
- Installs
uidmap
and sets up a rootless Docker environment.
-
host_authenticity()
:- Adds the
HOST_URL
to the SSHknown_hosts
file to prevent authenticity prompts.
- Adds the
-
install_robotair_client()
:- Installs the
robotair-client
package usingpipx
. - Configures
pip
to use the specifiedPIP_URL
.
- Installs the
-
configure_path()
:- Ensures the directory where
pipx
installs applications is in the user'sPATH
.
- Ensures the directory where
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
.
- Reloads systemd and enables the socket using
-
service_activation()
:- Reloads systemd and enables the service using
systemctl --user
.
- Reloads systemd and enables the service using
Step-by-Step Execution⿻
1. Handling Command-Line Arguments⿻
Handling Command-Line Arguments
- Purpose: To obtain the necessary credentials (
robot_id
androbot_token
) and set verbosity. - Process:
- The script checks for the
-v
or--verbose
flag. - It assigns the first two positional arguments to
ROBOT_ID
andROBOT_TOKEN
. - If these arguments are missing, the script exits with usage instructions.
- The script checks for the
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
-
Python 3: Ensures Python 3 is installed and meets the minimum version requirement.
-
pip: Installs
pip
if it's not found. -
pipx: Installs
pipx
if it's not found. -
ensurepip: Installs
ensurepip
usingapt
. -
Docker: Installs Docker in rootless mode if it's not found.
-
SSH Host Authenticity: Adds
HOST_URL
to~/.ssh/known_hosts
if it's not already present. -
Robotair Client: Installs the
robotair-client
package viapipx
if it's not already installed. -
PATH Configuration: Ensures the
pipx
binary directory is included in the user'sPATH
.
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:
- The
--force
flag ensures the client starts even if it's already running.