Installation and Setup

Prerequisites

The following prerequisites are required in order for Trudesk to run.

Trudesk is still in active development and its possible you may run into issues during the install process. If you have issues please fill out a [bug report](https://www.github.com/polonel/trudesk/issues/new).

Release Notes

Detailed release notes for each version are available on GitHub.

OSX Install

Please verify you have met all of the prerequisites before running the following commands.
For detailed documentation on installing the prerequisites, please visit the documentation for each above.

The following commands will download and install the latest version.

$ git clone https://www.github.com/polonel/trudesk
$ cd trudesk
$ npm install -g yarn
$ yarn
$ npm run build
$ node runner

By default the server starts listening for incoming connections on http://0.0.0.0:8118

Linux Install

Please verify you have met all of the prerequisites before running the following commands.
For detailed documentation on installing the prerequisites, please visit the documentation for each above.

The following commands will download and install the latest version.

$ git clone https://www.github.com/polonel/trudesk
$ cd trudesk
$ npm install -g yarn
$ yarn
$ npm run build
$ node runner

By default the server starts listening for incoming connections on http://0.0.0.0:8118

Ubuntu Install Script

The install script will download all the required packages and prompt if you want to install MongoDB locally.

Note: This script is designed to run on a fresh install of Ubuntu 16.04

Ubuntu 16.04

curl -L -s http://www.trudesk.io/install/install_ubuntu.sh | sudo bash

Installing Trudesk video showing the install processes with the Ubuntu Install Script.

Windows Install

Please verify you have met all of the prerequisites before running the following commands.
For detailed documentation on installing the prerequisites, please visit the documentation for each above.

The following commands will download and install the latest version.

C:\> git clone https://www.github.com/polonel/trudesk
C:\> cd trudesk
C:\trudesk> npm install -g yarn
C:\trudesk> yarn
C:\trudesk> npm run build
C:\trudesk> node runner

Note: Windows users should use PM2 to handle running the Trudesk Process.
See PM2 - Windows Setup



Virtual Appliance

The Trudesk virtual appliance is the fastest and easiest way to get a small deployment up and running. Simply download the appliance and import the OVA into VMWare or VirtualBox.

Download

Trudesk VA - v1.0.2

Access Trudesk

Once the virtual appliance is up and running, navigate to http://{ipaddress}:8118

Default Login

The default login credentials for the appliance:

Username: root
Password: trudesk

Network Configuration

The default network configuration is set to DHCP. During boot-up you will see the IP the appliance obtained.
udhcpc: lease of 192.168.1.233 obtained, lease time 86400
Running ifconfig will show the network interfaces as well.

Static Configuration

If you wish to static the appliance, edit the file /etc/network/insterfaces with changes similar to the following:

iface eth0 inet static
    address 192.168.1.XXX
    netmask 255.255.255.0
    gateway 192.168.1.1

Configure DNS: /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4

Restart Networking: rc-service networking restart



Docker Install

Trudesk can run as a docker container as well. The below example shows running a MongoDB container and linking it to a trudesk container.

The below example assumes you have docker already install

Note: In this example all container storage is located on the host.
In order to run trudesk in a multi-host container cluster, you will require a shared storage. (ex: NFS)

Storage - Create directories on host

$ mkdir -p /data/db
$ mkdir -p /data/configdb
$ mkdir -p /data/trudesk/plugins
$ mkdir -p /data/trudesk/uploads

MongoDB Container

The following command will deploy a mongodb 3.6 docker container with the name mongodb, which we will use to link to our trudesk container.

$ docker run --name mongodb \
    -v /data/db:/data/db \
    -v /data/configdb:/data/configdb \
    -d mongo:3.6

Trudesk Container

The following command will deploy a trudesk 1.0 docker container. The container will expose a NodePort to access the container.

Get latest updated image of 1.0

$ docker pull polonel/trudesk:1.0
$ docker run --name trudesk --link mongodb:mongodb \
    -v /data/trudesk/uploads:/usr/src/trudesk/public/uploads \
    -v /data/trudesk/plugins:/usr/src/trudesk/plugins \
    -e NODE_ENV=production \
    -e MONGODB_PORT_27017_TCP_ADDR=mongodb -e MONGODB_DATABASE_NAME=trudesk \
    -P -d polonel/trudesk:1.0

Accessing the trudesk container

Once the containers have started - access the trudesk container via the assigned NodePort.
The following command will list the two running containers. Notice under the ports column
the NodePort - 32772. This will allow access to the trudesk container via http://{hostip}:32772

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
5f75716aa8cc        polonel/trudesk:1   "/bin/bash /usr/src/…"   1 minute ago        Up 1 minute         0.0.0.0:32772->8118/tcp   trudesk
5b4f77cbf1a3        mongo:3.6           "docker-entrypoint.s…"   32 minutes ago      Up 32 minutes       27017/tcp                 mongodb

Systemd startup script

The docker containers will not start on reboot. A startup script can relaunch the containers during startup. The following is an example of a systemd startup script.

MongoDB

$ sudo vi /etc/systemd/system/docker-mongodb.service

[Unit]
Description=MongoDb Container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a mongodb
ExecStop=/usr/bin/docker stop -t 10 mongodb

[Install]
WantedBy=default.target

Trudesk

$ sudo vi /etc/systemd/system/docker-trudesk.service

[Unit]
Description=Trudesk Container
Requires=docker-mongodb.service
After=docker-mongodb.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a trudesk
ExecStop=/usr/bin/docker stop -t 2 trudesk

[Install]
WantedBy=default.target

Stop the containers if they are running

$ docker stop trudesk mongodb

Reload the systemd service files, start the containers, and enable the services for system startup.

$ sudo systemctl daemon-reload
$ sudo systemctl start docker-mongodb
$ sudo systemctl start docker-trudesk
$ sudo systemctl enable docker-mongodb
$ sudo systemctl enable docker-trudesk

Nginx Proxy

I recommend using Nginx to access the trudesk container with a hostname/domain name. Check out jwilder/nginx-proxy for more information.

PM2

Process Manager 2 is a great tool to handle running the Trudesk process.

Install and Configure

npm install pm2 -g will install the pm2 CLI for handling the process.

Linux & MacOS

$ pm2 start {path/to/trudesk}/app.js --name trudesk \
    -l {path/to/trudesk}/logs/output.log --merge-logs
$ pm2 save
$ pm2 startup

Windows Setup

PM2 will need additional setup on Windows machines.

npm i pm2 pm2-windows-service -g this installed both PM2 as well as PM2 as a windows service

Please run the following commands from an Administrative Command Prompt / Powershell

> pm2-service-install -n PM2
> pm2 start {path\\to\\trudesk}\\app.js --name trudesk -l {path\\to\\trudesk}\\logs\\output.log --merge-logs
> pm2 save

Reverse Proxy - Nginx

Trudesk runs on an internal port of 8118. In order to access Trudesk on port 80, a reverse proxy is recommended. This allows you to setup SSL/TLS for your domain.

nginx.conf - example

http {
    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  65;

    upstream socket_nodes {
        ip_hash;
        # IP Address of Host running Trudesk
        server 192.168.1.x:8118;
    }

    server {
        listen       80;
        server_name  trudesk.domain.com;

        location ~ ^/(uploads/) {
                root /path/to/trudesk/public;
                access_log off;
                expires modified +1h;
        }

        location / {
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                proxy_cache one;
                proxy_cache_key trudesk$request_uri$scheme;
                proxy_pass http://socket_nodes;
        }

        # redirect server error pages to the static page /40x.html
        #
        error_page  404              /404.html;
        location = /40x.html {
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        }
    }
}