Debian

How to install PureLife Cloud on Debian/Linux:

It is assumed in the following sections that the installation is done under Debian/Linux (x64).

PureLife Cloud also works on other platforms and the instructions should transfer, but we do not provide support for this. Please feel free to contact us for more information.

For the installation, we assume that the following packages are installed.

sudo apt install curl gnupg2 ca-certificates lsb-release

Preparation

Before you start the installation, you should make sure that the following components are present:

  • A bash (or other) terminal
  • A PostgreSQL >= 13 database server and database
  • The MQTT broker Mosquitto with the mosquitto-go-auth plugin, if authentication is to be used. If no authentication is to be used (not recommended), any other MQTT broker can be used.
  • (Recommended) A domain name pointing to your server (e.g. example.com)
  • (Recommended) A web server, e.g. nginx
  • (Recommended) SMTP access data for an email account to send service emails

You should also create a user who will later start the server:

sudo adduser --home /home/pureuser --disabled-login pureuser

Installation

First switch to the user who will later be responsible for running the PureLife Cloud instance.

sudo su - pureuser

Download the latest available version for your platform from the PureLife Cloud, copy it to the computer and unzip it.

# Copy the archive (for example with wget, scp or rsync)
tar -zxvf purelife-cloud*.tar.gz

You should now see a binary purelife-cloud which you should first check with ./purelife-cloud -h. After that you can you create a configuration file.

./purelife-cloud config generate

You should now see a new folder config with a file config.toml. From now on, the file is used for Configuration of the PureLife Cloud Instance.

Configuration

First should be under SqlSettings.DataSource the DSN for the PostgreSQL database connection be deposited. The following DNS can serve as a template:

"postgres://<purelife-cloud-db-user>:<purelife-cloud-db-password>@<host-name-or-IP>:5432/<purelife-cloud-db>?sslmode=disable&application_name=purelife-cloud"

The URL under which the page can later be reached should also be set under HttpSettings.SiteURL. A trailing backslash should be removed. If the access to the URL is secured by HTTPS (strongly recommended), a URL for unencrypted access to the PureLife Cloud must also be specified under HTTP.LegacyFirmwareURL.

Under MQTT you need to specify the URL through which Mosquitto can be reached. If you created an MQTT account for the PureLife cloud when setting up Mosquitto, you should also store it under MQTT. Otherwise, PureLife Cloud will automatically create a account, which Mosquitto will query via the Auth plugin.

[MQTT]
Broker = ["mqtt://hostname.de:1883"]
Username = "PureLifeCloud"
Password = "password-here"

The connection to the database can now be tested directly. For this purpose, a first user should be created, which is then automatically also the administrator of the application. (More users can be added later via the frontend).

./purelife-cloud user create

Now that you have a connection to the database, you should configure the server mails directly. To do this, you must enter your SMTP access data under SystemSMTPSettings and under SystemSettings.AdminMail Enter email address.

To complete the setup, you should save the secret key under ServiceSettings.SecretKey! This one is for it responsible for partially encrypting the data in your database. If the Secret Key is lost or overwritten the data in your database is useless.

System-Service

If you want the PureLife Cloud instance to start automatically with your server, a system service must be created.

1. Create a systemd file for the PureLife Cloud instance

sudo touch /etc/systemd/system/purelife-cloud.service

2. Open the file with a text editor and paste the following content.

[Unit]
Description=PureLife Cloud
After=network.target
After=postgresql.service
BindsTo=postgresql.service

[Service]
Type=notify
ExecStart=/home/pureuser/purelife-cloud server
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/home/pureuser
User=pureuser
Group=pureuser

[Install]
WantedBy=multi-user.target

If PostgreSQL is installed on another server, After=postgresql.service and BindsTo=postgresql.service must be removed.

3. After saving, the new service must be recognized.

sudo systemctl daemon-reload

4. Check if the file was recognized.

sudo systemctl status purelife-cloud.service

You should now see something like the following output.

 purelife-cloud.service - PureLife Cloud
  Loaded: loaded (/etc/systemd/system/purelife-cloud.service; disabled; vendor preset: enabled)
  Active: inactive (dead)

5. You have created the service and can start it.

sudo systemctl start purelife-cloud.service

6. Check if the instance is started.

sudo systemctl status purelife-cloud.service
curl http://localhost:8080

As an output, you should see an HTML file that the instance sent.

7. You can now enable the service to start automatically with your computer.

sudo systemctl enable purelife-cloud.service

Try it

Now that the cloud instance is up and running, you can adjust the configuration or log in. To do this, open the URL http://127.0.0.1:8080 locally on the server or using the IP address of the server from another computer.

Other useful adjustments

System

Enter the domain of the server in the hosts file.

127.0.0.1       example.com

Database

Activate extensions.

sudo su - postgres
psql -d database
CREATE EXTENSION IF NOT EXISTS "hstore";
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

Test the SMTP configuration

sudo su - pureuser
./purelife-cloud config test-mail --help
./purelife-cloud config test-mail --to user@example.de

Configure logrotate

Create the file /etc/logrotate.d/purelife-cloud, with the following content.

/home/pureuser/logs/purelife-cloud.log {
      # Maximum number of log files to keep
      rotate 20
      # Rotate log files on the first day every day
      daily
      # Compress rotated logs with .gzip
      compress
      # If the log file is missing, continue
      missingok
      # If the log file is empty, continue
      notifempty
      # Truncate the original log file in place after creating a copy
      copytruncate
}

Test the configuration with logrotate -f -v /etc/logrotate.d/purelife-cloud