Very Secure

Setting up trinque's logbot on centos 6 with sbcl, quicklisp, swank, and postgres

While this guide goes over how to setup logbot, it should be a useful reference for anyone who wants to start a sbcl process on a remote machine and then be able to interact with that process through their local repl1 - connecting / disconnecting and firing off subthreads at will.

I. Install SBCL 1.4.14

Connect to your centos6 VM as root. You can download sbcl 1.4.14 from my new codeshelf.2

keksum sbcl-1.4.14-x86-64-linux-binary.tar.bz2

bzip2 -cd sbcl-1.4.14-x86-64-linux-binary.tar.bz2 | tar xvf -
cd sbcl-1.4.14-x86-64-linux

II. Install quicklisp and swank.

Create and ssh into the user that will be running your program.3
Then download quicklisp either from or from my codeshelf.

keksum quicklisp.lisp

Load quicklisp, then inside the repl: install quicklisp, set (load "~/quicklisp/setup.lisp") to run when you start sbcl, then install slime so that you can start a swank server.

sbcl --load quicklisp.lisp

(ql:quickload "quicklisp-slime-helper")

III. Start and connect to the swank server.

Make a file named start_swank.lisp, with the following contents:4

(defvar *alive* t)
(load "~/quicklisp/setup.lisp")
(ql:quickload :swank)
(loop (sleep 10000) (if (not *alive*) (quit)))

then start the server.

nohup sbcl --script start_swank.lisp &

Now you have a swank server running. If you have a local emacs with slime installed, you can connect by using a terminal to start an ssh tunnel

ssh -L 4005:localhost:4005 USER@

and then within emacs run slime-connect to connect to the swank-server on localhost with port 4005

m-x slime-connect; ret; ret;

If you enter


into the repl and get back T, you are connected!

IV. Grab trinque's source.

UPDATE: If you want to connect to multiple channels, you'll want ben_vulple's vpatch logbot-multiple-channels-correct

The vpatches that constitute trinque's code can be found here. Some of the vpatches use keccak for hashing, some use sha512sum. So you will need two versions of V, or a V that can handle both forms of hashing, to press everything.

Once you've grabbed the sources place them in the


directory of the user that will be running the swank server.

V. Install & Setup Postgres 9.4

ssh into root. First you will download the repository information to be able to install postgres94 with yum. I mirrored the repository rpm on my codeshelf.6

keksum pgdg-redhat-repo-latest.noarch.rpm

rpm -ivh pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql94 postgresql94-server postgresql94-contrib

Now that postgres v9.4 is installed init the db

/etc/init.d/postgresql-9.4 initdb

That command will have created a conf file


Edit this file changing

# IPV4 local connections
host all all ident


# IPV4 local connections
host all all md57

Now start the db, and set it to start on boot.

/etc/init.d/postgresql-9.4 start
chkconfig postgresql-9.4 on

Then hop in the postgres shell.

su postges

Once inside the postgres shell, run the following commands, changing the values in capital letters as appropriate. Note that the
NONROOTUSER needs to be the same as the name of the user created in step II. that will run logbot / the swank server.:

create database logbotdb;
create user NONROOTUSER with encrypted password 'THEPASSWORD';
grant all privileges on schema public to NONROOTUSER;

Reconnect into the logbotdb and create the necessary extensions.

psql logbotdb

create extension if not exists plpgsql;
create extension if not exists pgcrypto;
create extension if not exists "uuid-ossp";

These last three create extension commands are in trinque's logbot.sql file that we are about to run. However, I had to run these manually in the shell while su'd to postgres. The NONROOTUSER does not have permission to create the extensions.

Now ssh into the NONROOTUSER and edit logbot.sql removing those three lines above.

--- create extension if not exists plpgsql;
--- create extension if not exists pgcrypto;
--- create extension if not exists "uuid-ossp";

Then run

psql -f logbot.sql logbotdb;

You're done! If you run

psql logbotdb;

and then in the postgres shell:


You should see two tables log and outbox. If everything looks good you can refer to the instructions at the end of step 3 to start the swank server that will run logbot. Once the swank server is running connect your local slime repl and then follow the logbot instructions.


Future steps to improve the setup process:

1. Slime and postgres9.4 and all related packages should be stored on a codeshelf.
2. Quicklisp, slime, and eventually sbcl should be signed.
3. There may be a better way to create/run the start_swank.lisp script.
4. It may be worth creating a vpatch removing logbot.sql create extensions lines and then adding the instructions on how to create the extensions while root to logbot's INSTALL file.

  1. Well the "r", "p", and "l" are local. The evaluation happens on the VM. []
  2. Note: I tried other versions of sbcl to no avail. The default version installed with yum has an asdf version incompatible with the libraries used by logbot. The most recent versions of sbcl on wouldn't compile on my machine. I found this version of sbcl on sourceforge. []
  3. On digitalocean you will need to allow your newly created user to accept connections from your machine by copying over the authorized_keys from root. While inside root run:

    adduser newuser
    mkdir /home/newuser/.ssh
    cp ~/.ssh/authorized_keys /home/newuser/.ssh/authorized_keys
    chown newuser /home/newuser/.ssh
    chown newuser /home/newuser/.ssh/authorized_keys


  4. The infinite loop that sleeps for 10,000 seconds each iteration to keep the process running works well, but I do not think it's the right way to do what I want. I tried to run the script without the infinte loop with sbcl --load start_swank.lisp. However this did not work with nohup because of the way nohup redirects stdin/stdout. Using --load may work with screen, but screen does not come preinstalled on centos 6. []
  5. replace USER and accordingly []
  6. This is put on the codeshelf for convenience. The rpm file is not the source, but rather the file that contains the location of the source. []
  7. This will allow you to later be able to connect to the database via cl's postgres library with the "encrypted" (i.e. hashed) password. []

One Response to “Setting up trinque's logbot on centos 6 with sbcl, quicklisp, swank, and postgres”

  1. [...] 1. Setting up Trinque's Logbot on Centos 6 With SBCL Quiclisp, Swank, and Postgres [...]

Leave a Reply