# Installing Connectware (Docker)

This guide walks you through installing Connectware on Docker using an installer script. The script automates the setup process and supports both interactive and silent installation modes. You can optionally configure Connectware to run as a systemd service for automatic startup.

## Prerequisites

Before installing Connectware, make sure to meet the following requirements:

* Connectware [license key](https://docs.cybus.io/2-1-0/documentation/installation-and-upgrades/licensing) is available.
* You have an Internet connection to download Docker images from `registry.cybus.io`.
* Docker and Docker Compose are installed and running on your host.
  * For more information on installing Docker, refer to the [Docker documentation](https://docs.docker.com/get-docker/). Docker Desktop includes Docker Compose along with Docker Engine and Docker CLI which are Compose prerequisites.
* You are familiar with Docker.

## Preparing the Installer Script

The installer script allows you to quickly install Connectware.

1. Download the installer script for the Connectware version that you want to install.
   * Download link for the installer script of the latest Connectware version: <https://download.cybus.io/latest/connectware-online-installer.sh>
   * To download the installer script for a specific Connectware version, use the following link and replace with the Connectware version: [https://download.cybus.io//connectware-online-installer.sh](https://download.cybus.io/%3CVERSION%3E/connectware-online-installer.sh)
   * For example, to download the installer script for Connectware 1.7.1, use the following link: <https://download.cybus.io/1.7.1/connectware-online-installer.sh>\
     \
     In the example below, we will use the latest version of Connectware.

{% code lineNumbers="true" %}

```bash
wget -O ./connectware-online-installer.sh https://download.cybus.io/latest/connectware-online-installer.sh
```

{% endcode %}

2. Make the script executable:

{% code lineNumbers="true" %}

```bash
chmod +x ./connectware-online-installer.sh
```

{% endcode %}

**Result:** You can now run the installer script to install Connectware.

You can run the installer in two modes:

* **Interactive mode:** Follow the prompts to configure your installation. See [Running the Installer Script](#running-the-installer-script).
* **Silent mode:** Use command-line parameters for automated deployment. See [Running the Installation in Silent Mode](#running-the-installation-in-silent-mode).

## Running the Installer Script

{% hint style="warning" %}
You can run the installer script without administrator rights in most cases. However, sudo privileges are required in two scenarios:

1. When setting up Connectware as a systemd service (recommended).
2. When installing to a directory that needs elevated permissions.

Since this guide demonstrates installing Connectware with systemd service integration, we will use sudo in the following commands.
{% endhint %}

1. Run the installer script:

{% code lineNumbers="true" %}

```bash
sudo ./connectware-online-installer.sh
```

{% endcode %}

2. The installer displays the Connectware version. Press **Enter** to confirm.
3. Enter your desired installation directory, or press **Enter** to use the default path: `/opt/connectware`
4. The installer runs preflight checks to verify all system requirements are met. If any checks fail, review the [Prerequisites](#prerequisites) section and check if your system meets all requirements.

If all requirements are met then you should see the following output.

{% code lineNumbers="true" %}

```bash
Running preflight checks.
=========================
Validating write permission to installation location /opt/connectware: [OK]
Checking whether this system has systemd: [YES]
Validating required utility installation: [OK]
Validating Cybus docker-registry connection: [OK]
Validating Docker installation: [OK]
Validating Docker Compose installation: [OK]
Validating that no former Connectware is running: [OK]
Preflight checks finished successfully!
```

{% endcode %}

5. Enter your Cybus license key when prompted. If your license key is valid, you will see a success message.

{% code lineNumbers="true" %}

```bash
Verifying license key...
Login succeeded.
```

{% endcode %}

6. Enter the ingress hostnames under which you will access Connectware. You can specify multiple values by separating them with commas. This allows you to define any hostnames, wildcard domains, and IP addresses that agents use to connect to Connectware. All values are added to the certificate's SAN field, enabling secure agent connections through any of the configured access points. You can change the hostnames later by setting the `CYBUS_INGRESS_DNS_NAMES` environment variable.

{% hint style="info" %}
If you are replacing the external Connectware CA certificate chain and manage `cybus_server.crt` manually, ensure that any DNS name with which you address Connectware or individual components is included. You can skip adding them to `CYBUS_INGRESS_DNS_NAMES`.
{% endhint %}

**Example**

{% code lineNumbers="true" %}

```bash
Ingress Hostnames [localhost]:
my.company.tld
```

{% endcode %}

7. Choose whether to run Connectware as a systemd service. Without this, you must start Connectware manually after each system restart. In this guide, we press <kbd>Enter</kbd> to confirm.
8. Review the configuration summary and confirm your settings are correct. If you followed the steps in this guide, you should see the following output.

{% code lineNumbers="true" %}

```bash
Please review and confirm the following Connectware configuration:
------------------------------------------------------------------

Connectware license key:       [VALID]
Installation directory:       /opt/connectware
Autostart as systemd service: true

Accept configuration? [Y/n]
```

{% endcode %}

9. The installer downloads the Connectware container images. After download completes, it checks for old container images from previous Connectware versions that can be safely removed ("pruned") to free disk space. The installer asks for confirmation before removing any images.

{% code lineNumbers="true" %}

```bash
-----------------------------------------
Removing old Docker images
-----------------------------------------

The following Docker images are from previous Connectware versions and can be removed:

REPOSITORY                            TAG          IMAGE ID  CREATED      SIZE
registry.cybus.io/cybus/admin-web-app ***********  e561383a5 24 hours ago 21.5MB
REPOSITORY                            TAG          IMAGE ID  CREATED      SIZE
registry.cybus.io/cybus/auth-server   ***********  a65b7f32f 24 hours ago 165MB
REPOSITORY                            TAG          IMAGE ID  CREATED      SIZE
registry.cybus.io/cybus/broker        ***********  80dd0fb24 24 hours ago 56.7MB
(...)

-----------------------------------------

Should the above docker images be removed from your local computer (pruned)? [Y/n]
```

{% endcode %}

10. After confirming, the installer displays the image removal results and shows a success message with commands to manage Connectware. In our example, you should see the following output:

{% code lineNumbers="true" %}

```bash
Successfully installed Connectware!
===================================
You can find the installation directory at /opt/connectware.
In order to stop type:
systemctl stop connectware
```

{% endcode %}

## Running the Installation in Silent Mode

The installer supports an automated deployment mode that requires no manual intervention. You can activate this by using either `-s` or `--silent` when [running the installation script](#running-the-installer-script).

For silent installations, you must provide your license key through the `--license-key` parameter. By default, this method installs a basic version of Connectware to `/opt/connectware` and skips the systemd service setup.

If you need to customize your installation, the script offers several configuration options. Run the installer with `--help` to view all available parameters.

## Updating SSL Certificates

When you need to update your SSL certificates (such as after a Let's Encrypt renewal via `certbot` or when adding self-signed certificates), follow these steps:

1. Copy the new certificates to the container:

{% code lineNumbers="true" %}

```bash
docker cp -L <path-to/your-key-file.key> <your-connectware-container>:/connectware_certs/cybus_server.key
docker cp -L <path-to/your-cert-file.crt> <your-connectware-container>:/connectware_certs/cybus_server.crt
```

{% endcode %}

2. The name of your Connectware container depends on the directory it was installed to and is rendered as `<your-connectware-directory>_connectware_1`. By default, Connectware is installed to `/opt/connectware/` which results in the container name `connectware_connectware_1`.
3. Restart the Connectware container to apply the new certificates. Replace `<your-connectware-container>` with the name of your Connectware container:

{% code lineNumbers="true" %}

```bash
docker restart <your-connectware-container>
```

{% endcode %}
