# Download/Install

> The Flexter download process.

---

Site [llms.txt](/flexter/v2.1/llms.txt)

---

## Repository Setup

There are two repositories available for Redhat and Debian-based Linux operating systems

### YUM/DNF Repository

Yum has been the main package installation tool for Redhat-based Linux distributions. It has been recently replaced by dnf. However, both dnf and yum are mutually compatible.

* Red Hat Enterprise Linux (RHEL)
* CentOS Stream
* Rocky Linux
* AlmaLinux
* Fedora
* Oracle Linux
* Amazon Linux

Flexter repository configuration should be added under the standard yum location. Please note it will normally require root access to create/edit, e.g.:

```bash
sudo vi /etc/yum.repos.d/sonra-flexter.repo
```

Below are the recommended settings to be added. The values for <USER> and <PASS> should be altered accordingly with credentials provided by Sonra.

```ini
[sonra-flexter]
name=Sonra Repository
baseurl=https://yum.sonra.io/flexter
username=<USER>
password=<PASS>
gpgkey=https://yum.sonra.io/RPM-GPG-KEY-Sonra
gpgcheck=0
enabled=0
priority=1
```

The repository is disabled `(enabled=0)` by default. It helps to avoid unwanted upgrades, e.g., when the server administrator only wants to upgrade the server packages, not necessarily include Flexter itself.

In this case the parameter `--repo` should always be explicitly used with dnf or yum commands as in the example below:

#### Installing the latest version

```bash
sudo dnf --repo=sonra-flexter install xml2er xsd2er json2er merge2er flexchma flexter-ui
```

#### Installing the specific version

```bash
sudo dnf --repo=sonra-flexter install xml2er-2.1.2 xsd2er-2.1.2 json2er-2.1.2 merge2er-2.1.2 flexchma-2.1.2 flexter-ui-2.1.2
```

### APT Repository

APT is the main package installation tool for Debian-based Linux distributions.

Example of Debian-Based distributions:
* Debian
* Ubuntu
* Linux Mint
* MX Linux
* Kali Linux
* Raspberry Pi OS
* Pop!_OS

Please note write access (sudo/root) to the following folders will most likely be required: `/etc/apt/sources.list.d/` and  `/etc/apt/auth.conf.d/`.

Please also make sure you have the `apt-transport-https`, `curl` and `gpg` installed:

```bash
sudo apt update
sudo apt install apt-transport-https curl gpg
```

The first step is to bring the public keys to recognize the repository's authenticity and avoid warnings from apt. Depending on the exact distribution and version, one of the two commands should work:

```bash
curl -sL https://apt.sonra.io/DEB-GPG-KEY-Sonra | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/DEB-GPG-KEY-Sonra
```

Then, the new list file needs to be created, `sonra-flexter.list`:

```bash
echo "deb [arch=all signed-by=/etc/apt/trusted.gpg.d/DEB-GPG-KEY-Sonra] https://apt.sonra.io/flexter releases main #Sonra Flexter" | sudo tee /etc/apt/sources.list.d/sonra-flexter.list > /dev/null
```

Also, the new authentication auth file, `sonra-flexter.conf`, with the <USER> and <PASS> values adapted using credentials provided by Sonra:

```bash
echo "machine apt.sonra.io login <USER> password <PASS>" | sudo tee /etc/apt/auth.conf.d/sonra-flexter.conf > /dev/null
```

After updating the indexes, the Flexter packages can be installed:

#### Installing the latest version

```bash
sudo apt update
sudo apt install xml2er xsd2er json2er merge2er flexchma flexter-ui
```

#### Installing the specific version

```bash
sudo apt update
sudo apt install xml2er=2.1.2 xsd2er=2.1.2 json2er=2.1.2 merge2er=2.1.2 flexchma=2.1.2 flexter-ui=2.1.2
```

#### APT Repository Enable/Disable (Optional)

<details>

<summary><b>Show the full list</b></summary>

The repository is enabled by default. We recommend disabling it after installations to avoid unwanted upgrades, e.g. when the server administrator wants to upgrade the server packages, not Flexter itself.

##### Disable

To disable it, rename the `/etc/apt/sources.list.d/sonra-flexter.list` and add the `.disabled` extension:

```bash
sudo mv /etc/apt/sources.list.d/sonra-flexter.list{,.disabled}
```

##### Enable

To re-enable it, rename the `/etc/apt/sources.list.d/sonra-flexter.list.disabled` and remove the `.disabled` extension:

```bash
sudo mv /etc/apt/sources.list.d/sonra-flexter.list{.disabled,}
```

</details>

## Manual Download

In cases where the repository hasn't been set up, the packages can be downloaded directly and installed manually as the procedures below.

Make sure the curl or wget command is available. 
All examples are based on curl, but you can use wget instead.

```bash
# curl approach
curl -u "<USER>:<PASS>" -OL <URL>

# wget approach
wget --user "<USER>" --password "<PASS>" <URL>
```

### URL pattern

```text
https://download.sonra.io/flexter/<MODULE>[-VERSION].<EXTENSION>
```

### Examples

```text
# latest version
https://download.sonra.io/flexter/xml2er.rpm

# specific version
https://download.sonra.io/flexter/xml2er-2.1.2.rpm

# different package type
https://download.sonra.io/flexter/xml2er-2.1.2.tgz
```

### Redhat-Based

Example of Redhat-Based distributions:
* Red Hat Enterprise Linux (RHEL)
* CentOS Stream
* Rocky Linux
* AlmaLinux
* Fedora
* Oracle Linux
* Amazon Linux

