Project

General

Profile

Build Core On Ubuntu » History » Version 14

« Previous - Version 14/20 (diff) - Next » - Current version
rikai, 02/18/2014 07:22 PM
Punctuation.


Building Quassel core from source on Ubuntu

These instructions tell how to build the latest Quassel core from git for your Ubuntu server or desktop.
Since it scales better with many users and huge amounts of history, setting up PostgreSQL as a backend will be explained as well.

Make sure repositories are up-to-date

sudo apt-get update

Install required dependencies and build tools

sudo apt-get install git-core qt4-dev-tools libqt4-dev libqt4-sql-sqlite screen cmake
* Ubuntu Server Note: use instead:
sudo apt-get -o APT::Install-Recommends=0 -o APT::Install-Suggests=0 install git-core qt4-dev-tools cmake libqt4-dev libqt4-sql-sqlite screen

Also install the SQL driver for your planned backend.

- For sqlite (Quassel's default, suggested for single user setups):

sudo apt-get install libqt4-sql-sqlite

- For PostgreSQL (suggested for multi-user setups):

sudo apt-get install libqt4-sql-psql

Get the sources

mkdir quassel-build
cd quassel-build
git clone https://github.com/quassel/quassel.git

Build it

mkdir quassel/build
cd quassel/build
cmake -DWANT_CORE=1 -DWANT_QTCLIENT=0 -DWANT_MONO=0 ../
make
sudo make install

Another common option to cmake would be:

-DINSTALL_PREFIX=/path/where/it/should/be/installed

Otherwise /usr/local/ is used as the install prefix.

Optional Step: Use PostgreSQL as backend

Setup PostgreSQL database master user

Setup quassel PostgreSQL database. The database password will be asked later by the Quassel client configuration wizard.

sudo -u postgres psql
postgres=# CREATE USER quassel ENCRYPTED PASSWORD 'somepassword';
CREATE ROLE
postgres=# CREATE DATABASE quassel WITH OWNER quassel ENCODING 'UTF8';
CREATE DATABASE

Optional Step: Create SSL certificate:

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.config/quassel-irc.org/quasselCert.pem -out ~/.config/quassel-irc.org/quasselCert.pem

Running Core

Screen is a terminal tool which allows you to leave terminal sessions running in the background even when you are logged out.

We run Quassel in screen so that core keeps running as long as it is killed or the server is restarted

screen
cd quassel/build
./quasselcore

Now you can shut down your terminal and the Quassel core still keeps running.

Later we can reattach to this screen session to check out the Quassel core terminal output to see if there has been any problems. Log in and type:

screen -x

Now you should how you left your terminal last time you shut it down.

First-time Setup

The configuration wizard will guide you through the rest of the setup when you connect to your Quassel core using a Quassel client for the first time. Remember to choose PostgreSQL backend instead of SQLite when asked.

Start as Daemon

make install, create a user quasselcore with quassel group and create the /etc/init.d/quasselcore:

### BEGIN INIT INFO
# Provides:          quasselcore
# Required-Start:    $network $local_fs
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: distributed IRC client using a central core component
# Description:       This is the core component of Quassel. A modern,
#                    cross-platform, distributed IRC client, meaning that one
#                    (or multiple) client(s) can attach to and detach from this
#                    central core. It's much like the popular combination
#                    of screen and a text-based IRC client such as WeeChat.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DAEMON=/usr/local/bin/quasselcore
NAME=quasselcore
DESC="distributed IRC core" 
LOGDIR=/var/log/quassel
PORT=4242

PIDFILE=/var/run/quasselcore.pid

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

DAEMON_OPTS="" 
DIETIME=10
STARTIME=3
LOGFILE=$LOGDIR/core.log
DATADIR=/var/cache/quassel
DAEMONUSER=quasselcore

if [ -f /etc/default/$NAME ] ; then
    . /etc/default/$NAME
fi

if [ -n "$DAEMONUSER" ] ; then
    if getent passwd | grep -q "^$DAEMONUSER:"; then
        # Obtain the uid and gid
        DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
        DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
    else
        log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist." 
        exit 1
    fi
fi

set -e

running_pid() {
    pid=$1
    name=$2
    [ -z "$pid" ] && return 1
    [ ! -d /proc/$pid ] &&  return 1
    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
    [ "$cmd" != "$name" ] &&  return 1
    return 0
}

running() {
    [ ! -f "$PIDFILE" ] && return 1
    pid=`cat $PIDFILE`
    running_pid $pid $DAEMON || return 1
    return 0
}

start_server() {
    start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \
        --background --chuid $DAEMONUSER --exec $DAEMON \
        -- --logfile=$LOGFILE --loglevel=$LOGLEVEL --configdir=$DATADIR \
           --port=$PORT \
           $DAEMON_OPTS
    errcode=$?
    return $errcode
}

stop_server() {
    start-stop-daemon --stop --quiet --pidfile $PIDFILE --user $DAEMONUSER \
        --exec $DAEMON
    errcode=$?
    return $errcode
}

force_stop() {
    [ ! -e "$PIDFILE" ] && return
    if running ; then
        kill -15 $pid
    # Is it really dead?
        sleep "$DIETIME"s
        if running ; then
            kill -9 $pid
            sleep "$DIETIME"s
            if running ; then
                echo "Cannot kill $NAME (pid=$pid)!" 
                exit 1
            fi
        fi
    fi
    rm -f $PIDFILE
}

case "$1" in
  start)
    log_daemon_msg "Starting $DESC" "$NAME" 
        # Check if it's running first
        if running ;  then
            log_progress_msg "apparently already running" 
            log_end_msg 0
            exit 0
        fi
        if start_server ; then
            [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
            if  running ;  then
                log_end_msg 0
            else
                log_end_msg 1
            fi
        else
            log_end_msg 1
        fi
    ;;
  stop)
        log_daemon_msg "Stopping $DESC" "$NAME" 
        if running ; then
            stop_server
            log_end_msg $?
        else
            log_progress_msg "apparently not running" 
            log_end_msg 0
            exit 0
        fi
        ;;
  force-stop)
        $0 stop
        if running; then
            # If it's still running try to kill it more forcefully
            log_daemon_msg "Stopping (force) $DESC" "$NAME" 
            force_stop
            log_end_msg $?
        fi
    ;;
  restart|force-reload)
        log_daemon_msg "Restarting $DESC" "$NAME" 
        stop_server
        # Wait some sensible amount, some server need this
        [ -n "$DIETIME" ] && sleep $DIETIME
        start_server
        [ -n "$STARTTIME" ] && sleep $STARTTIME
        running
        log_end_msg $?
    ;;
  status)
        log_daemon_msg "Checking status of $DESC" "$NAME" 
        if running ; then
            log_success_msg "running" 
            log_end_msg 0
        else
            log_success_msg "apparently not running" 
            log_end_msg 1
            exit 1
        fi
        ;;
  reload)
        log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon" 
        log_warning_msg "cannot re-read the config file (use restart)." 
        ;;

  *)
    N=/etc/init.d/$NAME
      echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
    exit 1
    ;;
esac

exit 0
  • Note: By default this script will not work after a reboot with mysql/postgresql backends. If you're interested in that, this should make quassel start with either mysql or postgresql as per this bug report. Simply change the the Should-Start and Should-Stop parameters to the following:
      # Should-Start: mysql postgresql
      # Should-Stop: mysql postgresql
    

And now...
Binary: /usr/local/bin/quasselcore
The logfile is: /var/log/quassel/core.log
PID-file: /var/run/quasselcore.pid
Data dir (confi, cert): /var/cache/quassel
Daemon-user: quasselcore

Ok... Start:

/etc/init.d/quasselcore start