Project

General

Profile

Build Core On Ubuntu » History » Version 12

Version 11 (genii, 08/08/2011 05:37 PM) → Version 12/20 (HappyHappyMan, 02/05/2014 04:14 AM)

h1. Building Quassel core from source on Ubuntu

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

h3. Make sure repositories repositores are up-to-date

<pre>
sudo apt-get update
</pre>

h3. Install required dependencies and build tools

<pre>
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
</pre>

Also install the SQL sql driver for your planned backend.

- For sqlite (Quassel's (Quassels default, suggested for single user setups):
<pre>
sudo apt-get install libqt4-sql-sqlite
</pre>

- For PostgreSQL (suggested for multi-user multiuser setups):
<pre>
sudo apt-get install libqt4-sql-psql
</pre>

h3. Get the sources

<pre>
mkdir quassel-build
cd quassel-build
git clone https://github.com/quassel/quassel.git git://gitorious.org/quassel/quassel.git
</pre>

h3. Build it

<pre>
mkdir quassel/build
cd quassel/build
cmake -DWANT_CORE=1 -DWANT_QTCLIENT=0 -DWANT_MONO=0 ../
make
sudo optional step: make install
</pre>

Another common option to cmake would be:
<pre>
-DINSTALL_PREFIX=/path/where/it/should/be/installed
</pre>


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

h2. Optional Step: Use PostgreSQL as backend

h3. Setup PostgreSQL database master user

* "Follow these Ubuntu specific instructions":https://help.ubuntu.com/community/PostgreSQL

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

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

h2. Optional Step: Create SSL certificate:

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

h2. Running Core

"Screen":http://www.debuntu.org/2006/07/04/72-how-to-screen-the-ultimate-admin-tool is a terminal tool which allows allwos you to leave terminal sessions running in the background even when you are logged out.

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

<pre>
screen
cd quassel/build
./quasselcore
</pre>

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

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

<pre>
screen -x
</pre>

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

h2. First-time Setup Starting using it

The configuration 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.



h2. Start as Daemon

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

<pre>
### 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
</pre>

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:
<pre>
/etc/init.d/quasselcore start
</pre>