.. Reminder for header structure:        
  Parts (H1)          : #################### with overline
  Chapters (H2)       : ******************** with overline
  Sections (H3)       : ====================
  Subsections (H4)    : --------------------
  Subsubsections (H5) : ^^^^^^^^^^^^^^^^^^^^
  Paragraphs (H6)     : """""""""""""""""""""

.. meta::
  :description: Installing WAPT Server on Debian and derivatives
  :keywords: WAPT, installing, Debian, Ubuntu

.. |date| date::

.. role:: red

.. _base_debian_server_install:
.. _base_ubuntu_server_install:

################################################
Installing WAPT Server on Debian and derivatives
################################################

*********************
Setting up the server
*********************

In order to install a supported version of :red:`Debian and its derivatives`, or :red:`Red Hat and its derivatives`.

.. warning::

  * Install **64bit** version.

  * Install the Server without the graphical user interface.

  * Systemd must be enabled

.. attention::

  The upgrade procedure is different from an initial installation.
  For an upgrade, please refer to :ref:`the documentation on upgrading the WAPT Server <upgrade-wapt>`.

Configuring the network parameters
==================================

.. include:: wapt-resources/linux-server-naming.txt

.. _fqdn_debian:

Configuring the name of the WAPT Server
=======================================

.. hint::

  The short name of the WAPT Server **MUST** not be longer than **15 characters** (the limit is due to *sAMAccountName* restriction in Active Directory).

  The name of the WAPT Server **MUST** be a :abbr:`FQDN (Fully Qualified Domain Name)`, that is to say it has both the server name and the DNS suffix.

* Modify the :file:`/etc/hostname` file and write the :term:`FQDN` of the WAPT Server.

.. code-block:: bash

  # /etc/hostname of the WAPT Server
  srvwapt.mydomain.lan

* Configure the :file:`/etc/hosts` file, be sure to put both the :term:`FQDN` and the short name of the WAPT Server.

.. code-block:: bash

  # /etc/hosts of the WAPT Server
  127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
  ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
  10.0.0.10   srvwapt.mydomain.lan srvwapt

.. hint::

  * On the line defining the DNS server IP address, be sure to have the IP of the WAPT Server (not 127.0.0.1), then the :term:`FQDN`, then the short name.

  * Do not change the line with *localhost*.

Configuring the IP address of the WAPT Server
=============================================

* Configure the IP address of the WAPT Server in the :file:`/etc/network/interfaces`.

.. code-block:: bash

  # /etc/network/interfaces of the WAPT Server
  auto eth0
  iface eth0 inet static
    address 10.0.0.10
    netmask 255.255.255.0
    gateway 10.0.0.254

* Apply the network configuration by rebooting the host with a :command:`reboot`.
  
.. code-block:: bash

  reboot

* If it has not already been done, create the :ref:`DNS entry <srv_dns>` for the WAPT Server in the :term:`Organization`'s Active Directory or DNS server.

* After having rebooted, configure the system locale in English in order to have non-localized logs for easier searching of common errors.

.. code-block:: bash

  apt install locales-all -y
  localectl set-locale LANG=en_US.UTF-8
  localectl status

* Check whether the machine is properly synchronized with NTP server.
  If it is not synchronized please refer to the OS documentation to configure :command:`timedatectl`.

.. code-block:: bash

  timedatectl status

* Update and upgrade the Operating System and make sure that the Debian default certificate authorities bundle is installed.

.. code-block:: bash

  apt update && apt upgrade
  apt install ca-certificates -y

* Reboot the WAPT Server.

.. code-block:: bash

  reboot

The server is now ready.

.. _install_wapt_debian:

Installing the WAPT Server requires a few steps:

* Configuring the repositories.

* Installing additional Linux packages.

* Installing and provisioning the PostgreSQL database.

* Post-configuring the WAPT Server.

.. note::

  The WAPT Server packages and repository are signed by Tranquil IT and it is necessary to get the :mimetype:`gpg` public key below in order to avoid warning messages during installation.

***********************************
Installing the WAPT Server packages
***********************************

* Update the APT source, retrieve the :mimetype:`.gpg` key from Tranquil IT, then add Tranquil IT's repository.

  .. code-block:: bash
    :substitutions:

    apt install apt-transport-https lsb-release gnupg wget -y
    sudo bash -c 'wget -qO- https://wapt.tranquil.it/$(lsb_release -is)/tiswapt-pub.gpg > /usr/share/keyrings/tiswapt-pub.gpg'
    echo "deb [signed-by=/usr/share/keyrings/tiswapt-pub.gpg] https://wapt.tranquil.it/$(lsb_release -is)/wapt-|wapt_short_version|/ $(lsb_release -c -s) main" > /etc/apt/sources.list.d/wapt.list

* Then install the WAPT Server packages.

  .. code-block:: bash

    export DEBIAN_FRONTEND=noninteractive
    apt update
    apt install tis-waptserver tis-waptsetup -y
    unset DEBIAN_FRONTEND

********************************
Standard mode post-configuration
********************************

.. include:: wapt-postconf-standard-mode.inc.rst

******************************
Secure mode post-configuration
******************************

.. include:: wapt-postconf-secure-mode.inc.rst

The WAPT Server is now ready.
You may go to the documentation on :ref:`installing the WAPT Console <installing_the_WAPT_console>`.
