Project

General

Profile

Build Core On Ubuntu » History » Version 20

mamarley, 10/03/2016 06:14 PM

1 6 seezer
h1. Building Quassel core from source on Ubuntu
2 1 miohtama
3 12 HappyHappyMan
These instructions tell how to build the latest Quassel core from git for your Ubuntu server or desktop.
4 12 HappyHappyMan
Since it scales better with many users and huge amounts of history, setting up PostgreSQL as a backend will be explained as well.
5 1 miohtama
6 18 zhsj
h2. Basic step: Build from source
7 19 zhsj
8 12 HappyHappyMan
h3. Make sure repositories are up-to-date
9 6 seezer
10 1 miohtama
<pre>
11 1 miohtama
sudo apt-get update
12 1 miohtama
</pre>
13 1 miohtama
14 7 seezer
h3. Install required dependencies and build tools
15 6 seezer
16 17 zhsj
* Ubuntu Desktop:
17 11 genii
<pre>
18 17 zhsj
sudo apt-get install git qt4-dev-tools libqt4-dev libqt4-sql-sqlite screen cmake build-essential
19 1 miohtama
</pre>
20 1 miohtama
21 17 zhsj
* Ubuntu Server (installed with PostgreSQL):
22 6 seezer
<pre>
23 17 zhsj
sudo apt-get -o APT::Install-Recommends=0 -o APT::Install-Suggests=0 install git-core qt4-dev-tools libqt4-dev libqt4-sql-psql screen cmake build-essential
24 6 seezer
</pre>
25 12 HappyHappyMan
26 17 zhsj
If you want to change the SQL driver, just replace the package libqt4-sql-* with what you want.
27 17 zhsj
* SQLite(libqt4-sql-sqlite) is suggested for single user setups.
28 17 zhsj
* PostgreSQL(libqt4-sql-psql) is suggested for multi-user setups
29 6 seezer
30 6 seezer
h3. Get the sources
31 6 seezer
32 7 seezer
<pre>
33 12 HappyHappyMan
mkdir quassel-build
34 12 HappyHappyMan
cd quassel-build
35 12 HappyHappyMan
git clone https://github.com/quassel/quassel.git
36 1 miohtama
</pre>
37 1 miohtama
38 7 seezer
h3. Build it
39 6 seezer
40 4 seezer
<pre>
41 1 miohtama
mkdir quassel/build
42 1 miohtama
cd quassel/build
43 1 miohtama
cmake -DWANT_CORE=1 -DWANT_QTCLIENT=0 -DWANT_MONO=0 ../
44 1 miohtama
make
45 12 HappyHappyMan
sudo make install
46 1 miohtama
</pre>
47 1 miohtama
48 1 miohtama
Another common option to cmake would be:
49 1 miohtama
<pre>
50 15 midzer
-DCMAKE_INSTALL_PREFIX=/path/where/it/should/be/installed
51 6 seezer
</pre>
52 12 HappyHappyMan
53 5 seezer
Otherwise /usr/local/ is used as the install prefix.
54 6 seezer
55 1 miohtama
h2. Optional Step: Use PostgreSQL as backend
56 7 seezer
57 6 seezer
h3. Setup PostgreSQL database master user
58 1 miohtama
59 2 miohtama
* "Follow these Ubuntu specific instructions":https://help.ubuntu.com/community/PostgreSQL
60 7 seezer
61 1 miohtama
h3. Setup quassel PostgreSQL database. The database password will be asked later by the Quassel client configuration wizard.
62 1 miohtama
63 1 miohtama
<pre>
64 1 miohtama
sudo -u postgres psql
65 1 miohtama
postgres=# CREATE USER quassel ENCRYPTED PASSWORD 'somepassword';
66 1 miohtama
CREATE ROLE
67 1 miohtama
postgres=# CREATE DATABASE quassel WITH OWNER quassel ENCODING 'UTF8';
68 1 miohtama
CREATE DATABASE
69 1 miohtama
</pre>
70 1 miohtama
71 6 seezer
h2. Optional Step: Create SSL certificate:
72 1 miohtama
73 1 miohtama
<pre>
74 1 miohtama
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout ~/.config/quassel-irc.org/quasselCert.pem -out ~/.config/quassel-irc.org/quasselCert.pem
75 1 miohtama
</pre>
76 1 miohtama
77 1 miohtama
h2. Running Core
78 1 miohtama
79 12 HappyHappyMan
"Screen":http://www.debuntu.org/2006/07/04/72-how-to-screen-the-ultimate-admin-tool is a terminal tool which allows you to leave terminal sessions running in the background even when you are logged out.
80 1 miohtama
81 12 HappyHappyMan
We run Quassel in screen so that core keeps running as long as it is killed or the server is restarted
82 1 miohtama
83 1 miohtama
<pre>
84 1 miohtama
screen
85 1 miohtama
cd quassel/build
86 1 miohtama
./quasselcore
87 1 miohtama
</pre>
88 1 miohtama
89 12 HappyHappyMan
Now you can shut down your terminal and the Quassel core still keeps running. 
90 1 miohtama
91 12 HappyHappyMan
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:
92 1 miohtama
93 1 miohtama
<pre>
94 1 miohtama
screen -x
95 1 miohtama
</pre>
96 1 miohtama
97 1 miohtama
Now you should how you left your terminal last time you shut it down.
98 1 miohtama
99 1 miohtama
100 12 HappyHappyMan
h2. First-time Setup
101 8 yitsushi
102 12 HappyHappyMan
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.
103 8 yitsushi
104 8 yitsushi
h2. Start as Daemon
105 8 yitsushi
106 20 mamarley
*make install*, create a user *quasselcore* with *quassel* group.
107 20 mamarley
108 20 mamarley
If your system uses systemd, create */lib/systemd/system/quasselcore.service* with the following contents, adjusting DATADIR and LOGFILE as needed:
109 20 mamarley
110 20 mamarley
<pre>
111 20 mamarley
[Unit]
112 20 mamarley
Description=distributed IRC client using a central core component
113 20 mamarley
Documentation=man:quasselcore(1)
114 20 mamarley
Wants=network-online.target postgresql.service
115 20 mamarley
After=network-online.target postgresql.service
116 20 mamarley
117 20 mamarley
[Service]
118 20 mamarley
User=quasselcore
119 20 mamarley
Group=quassel
120 20 mamarley
WorkingDirectory=/var/lib/quassel
121 20 mamarley
Environment="DATADIR=/var/lib/quassel" "LOGFILE=/var/log/quassel/core.log" "LOGLEVEL=Info" "PORT=4242"
122 20 mamarley
EnvironmentFile=-/etc/default/quasselcore
123 20 mamarley
ExecStart=/usr/bin/quasselcore --configdir=${DATADIR} --logfile=${LOGFILE} --loglevel=${LOGLEVEL} --port=${PORT}
124 20 mamarley
Restart=on-failure
125 20 mamarley
126 20 mamarley
[Install]
127 20 mamarley
WantedBy=multi-user.target
128 20 mamarley
</pre>
129 20 mamarley
130 20 mamarley
Otherwise, create the */etc/init.d/quasselcore*:
131 8 yitsushi
132 8 yitsushi
<pre>
133 8 yitsushi
### BEGIN INIT INFO
134 8 yitsushi
# Provides:          quasselcore
135 8 yitsushi
# Required-Start:    $network $local_fs
136 8 yitsushi
# Required-Stop:
137 8 yitsushi
# Should-Start:
138 8 yitsushi
# Should-Stop:
139 8 yitsushi
# Default-Start:     2 3 4 5
140 8 yitsushi
# Default-Stop:      0 1 6
141 8 yitsushi
# Short-Description: distributed IRC client using a central core component
142 8 yitsushi
# Description:       This is the core component of Quassel. A modern,
143 8 yitsushi
#                    cross-platform, distributed IRC client, meaning that one
144 8 yitsushi
#                    (or multiple) client(s) can attach to and detach from this
145 8 yitsushi
#                    central core. It's much like the popular combination
146 8 yitsushi
#                    of screen and a text-based IRC client such as WeeChat.
147 8 yitsushi
### END INIT INFO
148 8 yitsushi
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
149 8 yitsushi
150 8 yitsushi
DAEMON=/usr/local/bin/quasselcore
151 8 yitsushi
NAME=quasselcore
152 8 yitsushi
DESC="distributed IRC core"
153 10 verschdl
LOGDIR=/var/log/quassel
154 8 yitsushi
PORT=4242
155 8 yitsushi
156 8 yitsushi
PIDFILE=/var/run/quasselcore.pid
157 8 yitsushi
158 8 yitsushi
test -x $DAEMON || exit 0
159 8 yitsushi
160 8 yitsushi
. /lib/lsb/init-functions
161 8 yitsushi
162 8 yitsushi
DAEMON_OPTS=""
163 8 yitsushi
DIETIME=10
164 8 yitsushi
STARTIME=3
165 8 yitsushi
LOGFILE=$LOGDIR/core.log
166 8 yitsushi
DATADIR=/var/cache/quassel
167 8 yitsushi
DAEMONUSER=quasselcore
168 8 yitsushi
169 8 yitsushi
if [ -f /etc/default/$NAME ] ; then
170 8 yitsushi
    . /etc/default/$NAME
