1 | # $Id$ |
---|
2 | |
---|
3 | PyKota - Print Quotas for CUPS |
---|
4 | |
---|
5 | (c) 2003-2013 Jerome Alet <alet@librelogiciel.com> |
---|
6 | This program is free software: you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation, either version 3 of the License, or |
---|
9 | (at your option) any later version. |
---|
10 | |
---|
11 | This program is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | GNU General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU General Public License |
---|
17 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
18 | |
---|
19 | ==================================================================== |
---|
20 | |
---|
21 | READ SPECIAL LICENSING AND REDISTRIBUTION TERMS IN THE FILE 'LICENSE' |
---|
22 | |
---|
23 | ==================================================================== |
---|
24 | |
---|
25 | PyKota features : |
---|
26 | ----------------- |
---|
27 | |
---|
28 | http://www.pykota.com/software/pykota/features/ |
---|
29 | |
---|
30 | ==================================================================== |
---|
31 | |
---|
32 | Planned features are described in the TODO file. |
---|
33 | |
---|
34 | Actually three (or an infinity of) page accounting methods are |
---|
35 | implemented : |
---|
36 | |
---|
37 | - The 'hardware' method consists in querying the printer (via SNMP |
---|
38 | or Netatalk or any other method of your choice) for its internal |
---|
39 | pages counter. |
---|
40 | This is done both at the beginning and at the end of a |
---|
41 | print job. The counters difference is then used to |
---|
42 | decrease the user's account balance or increase his quota usage. |
---|
43 | |
---|
44 | - The 'software' method consists in delegating the computation of the |
---|
45 | job's size in number of pages to any external command of your choice. |
---|
46 | The command can read the job's data from its standard input and MUST |
---|
47 | output the job's size on its standard output. Changes to the user |
---|
48 | account are reported immediately. PyKota by default internally |
---|
49 | uses the code from pkpgcounter which can handle a large number |
---|
50 | of Page Description Languages, and can parse documents produced |
---|
51 | either by GhostScript or by a number of native printer drivers. |
---|
52 | Of course this means you have to install pkpgcounter if you want to |
---|
53 | use the default PDL parser. |
---|
54 | An up-to-date list of supported Page Description Languages and their |
---|
55 | level of support is available from : |
---|
56 | |
---|
57 | http://www.pykota.com/software/pkpgcounter/ |
---|
58 | |
---|
59 | - The 'ink' method consists in using pkpgcounter's code to compute |
---|
60 | how much of each page is covered by ink in each color of a particular |
---|
61 | colorspace chosen between CMYK, CMY, RGB, and BW (grayscale). |
---|
62 | These values are then summed up together and multiplied by a set |
---|
63 | of coefficients defined in PyKota's configuration files. |
---|
64 | |
---|
65 | PyKota is known to work with most printers, excepted GDI ones (Windows |
---|
66 | only). At least one of the accounting methods above should work |
---|
67 | for you. If it's not the case, please report the problem : tell us |
---|
68 | the exact brand and model of the printer, if possible the driver used, |
---|
69 | and send some test files. |
---|
70 | |
---|
71 | ============================================================ |
---|
72 | |
---|
73 | SUPPORT CONTRACTS: |
---|
74 | ================== |
---|
75 | |
---|
76 | You can now purchase 8x5x365@NextBusinessDay Technical |
---|
77 | Support Contracts from us. The yearly fee is computed with |
---|
78 | the following formula : |
---|
79 | |
---|
80 | (100.0 * NbPrintServers) + (2.5 * NbPrinters) + (0.04 * NbUsers) EUROS. |
---|
81 | |
---|
82 | This fee includes the VAT, and a free subscription to Official |
---|
83 | PyKota packages. |
---|
84 | |
---|
85 | Please send an email to alet@librelogiciel.com if you're |
---|
86 | interested in purchasing such a contract. |
---|
87 | |
---|
88 | Remember that purchasing a support contract for Free Software like PyKota |
---|
89 | is a great way to show your appreciation for the work already being done |
---|
90 | on this project, and will help to improve this software in the future. |
---|
91 | |
---|
92 | ============================================================ |
---|
93 | |
---|
94 | INSTALLATION: |
---|
95 | ============= |
---|
96 | |
---|
97 | NB : |
---|
98 | ==== |
---|
99 | |
---|
100 | PyKota's documentation is available as DocBook SGML sources |
---|
101 | files in the pykota/docs directory. If you obtained an |
---|
102 | Official package, in the same directory you'll also find |
---|
103 | the documentation in HTML and PDF formats. Otherwise you |
---|
104 | have to compile it into HTML or PDF yourself by using |
---|
105 | the appropriate tools as installed on your system. |
---|
106 | |
---|
107 | PyKota's collaborative documentation is available from : |
---|
108 | |
---|
109 | http://www.pykota.com/wiki/ |
---|
110 | |
---|
111 | You may learn more about PyKota, if it fits your own organization, |
---|
112 | its internal working, and some potential performance drawbacks and |
---|
113 | how to avoid them, in a document created by Ryan Suarez at : |
---|
114 | |
---|
115 | http://archive.macosxlabs.org/forum/webcrossing_archive/documentation/Pykota_and_CUPS/Pykota_and_CUPS.html |
---|
116 | |
---|
117 | You may also find the following document interesting : |
---|
118 | |
---|
119 | http://es.tldp.org/Tutoriales/doc-openldap-samba-cups-python/ |
---|
120 | |
---|
121 | This document, written in Spanish by Sergio Gonzalez Gonzalez, |
---|
122 | describes the integration of PyKota into an OpenLDAP + Samba |
---|
123 | + CUPS installation. Even for people who can't read spanish |
---|
124 | this document is really interesting, and contains lots of |
---|
125 | screenshots. |
---|
126 | |
---|
127 | |
---|
128 | Prerequisite : |
---|
129 | -------------- |
---|
130 | |
---|
131 | See : |
---|
132 | |
---|
133 | http://www.pykota.com/wiki/Dependencies |
---|
134 | |
---|
135 | for an up-to-date list, or see below (maybe not up-to-date) : |
---|
136 | |
---|
137 | You need to have the following tools installed on the CUPS Server : |
---|
138 | |
---|
139 | - CUPS (http://www.cups.org). PyKota v1.27 requires CUPS v1.3.4 or higher. |
---|
140 | - Python v2.4 or higher (http://www.python.org) |
---|
141 | - eGenix' mxDateTime Python extension (http://www.egenix.com) |
---|
142 | - The pkpgcounter command line tool, version 1.56 or higher. This |
---|
143 | tool is now mandatory for PyKota to work. |
---|
144 | (http://www.pykota.com/software/pkpgcounter) |
---|
145 | - The pkipplib Python library (http://www.pykota.com/software/pkipplib) |
---|
146 | - The JAXML Python module to be able to dump datas in the XML format. |
---|
147 | (http://www.librelogiciel.com/software/) |
---|
148 | - The Python-PAM module if you need the pknotify command to be able |
---|
149 | to check usernames and passwords. (http://www.pangalactic.org/PyPAM) |
---|
150 | - The Python-SNMP module to query printers for their page counter. |
---|
151 | (http://pysnmp.sourceforge.net) |
---|
152 | IMPORTANT : version v4.x is now REQUIRED. |
---|
153 | Versions 3.x or earlier are not supported anymore. |
---|
154 | - The Python-OSD module to use the graphical print quota reminder. |
---|
155 | (http://repose.cx/pyosd/) |
---|
156 | - SNMP tools (specifically the snmpget command) if you prefer to |
---|
157 | use your own script to request query printers instead of PyKota's |
---|
158 | internal SNMP handling facilities, which is not recommended... |
---|
159 | (http://www.net-snmp.org). You probably don't need this. |
---|
160 | - Netatalk (specifically the pap command) if you plan to |
---|
161 | request your printer's lifetime page counter via AppleTalk. |
---|
162 | (http://netatalk.sourceforge.net). You probably don't need this. |
---|
163 | - The ReportLab Python module (http://www.reportlab.org) if you want |
---|
164 | to have PyKota generate nice banners, invoices or receipts in PDF for you. |
---|
165 | - The Python Imaging Library (aka PIL) module |
---|
166 | (http://www.pythonware.com/downloads) if you want to have PyKota |
---|
167 | generate nice banners, invoices or receipts in PDF for you. |
---|
168 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
169 | libraries if you plan to use PostgreSQL as the database backend. |
---|
170 | (http://www.postgresql.org and http://www.pygreql.org) |
---|
171 | or |
---|
172 | - python-ldap Python module and the OpenLDAP client libraries |
---|
173 | if you plan to use an LDAP server as the database backend. |
---|
174 | (http://www.openldap.org and http://python-ldap.sourceforge.net) |
---|
175 | or |
---|
176 | - SQLite v3.2.7 and the SQLite libraries if you plan to use SQLite |
---|
177 | as the database backend (http://www.sqlite.org). You also need the |
---|
178 | PySQLite module v2.0.5 or higher (http://www.pysqlite.org) |
---|
179 | or |
---|
180 | - The MySQL-python bindings. |
---|
181 | IMPORTANT: If you are using MySQL 4.1, then MySQL-python must be |
---|
182 | version 1.2 or greater. Version 1.0 does not work correctly with 4.1. |
---|
183 | |
---|
184 | |
---|
185 | You need to have the following tools installed on the database |
---|
186 | server : |
---|
187 | |
---|
188 | - PostgreSQL (http://www.postgresql.org) |
---|
189 | |
---|
190 | or |
---|
191 | |
---|
192 | - OpenLDAP, or any other LDAP server (http://www.openldap.org) |
---|
193 | |
---|
194 | or |
---|
195 | |
---|
196 | - SQLite, v3.2.7 or higher (http://www.sqlite.org). |
---|
197 | Beware : with SQLite the database server and the print |
---|
198 | servers MUST be the very same machine. |
---|
199 | |
---|
200 | or |
---|
201 | |
---|
202 | - MySQL 4.1 or higher. 5.x is recommended. |
---|
203 | |
---|
204 | This list of prerequisite software may change in the future, when |
---|
205 | PyKota will support more functionnalities you will be given |
---|
206 | alternatives. |
---|
207 | |
---|
208 | Of course the Print Server and the database server can be the |
---|
209 | very same machine if you've got a tiny network, or you can have |
---|
210 | multiple Print Servers all storing their quotas on the same database |
---|
211 | server if you've got a bigger network. (NB : with SQLite, the database |
---|
212 | can't be shared between several print servers) |
---|
213 | |
---|
214 | Hint : |
---|
215 | ------ |
---|
216 | |
---|
217 | - The Debian GNU/Linux distribution is to our knowledge the |
---|
218 | easiest distribution to install PyKota on, because almost all |
---|
219 | of PyKota dependencies are already included. |
---|
220 | We recommend you to use Debian's Etch distribution or |
---|
221 | more recent. PyKota works fine on Sarge, but some additional |
---|
222 | dependencies are missing in Sarge and have to be installed |
---|
223 | manually. |
---|
224 | |
---|
225 | Then : |
---|
226 | ------ |
---|
227 | |
---|
228 | Download the latest PyKota version from the Subversion tree : |
---|
229 | |
---|
230 | $ svn co http://svn.pykota.com/pykota/trunk pykota |
---|
231 | |
---|
232 | You can now check if the dependencies are correct by typing : |
---|
233 | |
---|
234 | $ python checkdeps.py |
---|
235 | |
---|
236 | An availability report for all the software needed by PyKota |
---|
237 | will be displayed : you'll have to install the missing |
---|
238 | software if you want PyKota to work correctly. |
---|
239 | |
---|
240 | To install the software, just type : |
---|
241 | |
---|
242 | $ python setup.py install |
---|
243 | |
---|
244 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
245 | |
---|
246 | If you use Debian or Ubuntu, and want to use PostgreSQL as the |
---|
247 | database backend, just type : |
---|
248 | |
---|
249 | $ pksetup debian |
---|
250 | |
---|
251 | or : |
---|
252 | |
---|
253 | $ pksetup ubuntu |
---|
254 | |
---|
255 | and follow the instructions to install PyKota in interactive mode, then |
---|
256 | skip the remaining of the section below. |
---|
257 | |
---|
258 | Otherwise, you have to setup manually : |
---|
259 | |
---|
260 | Create a system user for PyKota : |
---|
261 | |
---|
262 | $ adduser --system --group --home /etc/pykota --gecos PyKota pykota |
---|
263 | |
---|
264 | Put the user your printing system is run as in the pykota system group : |
---|
265 | |
---|
266 | $ adduser lp pykota |
---|
267 | |
---|
268 | NB : on our system, the CUPS printing system runs as system user 'lp'. |
---|
269 | Please adapt this to your own system. |
---|
270 | |
---|
271 | Go to the initscripts/ subdirectory of PyKota's sources, and choose |
---|
272 | the appropriate storage backend for your configuration. Read carefully |
---|
273 | the associated README file, modify the initialization script to |
---|
274 | change the passwords, or, in the case of the LDAP backend, adapt it |
---|
275 | to your own LDAP DIT, and execute the initialization script |
---|
276 | to create an empty PyKota database. Upgrade scripts may be |
---|
277 | provided as well. NB : if you use PostgreSQL, a good way to |
---|
278 | make PyKota work first time is to modify PostgreSQL's pg_hba.conf |
---|
279 | to allow the 'trust' database connection mode. However once PyKota |
---|
280 | works it is HIGHLY RECOMMENDED TO CHANGE THIS TO A MORE SECURE |
---|
281 | VALUE. Look at the SECURITY document, PyKota's Official documentation |
---|
282 | and PostgreSQL's documentation for details on this subject. |
---|
283 | |
---|
284 | Copy the conf/pykota.conf.sample and conf/pykotadmin.conf.sample |
---|
285 | sample configuration files to ~pykota/pykota.conf and |
---|
286 | ~pykota/pykotadmin.conf |
---|
287 | The installation script usually copies these files into /usr/share/pykota |
---|
288 | |
---|
289 | NB : You can move PyKota's configuration files elsewhere, they will |
---|
290 | be searched first in user pykota's home directory, then in /etc/pykota. |
---|
291 | |
---|
292 | You need to adapt these files to your own needs. Especially you may |
---|
293 | have to create sections named after your own printers, and change |
---|
294 | the administrator's email address which by default is |
---|
295 | root@localhost. Read and try to understand these two very well |
---|
296 | commented files, so that you'll encounter less problems later. |
---|
297 | |
---|
298 | The rest of the installation depends on your printing system : |
---|
299 | |
---|
300 | - CUPS Printing System : |
---|
301 | |
---|
302 | Once and for all : |
---|
303 | |
---|
304 | Modify CUPS' cupsd.conf to make CUPS listen to 127.0.0.1:631 |
---|
305 | INSTEAD OF to an unix domain socket, in addition to any |
---|
306 | external network interface CUPS might already be listening to. |
---|
307 | |
---|
308 | Create a symbolic link to the cupspykota backend |
---|
309 | in CUPS's backend directory : |
---|
310 | |
---|
311 | $ cd /usr/lib/cups/backend |
---|
312 | $ ln -s /usr/share/pykota/cupspykota cupspykota |
---|
313 | |
---|
314 | If you use CUPS v1.2 or higher, please do this as well : |
---|
315 | |
---|
316 | $ chmod 700 /usr/share/pykota/cupspykota |
---|
317 | |
---|
318 | This allows the cupspykota backend to support other |
---|
319 | backends which must be run as user root, like the |
---|
320 | lpd backend for example. |
---|
321 | |
---|
322 | Restart CUPS so that the new backend can be detected. |
---|
323 | |
---|
324 | $ /etc/init.d/cupsys restart |
---|
325 | |
---|
326 | for example under Debian, or any similar command depending |
---|
327 | on your operating system of choice. |
---|
328 | |
---|
329 | For new printers : |
---|
330 | |
---|
331 | Go to CUPS management interface (http://localhost:631) |
---|
332 | and choose the appropriate PyKota managed device depending |
---|
333 | on the type of printer you use. For example, if your |
---|
334 | printer is waiting on : |
---|
335 | |
---|
336 | socket://myprinter.example.com:9100 |
---|
337 | |
---|
338 | Then choose : |
---|
339 | |
---|
340 | cupspykota:socket://myprinter.example.com:9100 |
---|
341 | |
---|
342 | Configure your printer as usual. |
---|
343 | |
---|
344 | Now double check /etc/pykota/pykota.conf |
---|
345 | |
---|
346 | You should manually create a section named after the |
---|
347 | printer you've just added, unless you have set |
---|
348 | all options globally. |
---|
349 | |
---|
350 | The new pkturnkey command can help you with correct settings |
---|
351 | for your printers. To have pkturnkey give you some hints |
---|
352 | about what to put into pykota.conf for a particular |
---|
353 | print queue, just use its --doconf command line switch : |
---|
354 | |
---|
355 | $ pkturnkey --doconf TheNameOfThePrintQueue |
---|
356 | |
---|
357 | pkturnkey will try to tell you what is the best accounting |
---|
358 | method for each printer and will print some lines you'll |
---|
359 | just have to copy&paste in the appropriate sections in |
---|
360 | /etc/pykota/pykota.conf |
---|
361 | |
---|
362 | For more informations about what pkturnkey can do for you, |
---|
363 | see pkturnkey's manual page or use the --help command |
---|
364 | line switch : |
---|
365 | |
---|
366 | $ pkturnkey --help | less |
---|
367 | |
---|
368 | That's all. |
---|
369 | |
---|
370 | For existing print queues : |
---|
371 | |
---|
372 | You want to route the print queue through PyKota, |
---|
373 | and you can do this in several manners. |
---|
374 | |
---|
375 | $ pkprinters --add --cups TheNameOfThePrintQueue |
---|
376 | |
---|
377 | or |
---|
378 | |
---|
379 | if your printer's DeviceURI is something like : |
---|
380 | |
---|
381 | socket://myprinter.example.com:9100 |
---|
382 | |
---|
383 | then you can do this : |
---|
384 | |
---|
385 | $ pkprinters --add TheNameOfThePrintQueue |
---|
386 | $ lpadmin -p TheNameOfThePrintQueue \ |
---|
387 | -v cupspykota://socket://myprinter.example.com:9100 |
---|
388 | |
---|
389 | Finally, you could do it manually by modifying the |
---|
390 | the DeviceURI lines in /etc/cups/printers.conf : |
---|
391 | You would have to preprend 'cupspykota://' in front |
---|
392 | of what is already on these lines. For example, replace : |
---|
393 | |
---|
394 | DeviceURI socket://myprinter.example.com:9100 |
---|
395 | |
---|
396 | with : |
---|
397 | |
---|
398 | DeviceURI cupspykota://socket://myprinter.example.com:9100 |
---|
399 | |
---|
400 | or : |
---|
401 | |
---|
402 | DeviceURI cupspykota://socket://myprinter.example.com:9100 |
---|
403 | |
---|
404 | Save the file and restart CUPS for the changes to take effect. |
---|
405 | |
---|
406 | Here too, you may find it interesting to use the pkturnkey command as |
---|
407 | described above to help with manual configuration of the file |
---|
408 | /etc/pykota/pykota.conf |
---|
409 | |
---|
410 | Now you can begin to populate the PyKota's database with printers, |
---|
411 | users and groups : |
---|
412 | |
---|
413 | Add printers and users to the quota system and set their quota values : |
---|
414 | |
---|
415 | You can either use pkturnkey, or do the same things manually by |
---|
416 | using the pkprinters, pkusers and edpykota command line tools : |
---|
417 | |
---|
418 | Create printers : |
---|
419 | |
---|
420 | $ pkprinters --help |
---|
421 | |
---|
422 | will tell you how to create, manage or delete printers and |
---|
423 | printers groups. |
---|
424 | |
---|
425 | $ pkprinters --add --charge 0.05 hp2100 |
---|
426 | |
---|
427 | would add the printer named hp2100 with a price per page |
---|
428 | of 0.05 unit. |
---|
429 | |
---|
430 | Create users : |
---|
431 | |
---|
432 | $ pkusers --add --limitby balance --balance 10.0 jerome |
---|
433 | |
---|
434 | would create user jerome and give him ten credits to spend |
---|
435 | on any printer. |
---|
436 | |
---|
437 | Finally create print quota entries : |
---|
438 | |
---|
439 | $ edpykota --add --printer hp2100 john paul george ringo |
---|
440 | |
---|
441 | This will create print quota entries for The Beatles on |
---|
442 | printer hp2100. The print quota entry holds the number of |
---|
443 | pages printed on a particular printer for a particular |
---|
444 | user, as well as optional page limits to be used instead |
---|
445 | of balance limits. See pkusers and edpykota's manual |
---|
446 | pages for details. |
---|
447 | |
---|
448 | Your users now should be able to print but not exceed their |
---|
449 | printing quota. |
---|
450 | |
---|
451 | To see printer quota usage on printer hp2100, you can use : |
---|
452 | |
---|
453 | $ repykota --printer hp2100 |
---|
454 | |
---|
455 | or : |
---|
456 | |
---|
457 | $ repykota |
---|
458 | |
---|
459 | which will print quota usage for all users on all printers, |
---|
460 | along with totals, if you are a PyKota Administator. If you are |
---|
461 | a regular user, only your own quota report will be produced. |
---|
462 | |
---|
463 | You can also use these commands : |
---|
464 | |
---|
465 | $ pkusers --list |
---|
466 | $ edpykota --list |
---|
467 | |
---|
468 | $ pkusers --list john paul george ringo |
---|
469 | $ edpykota --list --printer hp2100 john paul george ringo |
---|
470 | |
---|
471 | Quota reports are also available remotely by using the CGI script |
---|
472 | printquota.cgi provided in the cgi-bin/ subdirectory. You can |
---|
473 | also use the CSS stylesheet present in the stylesheets/ subdirectory |
---|
474 | and put it at your web server's DocumentRoot, to benefit from a nicer |
---|
475 | look, especially quota violations will appear in different colors. |
---|
476 | |
---|
477 | For additionnal security concerns, please give a look at the SECURITY |
---|
478 | file which is part of this software. |
---|
479 | |
---|
480 | To diagnose a problem when something doesn't work as expected, |
---|
481 | please read this FAQ entry : |
---|
482 | |
---|
483 | http://otrs.librelogiciel.com/otrs/public.pl?ID=2 |
---|
484 | |
---|
485 | ============================================================ |
---|
486 | |
---|
487 | Mailing lists : |
---|
488 | --------------- |
---|
489 | |
---|
490 | A mailing list is dedicated to PyKota, you can subscribe to it |
---|
491 | or consult its archives at : |
---|
492 | |
---|
493 | http://lists.pykota.com/mailman/listinfo/pykota |
---|
494 | |
---|
495 | This mailing list is the preferred way to obtain support, because |
---|
496 | all members can help and can also benefit from the solutions |
---|
497 | proposed by other members. |
---|
498 | |
---|
499 | Another mailing list, dedicated to developers, is available from : |
---|
500 | |
---|
501 | http://lists.pykota.com/mailman/listinfo/pykota-devel |
---|
502 | |
---|
503 | In this mailing list you can discuss implementation details, bugs, |
---|
504 | ideas, and so on. All commit messages are also sent to this list. |
---|
505 | |
---|
506 | Posts by non-members are rejected. |
---|
507 | |
---|
508 | The mailing lists language is english and only english. |
---|
509 | |
---|
510 | IRC : |
---|
511 | ----- |
---|
512 | |
---|
513 | You can also chat with us : |
---|
514 | |
---|
515 | /server irc.freenode.net |
---|
516 | /join #pykota |
---|
517 | |
---|
518 | Preferred language on this channel is english, but french |
---|
519 | is also accepted. Try to avoid exposing complex problems |
---|
520 | in french because english speaking people on the channel |
---|
521 | wouldn't benefit from the solutions. |
---|
522 | |
---|
523 | PyKota's main author is known as 'tamere' on IRC. |
---|
524 | |
---|
525 | Bug Tracker : |
---|
526 | ------------- |
---|
527 | |
---|
528 | You can report bugs to our bug tracker on the development website |
---|
529 | at : |
---|
530 | |
---|
531 | http://trac.pykota.com |
---|