# Setup & Configuration

```
 /$$                     /$$       /$$   /$$       
|__/                    | $$      |__/  | $$       
 /$$ /$$$$$$$   /$$$$$$ | $$$$$$$  /$$ /$$$$$$     
| $$| $$__  $$ |____  $$| $$__  $$| $$|_  $$_/     
| $$| $$  \ $$  /$$$$$$$| $$  \ $$| $$  | $$       
| $$| $$  | $$ /$$__  $$| $$  | $$| $$  | $$ /$$   
| $$| $$  | $$|  $$$$$$$| $$$$$$$/| $$  |  $$$$//$$
|__/|__/  |__/ \_______/|_______/ |__/   \___/ |__/
```

Production-ready CLI for configuring and running the Inabit Remote Approver with Docker and nginx.

Current version: v0.1.3

## What you get

* Guided setup wizard (validates token, configures URL/ports, generates nginx.conf)
* Automatic nginx and Docker Compose configuration
* HTTPS support with auto-detected certificates (PEM or CRT/KEY)
* Health checks and smart troubleshooting
* One-command cleanup and uninstall

## Install (production)

Clone the release repository on your remote instance and run the installer:

{% code title="Install (production)" %}

```bash
# Clone the release bundle (contains installer + docker-compose.yml)
git clone https://your-release-repo-url.git approver-cli
cd approver-cli

# Install as current user (no sudo needed)
bash inabit-cli-installation-v1.0.sh

# Or system-wide (requires sudo)

# sudo bash inabit-cli-installation-v1.0.sh
```

{% endcode %}

After installation, the global command `inabit` is available.

## Quick start

{% code title="Quick start" %}

```bash
# Run the guided setup
inabit setup

# Check status / logs
inabit status
inabit logs

# Manage services
inabit restart
inabit stop
inabit start

# Cleanup everything created by setup (keeps Docker images)
inabit cleanup

# Uninstall the CLI and remove the global "inabit" command
inabit uninstall

# For system-wide installs, use: sudo inabit uninstall
```

{% endcode %}

## Setup flow (overview)

{% stepper %}
{% step %}

### Start setup

Begin the guided setup by running `inabit setup`.
{% endstep %}

{% step %}

### Validate login token → obtain access token

The wizard validates the provided token and obtains an access token.
{% endstep %}

{% step %}

### Configure service port

Choose the approver service port (default 3020).
{% endstep %}

{% step %}

### Choose network approach

Select either Domain or IP + Port.

* Domain:
  * Choose 80 (HTTP) or 443 (HTTPS)
  * Generate nginx.conf
  * Auto-update docker-compose ports
  * Detect SSL files in ./ssl (PEM or CRT/KEY)
* IP + Port:
  * Generate nginx.conf and map chosen port
    {% endstep %}

{% step %}

### Validate external URL (health check)

The setup performs health checks to validate the external URL.
{% endstep %}

{% step %}

### Create directories and configuration

Setup creates required directories and configuration files.
{% endstep %}

{% step %}

### Start nginx → start approver

The wizard starts nginx first, then starts the approver service.
{% endstep %}

{% step %}

### Verify accessibility

The wizard verifies accessibility (accepts some transient errors like 403/502/503 during initialization).
{% endstep %}

{% step %}

### Show pairing code and instructions

Finally, the setup displays the pairing code and next-step instructions.
{% endstep %}
{% endstepper %}

Notes:

* During setup, HTTP 403 from curl can be normal if Cloudflare blocks non-browser requests; browsers should work.
* The wizard treats 403/502/503 as acceptable during early startup while the approver initializes.

## Nginx in production (what the wizard configures)

* Domain
  * Port 80 (HTTP): `server { listen 80; }` that proxies to `approver:${APPROVER_PORT}`
  * Port 443 (HTTPS):
    * `listen 80;` redirects HTTP to HTTPS
    * `listen 443 ssl; http2 on;` uses detected cert/key under `/etc/nginx/ssl/`
  * Docker Compose ports exposed automatically: `80:80` and `443:443`
* IP + Port
  * Single `server { listen <custom>; }` with proxy to `approver:${APPROVER_PORT}`
  * Compose port exposed automatically: `<custom>:<custom>`

Supported certificate pairs to place in local `ssl/`:

* `cert.pem` + `key.pem`
* `cert.crt` + `key.key`
* `server.crt` + `server.key`
* `domain.crt` + `domain.key`

## Project structure (for reference)

{% code title="Project structure" %}

```
release/
├── inabit-cli-installation-v1.0.sh   # Installer
├── docker-compose.yml                # Docker services configuration
└── README.md
```

{% endcode %}

## Prerequisites

* Docker
* Docker Compose
* Bash shell

## Troubleshooting

Use the CLI to inspect status, logs, and perform restarts or cleanup:

{% code title="Troubleshooting commands" %}

```bash
# Status / Logs
inabit status
inabit logs

# Restart / Cleanup
inabit restart
inabit cleanup
```

{% endcode %}

## License

This project is part of the Inabit Remote Approver service.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inabit.com/api-reference/remote-approver-app/setup-and-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
