Setting up a Lino production server

Here is a set of conventions we suggest to use as a site maintainer when setting up a Lino production server.

Set up a master environment

If you are the first site maintainer on this server, you must set up the master environment.

master environment

A virtualenv to be used as default virtualenv for all site maintainers on this production server. It mainly contains getlino.

The master environment should be outside of your home:

$ sudo mkdir /usr/local/lino/shared/env
$ cd /usr/local/lino/shared/env
$ sudo chown root:www-data .
$ sudo chmod g+ws .
$ virtualenv -p python3 master
$ . /usr/local/lino/shared/env/master/bin/activate

Add the following line to your .bashrc:

. /usr/local/lino/shared/env/master/bin/activate

Install getlino and run getlino configure

Install getlino into the master environment:

$ pip install getlino

Run getlino configure as root:

$ sudo env PATH=$PATH getlino configure --no-clone --appy --https

The env PATH=$PATH is needed to work around the controversial Debian feature of overriding the PATH for security reasons (source).

If your customers want to access their Lino from outside of their intranet, then you need to setup a domain name and add the --https option in above command line.

When at least one Lino site of a server uses lino_xl.lib.appypod, then the server must have a LibreOffice service running so that the users of your site can print documents using the appypdf, appydoc or appyrtf methods (the appyodt method does not require a LO service). You say this using the getlino configure --appy option. For background information see Running a LibreOffice server.

For details see the documentation about getlino.

Check /etc/aliases

Every production server should be able to send emails to its maintainers, e.g. to notify them when a cron job fails.

$ sudo apt install sendmail
$ sudo nano /etc/aliases   # add your email address
$ sudo newaliases

Install your first site

You will do the following for every new site on your server.

$ sudo env PATH=$PATH getlino startsite application_name site_name

Point your browser to http://first.localhost

  • application_name is one of the known Lino applications (noi, cosi, avanti, voga...)

  • site_name is the unique internal name of your site on this server.

Some useful additions to your shell

Add the following to your system-wide /etc/bash.bashrc:

alias ll='ls -al'
alias a='. env/bin/activate'

function pywhich() {
  python -c "import $1; print($1.__file__)"
}

# find another name if your team also uses golang
function go() {
    for BASE in /usr/local/lino/lino_local
    do
      if [ -d $BASE/$1 ] ; then
        cd $BASE/$1;
        return;
      fi
    done
    echo Oops: no project $1
    return -1
}

If you want Logging all bash commands to syslog, then add also this:

# copied from http://backdrift.org/logging-bash-history-to-syslog-using-traps
function log2syslog
{
   declare COMMAND
   COMMAND=$(fc -ln -0)
   logger -p local1.notice -t bash -i -- "${USER}:${COMMAND}"
}
trap log2syslog DEBUG

After these changes you must close and reopen your terminal to activate them. You can now do the following to quickly cd to a project directory and activate its Python environment:

$ go prj1
$ a