58 Installation
André Jaenisch edited this page 6 months ago

Installation

Required packages

Arch Linux

pacman -S npm nodejs
yay -S mongodb-bin mongodb-tools-bin

RaspberryPi 2/3 (tested with raspbian stretch)

Note: Since monodb is no longer available for armhf in newer versions (> 3.2) and the version (2.4) in raspbian is too old, an Ubuntu package (2.6) can be installed. It can be assumed that this Verion is no longer supplied with security updates ...

# Install Nodejs
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs autoconf libcurl3
sudo npm install -g gulp

# Install MongoDB
wget http://launchpadlibrarian.net/214171391/mongodb-server_2.6.10-0ubuntu1_armhf.deb
wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u11_armhf.deb
sudo dpkg -i mongodb-server_2.6.10-0ubuntu1_armhf.deb
sudo dpkg -i libssl1.0.0_1.0.1t-1+deb8u11_armhf.deb
apt-get -f install

Debian

# Install MongoDB
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
apt-get update
apt-get install -y mongodb-org

# Install Nodejs
curl -sL https://deb.nodesource.com/setup_12.x -o nodesource_setup.sh
bash nodesource_setup.sh
apt install nodejs

# Install Tools
apt-get install git autoconf libcurl4
sudo npm install -g gulp

Also check for an update for npm in order to fix latest security issues in the packages you will need to install later on.

Get sources of base application

git clone https://codeberg.org/lerntools/base.git

Get sources of additional modules

Important: Only clone required modules, skip other lines

cd base
mkdir modules
cd modules
git clone https://codeberg.org/lerntools/abcd.git
git clone https://codeberg.org/lerntools/about.git
git clone https://codeberg.org/lerntools/ideas.git
git clone https://codeberg.org/lerntools/projector.git
git clone https://codeberg.org/lerntools/survey.git
git clone https://codeberg.org/lerntools/tex.git

Install JS libraries

All dependencies can be installed using the package manager for nodejs:

cd .. # go back to base
npm install

On the RaspberryPi this step takes about half an hour, as some of the required packages are compiled first.

If npm displays audit security warnings, you shoulf fix them:

npm audit fix

Configure Server

  1. Copy the file server.config.example.json to server.config.production.json (do not rename!)
  2. Basic configuration by adjusting the values in the server.config.production.json file, be sure to add a valid "SMTP_CONF" and "USER_ADMIN_MAIL" - otherwise you won't be able to change your password or administrate users!
  3. Start the database: sudo systemctl start mongodb
  4. Initialize the database : node bin/installDatabase.js

Important: Copy the initial admin password from the output - you won't get a chance to get this password later...

**********************************************************
Initial Password for user admin
EMXc8sOA5ycmote68jvNb
**********************************************************

Configure Client App

  1. Copy the file app.config.example.js to app.config.js (do not rename!)
  2. Remove unwanted modules from app.config.js (import statement and entry in allModules)
  3. Basic configuration by adjusting the values in the app.config.js file

Create upload and data directory

mkdir upload
mkdir data

Ensure, the user running nodejs is allowed to write files into that folder.

  1. Create direcory: mkdir -p main/text/en
  2. Edit main/text/en/imprint.md for your contact information
  3. Edit main/text/en/terms.md for terms of usage
  4. Edit main/text/en/privacy.mc for information on privacy

Repeat theese steps for all supported languages by replacing "en" with "de" for example. The page title is generated from the level 1 headline:

# Imprint

## First headline

Text...

Create the assets

The application does not have to be "compiled", however it is necessary to bundle the so-called assets (graphics, stylesheets, libraries, etc.). By compressing and summarizing the load times can be significantly improved. Gulp's main task does this work (it runs in the lerntools home directory):

npm run build

After that the directory dist contains the necessary files.

First start

  1. Starting the integrated webserver (port 8080) of nodejs:
npm start
  1. Open http://localhost:8080 in your browser
  2. Log in as admin (see output of bin/installDatabase.js for the initial credentials)
  3. Add your correct e-mail address for password recovery
  4. Import examples from the folder examples in the doc-folder

In order to administrate users you have to add a valid "SMTP_CONF" and "USER_ADMIN_MAIL" in server.config.production.json! You could also temporarily use the option "TAN_IGNORE": true, and enter "abcdef" as TAN. Be sure to change this setting back!

Tips

Deactivation of individual modules or functions

The application is modular, individual modules are located in the subfolder /modules/. In order to deactivate a module, you have to edit the file app.config.js:

  1. Remove specific import line
  2. Remove module from array allModules

Rerun npm run build-app afterwards.

Instructions mongodb

  1. Delete a table (referred as "collection") under Mongodb, here for example the collection "users":
mongo
use lerntools
db.users.drop();
  1. Delete the complete DB in Mongodb:
mongo
use lerntools
db.dropDatabase()
  1. Delete specific user (example admin):
mongo
use lerntools
db.users.deleteOne({login:'admin'});

Setup Lerntools using Docker

For installing Docker on the system, please refer to the Docker installation.

The official Lerntools Docker image contains the basic server and all of the modules. It can be found on Docker Hub.

The two following setups are also starting the database as a container. In case there is another configuration, please adapt the Lerntools configuration files accordingly.

Basic setup

This setup is The docker setup in this configuration is solely meant to provide an easy start for testing, not for production.

  1. Create the network for communication between lerntools and mongodb:
docker network create lerntools
  1. Run the database:
docker run -d --name mongodb --network=lerntools -v `pwd`/data:/data -p 27017:27017 mongo:latest
  1. Initialize the database:
docker run --network=lerntools lerntools/lerntools:latest node bin/installDatabase.js
  1. Run the lerntools container:
docker run -d --name lerntools --network=lerntools -p 8082:8082 lerntools/lerntools:latest
  1. Now you can access your new instance via http://localhost:8082.

Production Setup

This setup includes additionally saves the config files persistantly using volumes.

  1. Preparation: Create the files 'app.config.js' and 'server.config.production.json' on the machine by copying the template from the base repository and configuring them according to the desired configuration.

  2. Create the network for communication between lerntools and mongodb:

docker network create lerntools
  1. Run the database:
docker run -d --name mongodb --network=lerntools -v `pwd`/data:/data -p 127.0.0.1:27017:27017 mongo:latest
  1. Get rid of the existing configuration files within the container:
docker run lerntools/lerntools:latest rm /srv/base/app.config.js
docker run lerntools/lerntools:latest rm /srv/base/server.config.production.json
  1. Initialize the database:
docker run \
        --network=lerntools \
        -v `pwd`/server.config.production.json:/srv/base/server.config.production.json \
        lerntools/lerntools:latest \
        node bin/installDatabase.js
  1. Start the Lerntools container:
docker run -d \
        --restart always \
        --network=lerntools \
        --name lerntools \
        -p 8080:8080 \
        -v `pwd`/app.config.js:/srv/base/app.config.js \
        -v `pwd`/server.config.production.json:/srv/base/server.config.production.json \
        lerntools/lerntools:latest

If you don't want that your installation to be reachable from the internet via Port 8080 please run

docker run -d \
        --restart always \
        --network=lerntools \
        --name lerntools \
        -p 127.0.0.1:8080:8080 \
        -v `pwd`/app.config.js:/srv/base/app.config.js \
        -v `pwd`/server.config.production.json:/srv/base/server.config.production.json \
        lerntools/lerntools:latest

You would need to change the Containername from "localhost" to "mongodb" in server.config.production.json.

  1. Now you can access your new instance via http://localhost:8080.