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