171 8 yitsushi
fi
172 8 yitsushi
173 8 yitsushi
if [ -n "$DAEMONUSER" ] ; then
174 8 yitsushi
    if getent passwd | grep -q "^$DAEMONUSER:"; then
175 8 yitsushi
        # Obtain the uid and gid
176 8 yitsushi
        DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
177 8 yitsushi
        DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
178 8 yitsushi
    else
179 8 yitsushi
        log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
180 8 yitsushi
        exit 1
181 8 yitsushi
    fi
182 8 yitsushi
fi
183 8 yitsushi
184 8 yitsushi
set -e
185 8 yitsushi
186 8 yitsushi
running_pid() {
187 8 yitsushi
    pid=$1
188 8 yitsushi
    name=$2
189 8 yitsushi
    [ -z "$pid" ] && return 1
190 8 yitsushi
    [ ! -d /proc/$pid ] &&  return 1
191 8 yitsushi
    cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1`
192 8 yitsushi
    [ "$cmd" != "$name" ] &&  return 1
193 8 yitsushi
    return 0
194 8 yitsushi
}
195 8 yitsushi
196 8 yitsushi
running() {
197 8 yitsushi
    [ ! -f "$PIDFILE" ] && return 1
198 8 yitsushi
    pid=`cat $PIDFILE`
199 8 yitsushi
    running_pid $pid $DAEMON || return 1
200 8 yitsushi
    return 0
201 8 yitsushi
}
202 8 yitsushi
203 8 yitsushi
start_server() {
204 8 yitsushi
    start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \
205 8 yitsushi
        --background --chuid $DAEMONUSER --exec $DAEMON \
206 8 yitsushi
        -- --logfile=$LOGFILE --loglevel=$LOGLEVEL --configdir=$DATADIR \
207 8 yitsushi
           --port=$PORT \
208 8 yitsushi
           $DAEMON_OPTS
209 8 yitsushi
    errcode=$?
210 8 yitsushi
    return $errcode
211 8 yitsushi
}
212 8 yitsushi
213 8 yitsushi
stop_server() {
214 8 yitsushi
    start-stop-daemon --stop --quiet --pidfile $PIDFILE --user $DAEMONUSER \
215 8 yitsushi
        --exec $DAEMON
216 8 yitsushi
    errcode=$?
217 8 yitsushi
    return $errcode
218 8 yitsushi
}
219 8 yitsushi
220 8 yitsushi
force_stop() {
221 8 yitsushi
    [ ! -e "$PIDFILE" ] && return
222 8 yitsushi
    if running ; then
223 8 yitsushi
        kill -15 $pid
224 8 yitsushi
    # Is it really dead?
225 8 yitsushi
        sleep "$DIETIME"s
226 8 yitsushi
        if running ; then
227 8 yitsushi
            kill -9 $pid
228 8 yitsushi
            sleep "$DIETIME"s
229 8 yitsushi
            if running ; then
230 8 yitsushi
                echo "Cannot kill $NAME (pid=$pid)!"
231 8 yitsushi
                exit 1
232 8 yitsushi
            fi
233 8 yitsushi
        fi
234 8 yitsushi
    fi
235 8 yitsushi
    rm -f $PIDFILE
236 8 yitsushi
}
237 8 yitsushi
238 8 yitsushi
case "$1" in
239 8 yitsushi
  start)
240 8 yitsushi
    log_daemon_msg "Starting $DESC" "$NAME"
241 8 yitsushi
        # Check if it's running first
242 8 yitsushi
        if running ;  then
243 8 yitsushi
            log_progress_msg "apparently already running"
244 8 yitsushi
            log_end_msg 0
245 8 yitsushi
            exit 0
246 8 yitsushi
        fi
247 8 yitsushi
        if start_server ; then
248 8 yitsushi
            [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
249 8 yitsushi
            if  running ;  then
250 8 yitsushi
                log_end_msg 0
251 8 yitsushi
            else
252 8 yitsushi
                log_end_msg 1
253 8 yitsushi
            fi
254 8 yitsushi
        else
255 8 yitsushi
            log_end_msg 1
256 8 yitsushi
        fi
257 8 yitsushi
    ;;
258 8 yitsushi
  stop)
259 8 yitsushi
        log_daemon_msg "Stopping $DESC" "$NAME"
260 8 yitsushi
        if running ; then
261 8 yitsushi
            stop_server
262 8 yitsushi
            log_end_msg $?
263 8 yitsushi
        else
264 8 yitsushi
            log_progress_msg "apparently not running"
265 8 yitsushi
            log_end_msg 0
266 8 yitsushi
            exit 0
267 8 yitsushi
        fi
268 8 yitsushi
        ;;
269 8 yitsushi
  force-stop)
270 8 yitsushi
        $0 stop
271 8 yitsushi
        if running; then
272 8 yitsushi
            # If it's still running try to kill it more forcefully
273 8 yitsushi
            log_daemon_msg "Stopping (force) $DESC" "$NAME"
274 8 yitsushi
            force_stop
275 8 yitsushi
            log_end_msg $?
276 8 yitsushi
        fi
277 8 yitsushi
    ;;
278 8 yitsushi
  restart|force-reload)
279 8 yitsushi
        log_daemon_msg "Restarting $DESC" "$NAME"
280 8 yitsushi
        stop_server
281 8 yitsushi
        # Wait some sensible amount, some server need this
282 8 yitsushi
        [ -n "$DIETIME" ] && sleep $DIETIME
283 8 yitsushi
        start_server
284 8 yitsushi
        [ -n "$STARTTIME" ] && sleep $STARTTIME
285 8 yitsushi
        running
286 8 yitsushi
        log_end_msg $?
287 8 yitsushi
    ;;
288 8 yitsushi
  status)
289 8 yitsushi
        log_daemon_msg "Checking status of $DESC" "$NAME"
290 8 yitsushi
        if running ; then
291 8 yitsushi
            log_success_msg "running"
292 8 yitsushi
            log_end_msg 0
293 8 yitsushi
        else
294 8 yitsushi
            log_success_msg "apparently not running"
295 8 yitsushi
            log_end_msg 1
296 8 yitsushi
            exit 1
297 8 yitsushi
        fi
298 8 yitsushi
        ;;
299 8 yitsushi
  reload)
300 8 yitsushi
        log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
301 8 yitsushi
        log_warning_msg "cannot re-read the config file (use restart)."
302 8 yitsushi
        ;;
303 8 yitsushi
304 8 yitsushi
  *)
305 8 yitsushi
    N=/etc/init.d/$NAME
306 8 yitsushi
      echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2
307 8 yitsushi
    exit 1
308 8 yitsushi
    ;;
309 8 yitsushi
esac
310 8 yitsushi
311 8 yitsushi
exit 0
312 8 yitsushi
</pre>
313 8 yitsushi
314 14 rikai
* *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":https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=701943. Simply change the the Should-Start and Should-Stop parameters to the following:
315 13 rikai
<pre>
316 13 rikai
  # Should-Start: mysql postgresql
317 13 rikai
  # Should-Stop: mysql postgresql
318 13 rikai
</pre>
319 13 rikai
320 8 yitsushi
And now...
321 8 yitsushi
Binary: /usr/local/bin/quasselcore
322 8 yitsushi
The logfile is: /var/log/quassel/core.log
323 8 yitsushi
PID-file: /var/run/quasselcore.pid
324 8 yitsushi
Data dir (confi, cert): /var/cache/quassel
325 8 yitsushi
Daemon-user: quasselcore
326 8 yitsushi
327 8 yitsushi
Ok... Start: 
328 8 yitsushi
<pre>
329 8 yitsushi
/etc/init.d/quasselcore start
330 1 miohtama
</pre>