Remove some system errors from errno.h
[paraslash.git] / INSTALL
1 INSTALL
2 =======
3
4 ----
5 Any knowledge of how to work with mouse and icons is not required.
6
7 ---------------------------
8 Install all needed packages
9 ---------------------------
10
11 See README for a list of required software. You don't need everything
12 listed there. In particular, mp3, ogg vorbis and aac support is
13 optional. Autoconf will detect what is installed on your system
14 and will only try to build those executables that can be built with
15 your setup.
16
17 Note that no special library (not even the mp3 decodong library libmad)
18 is needed for para_server if you only want to stream mp3 files.
19 Also, it's fine to use para_server on a box without sound card as
20 para_server only sends the audio stream to connected clients.
21
22 -------------------------
23 Install server and client
24 -------------------------
25
26 Install the package on all machines, you'd like this software to run on:
27
28         (./configure && make) > /dev/null
29
30 There should be no errors but probably some warnings about missing
31 software packages which usually implies that not all audio formats will
32 be supported. If headers or libs are installed at unusual locations
33 you might need to tell the configure script to find them.  Try
34
35         configure --help
36
37 to see a list of options. If the paraslash package was compiled
38 successfully, execute as root,
39
40         make install
41
42 -----------------------------------
43 Setup user list and create rsa keys
44 -----------------------------------
45
46 If you already have your rsa keys, skip this step. If you are new
47 to paraslash, you have to generate an rsa key pair for each user you
48 want to allow to connect. You need at least one user.
49
50 Let's assume that you'd like to run the server on host server_host
51 as user foo, and that you want to connect from client_host as user bar.
52
53 As foo@server_host, create ~/.paraslash/server.users by typing the
54 following commands:
55
56         target=~/.paraslash/server.users
57         key=~/.paraslash/key.pub.bar
58         perms=AFS_READ,AFS_WRITE,VSS_READ,VSS_WRITE
59         mkdir -p ~/.paraslash
60         echo "user bar $key $perms" >> $target
61
62 This gives "bar" the full privileges.
63
64 Change to the bar account on client_host and generate the key-pair
65 with the commands
66
67         key=~/.paraslash/key.bar
68         mkdir -p ~/.paraslash
69         (umask 077 && openssl genrsa -out $key)
70
71 Next, extract its public part:
72
73         pubkey=~/.paraslash/key.pub.bar
74         openssl rsa -in $key -pubout -out $pubkey
75
76 and copy the public key just created to server_host (you may
77 skip this step for a single-user setup, i.e. if foo=bar and
78 server_host=client_host):
79
80         scp $pubkey foo@server_host:.paraslash/
81
82 Finally, tell para_client to connect to server_host:
83
84         conf=~/.paraslash/client.conf
85         echo 'hostname server_host' > $conf
86
87 -----------------
88 Start para_server
89 -----------------
90
91 For this first try, we'll use a debug level of one to make the
92 output of para_server more verbose.
93
94         para_server -l 2
95
96 Now you can use para_client to connect to the server and issue
97 commands. Open a new shell (as "bar" on "client_host" in the above
98 example) and try
99
100         para_client help
101         para_client si
102
103 to retrieve the list of available commands and some server info.
104 Don't proceed if this doesn't work.
105
106 -------------------
107 Create the database
108 -------------------
109
110         para_client init
111
112 This creates some empty tables under ~/.paraslash/afs_database.
113 You normally don't need to look at these tables, but it's good
114 to know that you can start from scratch with
115
116         rm -rf ~/.paraslash/afs_database
117
118 in case something went wrong.
119
120 Next, you need to fill the audio file table of that database with
121 contents so that para_server knows about your audio files.  Choose an
122 absolute path to a directory containing some audio files and add them
123 to the audio file table:
124
125         para_client add /my/mp3/dir
126
127 This might take a while, so it is a good idea to start with a directory
128 containing not too many audio. Note that the table only contains data
129 about the audio files found, not the files themselves.
130
131 Print a list of all audio files found with
132
133         para_client ls
134
135 ------------------------
136 Start streaming manually
137 ------------------------
138
139         para play
140         para stat 2
141
142 This starts streaming and dumps some information about the current
143 audio file to stdout.
144
145 You should now be able to receive the stream and listen to it. If
146 you have mpg123 or xmms handy, execute on client_host
147
148         mpg123 http://server_host:8000/
149 or
150         xmms http://server_host:8000/
151
152 Paraslash comes with its own receiving and playing software, which
153 will be described next. Try the following on client_host (assuming
154 Linux/ALSA and an mp3 stream):
155
156         para_recv -l 2 -r 'http -i server_host' > file.mp3
157         # (interrupt with CTRL+C after a few seconds)
158         ls -l file.mp3 # should not be empty
159         para_filter -f mp3dec -f wav < file.mp3 > file.wav
160         ls -l file.wav # should be much bigger than file.mp3
161         para_write -w alsa < file.wav
162
163 If this works, proceed. Otherwise double check what is logged by
164 para_server and use the --loglevel option of para_recv, para_filter
165 and para_write to increase verbosity.
166
167 Next, put the pieces together:
168
169         para_recv -r 'http -i server_host' \
170                 | para_filter -f mp3dec -f wav \
171                 | para_write -w alsa
172
173 ---------------------
174 Configure para_audiod
175 ---------------------
176
177 In order to automatically start the right decoder at the right time
178 and to offer to the clients some information on the current audio
179 stream and on paraslash's internal state, you should run the local
180 audio daemon, para_audiod, on every machine in your network which is
181 supposed to play the audio stream. Try
182
183         para_audiod -h
184
185 for help. Usually you have to specify only server_host as the receiver
186 specifier for each supported audio format, like this:
187
188         para_audiod -l 2 -r 'mp3:http -i server_host'
189
190 The preferred way to use para_audiod is to run it once at system start
191 as an unprivileged user. para_audiod needs to create a "well-known"
192 socket for the clients to connect to. The default path for this
193 socket is
194
195         /var/paraslash/audiod_socket.$HOSTNAME
196
197 so the /var/paraslash directory should be owned by the user who
198 runs para_audiod.
199
200 If you want to change the location of the socket, use the -s option
201 for para_audiod or the config file ~/.paraslash/audiod.conf to change
202 the default. Note that in this case you'll also have to specify the
203 same value for para_audioc's -s option.
204
205 If para_server is playing, you should be able to listen to the audio
206 stream as soon as para_audiod is started.  Once it is running, try
207
208         para_audioc stat
209
210 That should dump some information to stdout. Other commands include
211
212         para_audioc off
213         para_audioc on
214         para_audioc sb
215         para_audioc term
216         para_audioc cycle
217
218 --------------
219 Start para_gui
220 --------------
221
222 para_gui reads the output of "para_audioc stat" and displays that
223 information in a curses window. It also allows you to bind keys to
224 arbitrary commands. There are several flavours of key-bindings:
225
226         - internal: These are the built-in commands that can not be
227           changed (help, quit, loglevel, version...).
228         - external: Shutdown curses before launching the given command.
229           Useful for starting other ncurses programs from within
230           para_gui, e.g. aumix or para_dbadm. Or, use "para_client
231           mbox" to write a mailbox containing one mail for each file
232           in the mysql database and start mutt from within para_gui
233           to browse your collection!
234         - display: Launch the command and display its stdout in
235           para_gui's bottom window.
236         - para: Like display, but start "para_client <specified
237           command>" instead of "<specified command>".
238
239 ---------
240 AFS usage
241 ---------
242
243 Paraslash comes with a sophisticated audio file selector called afs.
244 In the example above, we only used the "dummy" mode of afs which
245 gets activated automatically if nothing else was specified. In this
246 section the various features of afs are described.
247
248 ----------
249 Attributes
250 ~~~~~~~~~~
251
252 An attribute is simply a bit which can be set for each audio
253 file individually.  Up to 64  different attributes may be
254 defined. For example, "pop", "rock", "blues", "jazz", "instrumental",
255 "german_lyrics", "speech" whatever. It's up to you how many attributes
256 you define and how you call them.
257
258 A new attribute "test" is created by
259
260         para_client addatt test
261
262 and
263         para_client lsatt
264
265 lists all available attributes. You can set the "test" attribute for
266 an audio file by executing
267
268         para_client setatt test+ /path/to/the/audio/file
269
270 Similarly, the "test" bit can be removed from a audio file with
271
272         para_client setatt test- /path/to/the/audio/file
273
274 Instead of a path you can also use a pattern, and the attribute is
275 applied to all audio files matching that pattern:
276
277         para_client setatt test+ '/test/directory/*'
278
279 The command
280
281         para_client -- ls -lv
282
283 gives you a verbose listing of your audio files which contains also
284 which attributes are set.
285
286 In case you wonder why the double-dash in the above command is needed:
287 It tells para_client to not interpret the options after the dashes. If
288 you find this annoying, just say
289
290         alias para='para_client --'
291
292 and be happy. In the remainder part this alias is being used.
293
294 Drop the test attribute entirely from the database with
295
296         para rmatt test
297
298 Read the output of
299
300         para help ls
301         para help setatt
302
303 for more information and a complete list of command line options to
304 these commands.
305
306
307 ----------------------
308 Abstract mood nonsense
309 ~~~~~~~~~~~~~~~~~~~~~~
310
311 [skip this part if you don't like formal definitions]
312
313 A mood consists of a unique name and its *mood definition*, which is a set of
314 *mood lines* containing expressions in terms of attributes and other data
315 contained in the database.
316
317 A mood defines a subset of audio files called the *admissible audio files*
318 for that mood. A mood can be *active* which means that para_server
319 is going to select only files from that subset of admissible files.
320
321 So in order to create a mood definition one has to write a set of
322 mood lines. Mood lines come in three flavours: Accept lines, deny
323 lines and score lines.
324
325 The general syntax of the three types of mood lines is
326
327
328         accept [with score <score>] [if] [not] <mood_method> [options]
329         deny [with score <score>] [if] [not] <mood_method> [options]
330         score <score>  [if] [not] <mood_method> [options]
331
332
333 Here <score> is either an integer or the string "random" which assigns
334 a random score to all matching files. The score value changes the
335 order in which admissible files are going to be selected, but is of
336 minor importance for this introduction.
337
338 So we concentrate on the first two forms, that is accept and deny
339 lines. As usual, everything in square brackets is optional, i.e.
340 accept/deny lines take the following form when ignoring scores:
341
342         accept [if] [not] <mood_method> [options]
343
344 and analogously for the deny case. The "if" keyword is purely cosmetic
345 and has no function. The "not" keyword just inverts the result, so
346 the essence of a mood line is the mood method part and the options
347 following thereafter.
348
349 A *mood method* is realized as function which takes an audio file
350 and computes a number from the data contained in the database.
351 If this number is non-negative, we say the file *matches* the mood
352 method. The file matches the full mood line if it either
353
354         - matches the mood method and the "not" keyword is not given,
355 or
356         - does not match the mood method, but the "not" keyword is given.
357
358 The set of admissible files for the whole mood is now defined as those
359 files which match at least one accept mood line, but no deny mood line.
360 More formally, a file is admissible if and only if
361
362         (F ~ AL1 or F ~ AL2...) and not (F ~ DL1 or F ~ DN2 ...)
363
364 where F is the file, AL1, AL2... are the accept lines, DL1, DL2... are
365 the deny lines and "~" means "matches".
366
367 The cases where no mood lines of accept/deny type are defined need
368 special treatment:
369
370         - Neither accept nor deny lines: This treats all files as admissible
371           (in fact, that is the definition of the dummy mood which is activated
372           automatically if no moods are available).
373
374         - Only accept lines: A file is admissible iff it matches at least one
375           accept line:
376
377                 F ~ AL1 or F ~ AL2 or ...
378
379         - Only deny lines: A file is admissible iff it matches no deny line:
380
381                 not (F ~ DL1 or F ~ DN2 ...)
382
383
384
385 --------------------
386 List of mood_methods
387 ~~~~~~~~~~~~~~~~~~~~
388
389         no_attributes_set()
390
391 Takes no arguments and matches an audio file if and only if no
392 attributes are set.
393
394         played_rarely()
395
396 Takes no arguments and matches all audio files where the number of
397 times this audio file was selected is below the average.
398
399         is_set(attribute_name)
400
401 Takes the name of an attribute and matches iff that attribute is set.
402
403         name_like(pattern)
404
405 Takes a filename pattern and matches iff the path of the audio file
406 matches the pattern.
407
408
409 ----------
410 Mood usage
411 ~~~~~~~~~~
412
413 To create a new mood called "my_mood", write its definition into
414 some temporary file, say "tmpfile", and add it to the mood table
415 by executing
416
417         para addmood my_mood < tmpfile
418
419 If the mood definition is really short, you may just pipe it to the
420 client instead of using temporary files. Like this:
421
422         echo "$MOOD_DEFINITION" | para addmood my_mood
423
424 There is no need to keep the temporary file since you can always use
425 the catmood command to get it back:
426
427         para catmood my_mood
428
429 A mood can be activated by executing
430
431         para chmood my_mood
432
433 Once active, the list of admissible files is shown by the ls command
434 if the "-a" switch is given:
435
436         para ls -a
437
438 -----------------------
439 Example mood definition
440 ~~~~~~~~~~~~~~~~~~~~~~~
441
442 Suppose you have defined attributes "punk" and "rock" and want to define
443 a mood containing only Punk-Rock songs. That is, an audio file should be
444 admissible if and only if both attributes are set. Since
445
446         punk and rock
447
448 is obviously the same as
449
450         not (not punk or not rock)
451
452 (de Morgan's rule), a mood definition that selects only Punk-Rock
453 songs is
454
455         deny if not is_set punk
456         deny if not is_set rock
457
458
459 ---------
460 Troubles?
461 ---------
462 If something went wrong, look at the output. If that does not give
463 you a clue, use loglevel one (option -l 1 for most commands) to show
464 debugging info. Almost all paraslash executables have a brief online
465 help which is displayed by using the -h switch.
466
467 Still not working? Mail the author Andre Noll <maan@systemlinux.org>
468 (english, german, or spanish language). Please provide enough info
469 such as the version of paraslash you are using and relevant parts of
470 the logs.