#### Download installers

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.rpm
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.rpm
```

#### Checking hash (optional)

<details>

<summary><b>Show the full list</b></summary>

Checking if the files were downloaded correctly with the md5 hash algorithm.

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.rpm.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.rpm.md5

# helper function
md5ck() { md5sum -c <(echo `cat $1.md5` $1); }

md5ck flexchma*.rpm
md5ck xml2er*.rpm
md5ck xsd2er*.rpm
md5ck json2er*.rpm
md5ck merge2er*.rpm
md5ck flexter-ui*.rpm
```

</details>

#### Installing the packages

```bash
sudo dnf install xml2er*.rpm xsd2er*.rpm json2er*.rpm merge2er*.rpm flexchma*.rpm flexter-ui*.rpm
```

### Debian-Based

Example of Debian-Based distributions:
* Debian
* Ubuntu
* Linux Mint
* MX Linux
* Kali Linux
* Raspberry Pi OS
* Pop!_OS

#### Download installers

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.deb
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.deb
```

#### Checking hash (optional)

<details>

<summary><b>Show the full list</b></summary>

Checking if the files were downloaded correctly with the md5 hash algorithm.

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.deb.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.deb.md5

# helper function
md5ck() { md5sum -c <(echo `cat $1.md5` $1); }

md5ck flexchma*.deb
md5ck xml2er*.deb
md5ck xsd2er*.deb
md5ck json2er*.deb
md5ck merge2er*.deb
md5ck flexter-ui*.deb
```

</details>

#### Installing the packages

```bash
sudo apt install xml2er*.deb xsd2er*.deb json2er*.deb merge2er*.deb flexchma*.deb flexter-ui*.deb
```

### Unix-Based

For the other type of distros, not compatible with Redhat-Based or Debian-Based, the `.tgz` packages can be downloaded and installed manually:

Examples of other Unix-Based distributions:
* Mac OS
* Alpine Linux
* Arch Linux
* Gentoo
* OpenBSD
* FreeBSD
* NetBSD
* Solaris
* OpenSolaris
* OpenIndiana

#### Download installers

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.tgz
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.tgz
```

#### Checking hash (optional)

<details>

<summary><b>Show the full list</b></summary>

Checking if the files were downloaded correctly with the md5 hash algorithm.

```bash
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexchma.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xml2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/xsd2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/json2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/merge2er.tgz.md5
curl -u "USER:PASS" -OL https://download.sonra.io/flexter/flexter-ui.tgz.md5

# helper function

md5ck() { md5sum -c <(echo `cat $1.md5` $1); }

md5ck flexchma*.tgz
md5ck xml2er*.tgz
md5ck xsd2er*.tgz
md5ck json2er*.tgz
md5ck merge2er*.tgz
md5ck flexter-ui*.tgz
```

</details>

#### Installing the packages - with root access

```bash
# flexchma
sudo tar xzf flexchma*.tgz -C /usr/share
sudo ln -s /usr/share/flexter/flexchma/bin/flexchma /usr/bin/
# xml2er
sudo tar xzf xml2er*.tgz -C /usr/share
sudo ln -s /usr/share/flexter/xml2er/bin/xml2er /usr/bin/xml2er

# xsd2er
sudo tar xzf xsd2er*.tgz -C /usr/share
sudo ln -s /usr/share/flexter/xsd2er/bin/xsd2er /usr/bin/xsd2er

# json2er
sudo tar xzf json2er*.tgz -C /usr/share
sudo ln -s /usr/share/flexter/json2er/bin/json2er /usr/bin/json2er

# merge2er
sudo tar xzf merge2er*.tgz -C /usr/share
sudo ln -s /usr/share/flexter/merge2er/bin/merge2er /usr/bin/merge2er

# flexter-ui
sudo mkdir -p /usr/share/flexter/flexter-ui
sudo tar xzf flexter-ui*.tgz -C /usr/share/flexter/flexter-ui

# complete the installation
sudo mkdir -p /etc/flexter
sudo ln -s /usr/share/flexter/conf /etc/flexter/conf
```

#### Installing the packages - without root access

```console
$ mkdir -p ~/.local/share ~/bin
# flexchma
$ tar xzf flexchma*.tgz -C ~/.local/share
$ ln -s ~/.local/share/flexter/flexchma/bin/flexchma ~/bin/flexchma
# xml2er
$ tar xzf xml2er*.tgz -C ~/.local/share
$ ln -s ~/.local/share/flexter/xml2er/bin/xml2er ~/bin/xml2er

# xsd2er
$ tar xzf xsd2er*.tgz -C ~/.local/share
$ ln -s ~/.local/share/flexter/xsd2er/bin/xsd2er ~/bin/xsd2er

# json2er
$ tar xzf json2er*.tgz -C ~/.local/share
$ ln -s ~/.local/share/flexter/json2er/bin/json2er ~/bin/json2er

# merge2er
$ tar xzf merge2er*.tgz -C ~/.local/share
$ ln -s ~/.local/share/flexter/merge2er/bin/merge2er ~/bin/merge2er

# flexter-ui
$ mkdir -p ~/.local/share/flexter/flexter-ui
$ tar xzf flexter-ui*.tgz -C ~/.local/share/flexter/flexter-ui

# complete the installation

$ mkdir -p ~/.config
$ ln -s ~/.local/share/flexter/conf ~/.config/flexter
# optional - add ~/.local/bin to the PATH if it isn't there
echo 'export PATH="$PATH:$HOME/bin"' >> ~/.bash_profile
source ~/.bash_profile
```
