Skip to content

Installation

Tom Steele edited this page Oct 4, 2015 · 26 revisions

These install instructions will walk you through installing individual server components. Most users will prefer using Lair Manager over this method.

For simplicity and for this guide to deal with various operating systems and configurations, each of these services will not run in the background. It is up to the reader to determine the best tools (upstart, systemd, etc) and configuration to use outside of this.

Lair requires the following services to be fully functional:

  • Lair App is the Meteor server used to drive the UI.
  • Lair API is the HTTP JSON API used by drones to import and export data. This is also used for file uploads.
  • Mongodb is the database.
  • Reverse HTTPS proxy which is used for TLS and to proxy requests to the app and API through a single service. We'll be using Caddy, but nginx will also work.

The rest of this guide will assume you are using a clean install of Ubuntu 14.04. Not much changes for other operating systems beyond downloading dependencies.

Setup

Start off by creating a tmux session and a directory to house all of our dependencies:

$ tmux
$ mkdir lair
$ cd lair

Mongodb

Next, we will download, start, and configure Mongodb. Download Mongodb for your operating system here.

Download and extract:

$ curl -o mongodb.tgz https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.0.6.tgz
$ tar -zxvf mongodb.tgz

Create a directory to hold our database:

$ mkdir db

Start Mongodb with the following options:

$ ./mongodb-linux-x86_64-ubuntu1404-3.0.6/bin/mongod --dbpath=db --bind_ip=localhost --quiet --nounixsocket --replSet rs0

If you choose to install Mongodb in some other way, the most important thing to note is that it must be configured to use a replica set, and will have to be configured to be the primary.

Configure Mongodb to be the primary in the replica set:

Login to Mongodb:

$ ./mongodb-linux-x86_64-ubuntu1404-3.0.6/bin/mongo admin
MongoDB shell version: 3.0.6
connecting to: admin

From the console, configure the replica set:

> rs.initiate({_id:"rs0", members: [{_id: 1, host: "localhost:27017"}]})
{ "ok" : 1 }
rs0:OTHER> quit()

Lair APP

Next, we will download and run the lair app. In a new tab:

Download and extract the latest app tarball for your operating system from here:

$ wget https://github.com/lair-framework/lair/releases/download/v2.0.2/lair-v2.0.0-linux-amd64.tar.gz
$ tar -zxvf lair-v2.0.2-linux-amd64.tar.gz
$ cd bundle

The app requires node.js v0.10.40. We'll use nvm to install this along side any existing node.js installs. Install nvm (piping into sh here, feel free to use the manual instructions):

$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.26.1/install.sh | bash
$ source ~/.bashrc
$ nvm install v0.10.40

You are now using node.js v0.10.40. You can use this version whenever you need to with nvm use v0.10.40

Now we need to install node.js dependencies using npm:

$ cd programs/server
$ npm i
$ cd ../../

Next, we'll setup our required environment variables, consult Meteor documentation or the README in the current directory for more information:

$ export ROOT_URL=http://localhost
$ export PORT=11014
$ export MONGO_URL=mongodb://localhost:27017/lair
$ export MONGO_OPLOG_URL=mongodb://localhost:27017/local

Finally, start the service:

$ node main.js
Created admin@localhost with password e5a8c667aafbec3

On first run, the app will create the user admin@localhost with a random password. This will be how you initially login to the app.

Lair API

Next, we will download run our API. In a new tab:

Download the latest binary for your operating system here:

$ cd ../../../
$ wget https://github.com/lair-framework/api-server/releases/download/v1.1.0/api-server_linux_amd64
$ chmod +x api-server_linux_amd64

Setup the needed environment variables and start:

$ export MONGO_URL=mongodb://localhost:27017/lair
$ export API_LISTENER=localhost:11015
$ ./api-server_linux_amd64 
2015/09/10 07:25:42 Listening on localhost:11015

Reverse HTTPS Proxy

Finally, we'll use Caddy as a reverse HTTPS proxy. In a new tab:

Download and extract Caddy for your operating system:

$ curl -o caddy.tar.gz 'http://caddyserver.com/download/build?os=linux&arch=amd64&features='
$ tar -zxvf caddy.tar.gz 

Generate SSL certificate:

$ openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 9999

Write the following into a file called Caddyfile:

# Change localhost to the interface you want to listen on.
localhost:11013
tls cert.pem key.pem
proxy /api localhost:11015
proxy / localhost:11014 {
  websocket
}

Start the proxy:

$ ./caddy --conf=Caddyfile
localhost:11013

You can now browse to lair at https://localhost:11013.

Clone this wiki locally