Skip to content

Uninstalling Robotair 🗑️

Estimated time to read: 7 minutes

This guide walks you through the process of fully removing Robotair from your system. Just like the installation process, we’ve designed this guide to be transparent and easy to follow, so you know exactly what’s happening during every step of the uninstallation. By following these instructions, you can confidently and completely remove Robotair without leaving behind any residual files or configurations.


Overview

The Robotair Uninstallation Script is designed to:

  1. Stop and Disable Services: Halts the Robotair services and sockets.
  2. Remove Service Definitions: Deletes the systemd unit files associated with Robotair.
  3. Uninstall Robotair Client: Removes the Robotair client package installed via pipx.
  4. Clean Up Residual Files: Deletes any remaining Robotair-related files and directories, including the .robotair directory.
  5. Provide Feedback: Offers clear messages to inform you of the uninstallation progress and status.

By following this guide and using the provided script, you can ensure that Robotair is thoroughly removed from your system.


How to Use the Script

Follow these steps to uninstall Robotair from your system:

1. Prepare the Uninstallation Script

  • Download the Script:

    • Save the uninstallation script provided above as uninstall.sh on your local machine.
  • Set Execution Permissions:

    • Open your terminal and navigate to the directory containing uninstall.sh.
    • Run the following command to make the script executable:

      chmod +x uninstall.sh
      

2. Run the Uninstallation Script

  • Execute the Script: To uninstall Robotair, run the script with optional verbosity:

    ./uninstall.sh [-v|--verbose]
    
  • Example with Verbose Output:

    ./uninstall.sh --verbose
    

    The -v or --verbose flag enables detailed output, allowing you to monitor the uninstallation process closely.

3. Monitor the Uninstallation Process

  • Feedback Messages:
    • The script will display messages indicating the progress of each uninstallation step.
    • Success messages are marked with a ✅, while errors are marked with a ❌.

4. Verify the Uninstallation

  • Check Service Status:

    systemctl --user status robotair.service
    
    You should see a message indicating the unit could not be found.

  • Check Configuration Directory:

    ls -la ~/.robotair
    
    This should report that the directory does not exist.

  • Check Log Directory:

    ls -la /var/log/robotair
    
    This should also report that the directory does not exist.

If all checks confirm that no traces remain, Robotair has been successfully removed.

Script Breakdown

Variable Definitions

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

    • PIP_URL: The URL for the Python package index where Robotair's packages are hosted.
    • HOST_URL: The host URL used during installation (github.com). Note: Be cautious when modifying SSH known_hosts related to this URL.
    • PACKAGE_NAME: The name of the Robotair client package (robotair-client).
  • Service Configuration:

    • SERVICE_NAME, SOCKET_NAME: Names of the systemd service and socket units.
    • USER_SYSTEMD_DIR: Directory where user-level systemd unit files are stored.
    • ROBOTAIR_DIR: Directory containing Robotair's configuration and deployment files ($HOME/.robotair).
    • SERVICE_READINESS_FILE: Path to the file indicating service readiness (/tmp/robotair_status).
    • SOCKET_PATH: Path to the Robotair socket file (/tmp/robotair.sock).
  • Color Codes:

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

Utility Functions

These functions help streamline the script by handling common tasks:
  • 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 enable verbose output. It supports -v or --verbose flags.

  • run(command): Executes commands while suppressing their output to keep the script's output clean.

  • check(command): Checks the exit status of commands to determine if they succeeded or failed.

  • check_installation_status(status, success_msg, error_msg): Verifies if the previous command was successful and prints appropriate messages.

Uninstallation Functions

These functions perform specific uninstallation tasks:
  • stop_and_disable_services():

    • Stops and disables the Robotair service and socket using systemctl --user.
    • Provides feedback on whether each operation was successful.
  • remove_service_definitions():

    • Deletes the systemd unit files for the Robotair service and socket.
    • Reloads the systemd daemon to apply changes.
  • uninstall_robotair_client():

    • Uninstalls the Robotair client package using pipx.
    • Checks if pipx is installed before attempting uninstallation.
  • remove_residual_files():

    • Removes any remaining Robotair-related files, such as socket files, readiness files, and the .robotair directory.
  • Important:

    • The script includes a cautionary note about removing entries from known_hosts for github.com, as this can affect other SSH operations. It's recommended to leave these entries intact unless you're certain they were exclusively added by Robotair.
  • cleanup_pipx_paths():

    • Ensures that pipx paths are correctly set after uninstallation.
    • Defines the PYTHON_EXEC variable by checking for python3 or python.
    • Runs pipx ensurepath to clean up any lingering pipx path configurations.

Step-by-Step Execution

1. Handling Command-Line Arguments

Handling Command-Line Arguments
  • Purpose:: To enable verbose output for detailed logging.

  • Process:

  • The script checks if -v or --verbose flags are passed.
  • If provided, it sets VERBOSE=1, offering you more insight into the process.

2. Stopping and Disabling Services

Stopping and Disabling Services
  • Purpose:: To ensure that Robotair services and sockets are not running during uninstallation.

  • Process:

    • The script checks if the systemd units (robotair.service and robotair.socket) exist.
    • If they do, it stops and disables them.
    • If they don’t, it informs you and moves on.

3. Removing Service Definitions

Removing Service Definitions
  • Purpose:: To remove the systemd unit files from your user directory.

  • Process:

    • The script removes service and socket unit files from $HOME/.config/systemd/user.
    • It then reloads the systemd daemon to apply the changes.

4. Uninstalling the Robotair Client

Uninstalling the Robotair Client
  • Purpose:: To remove the robotair-client package installed via pipx.

  • Process:

  • If pipx is available, it checks if robotair-client is installed.
  • If it is, it uninstalls it.
  • If not, it simply skips this step.

5. Removing Residual Files

Removing Residual Files
  • Purpose:: To remove any leftover files or directories related to Robotair.

  • Process:

    • Removes the socket file, readiness file, configuration directory (~/.robotair), and logs (/var/log/robotair).
    • The script checks if these files or directories exist before attempting to remove them, ensuring it never fails due to non-existent paths.
    • Removing logs may require sudo privileges. If prompted, enter your password. If you cannot provide sudo access, you may need to manually remove the logs later.

6. Cleaning Up pipx Paths

Cleaning Up pipx Paths
  • Purpose:: To ensure that pipx paths are set correctly after uninstallation.

  • Process:

    • The script locates a suitable Python executable.
    • It runs pipx ensurepath to clean up any pipx environment paths.