1 | # $Id$ |
---|
2 | |
---|
3 | PyKota - Print Quota for CUPS and LPRng |
---|
4 | |
---|
5 | (c) 2003-2004 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 2 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, write to the Free Software |
---|
18 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | ==================================================================== |
---|
21 | |
---|
22 | NOTE FOR LPRNG USERS : |
---|
23 | |
---|
24 | FROM MAY 21ST 2004 ON, AND UNTIL THIS NOTE IS REMOVED |
---|
25 | FROM THIS FILE, PYKOTA CAN'T BE USED ANYMORE WITH LPRNG. |
---|
26 | |
---|
27 | SUPPORT FOR LPRNG SHOULD BE RE-ADDED SOON WHEN A HUGE REWRITE |
---|
28 | OF SOME PARTS OF PYKOTA WILL HAVE TAKEN PLACE |
---|
29 | |
---|
30 | ==================================================================== |
---|
31 | |
---|
32 | READ SPECIAL LICENSING AND REDISTRIBUTION TERMS IN THE FILE 'LICENSE' |
---|
33 | |
---|
34 | ==================================================================== |
---|
35 | |
---|
36 | PyKota features : |
---|
37 | ----------------- |
---|
38 | |
---|
39 | Operating systems : |
---|
40 | |
---|
41 | - Any Unix-like system as print server. |
---|
42 | |
---|
43 | - Any operating system as client. |
---|
44 | |
---|
45 | Printing systems : |
---|
46 | |
---|
47 | - Supports both CUPS and LPRng as the printing system. |
---|
48 | |
---|
49 | Databases : |
---|
50 | |
---|
51 | - Supports PostgreSQL as the Quota Storage backend. |
---|
52 | Complete database creation script in SQL is included. |
---|
53 | |
---|
54 | - Supports OpenLDAP as the Quota Storage backend. |
---|
55 | Complete LDAP schema and sample empty tree are included. |
---|
56 | Plugging PyKota into your existing LDAP infrastructure |
---|
57 | is really easy thanks to PyKota's great configurability. |
---|
58 | |
---|
59 | Printers : |
---|
60 | |
---|
61 | - Hardware or Software accounting methods are completely |
---|
62 | configurable. |
---|
63 | |
---|
64 | - Supports any printer which can report its internal |
---|
65 | page counter. Can ask printers for their internal |
---|
66 | page counter via SNMP, Netatalk, or any other way. |
---|
67 | This is completely configurable. |
---|
68 | |
---|
69 | - Supports PostScript and PCL5 printers natively, |
---|
70 | more formats to come. |
---|
71 | |
---|
72 | - Supports any other printer via GhostScript. |
---|
73 | Depending on the printer some configuration may |
---|
74 | be needed. |
---|
75 | |
---|
76 | Quota systems : |
---|
77 | |
---|
78 | - Supports printers and printers groups quotas. |
---|
79 | |
---|
80 | - Supports users and users groups quotas. |
---|
81 | |
---|
82 | - Supports page quotas. |
---|
83 | Page quotas can be set differently on a per printer |
---|
84 | and per user/group basis. |
---|
85 | |
---|
86 | - Supports account balance quotas in any currency. |
---|
87 | Account balance quotas can be set on a per user |
---|
88 | basis. The account balance is shared amongst |
---|
89 | all printers. |
---|
90 | |
---|
91 | - Page quota and account balance can be set/reset |
---|
92 | independantly. |
---|
93 | |
---|
94 | - Limiting factor, page quota or account balance, |
---|
95 | can be set on a per user or per group basis. |
---|
96 | |
---|
97 | - Price per page and per job can be set differently |
---|
98 | on any printer. |
---|
99 | |
---|
100 | - Low level of page quota or account balance are |
---|
101 | configurable. |
---|
102 | |
---|
103 | - Both soft and hard limit with configurable grace delay |
---|
104 | can be set for page quota. |
---|
105 | |
---|
106 | - Possibility to disable quota enforcement for any user |
---|
107 | or group, while still keeping page accounting. |
---|
108 | |
---|
109 | Administration : |
---|
110 | |
---|
111 | - Powerful administration tools can be used to |
---|
112 | automate setting or resetting of quotas or |
---|
113 | account balances at specific intervals. |
---|
114 | |
---|
115 | - Administration tools can modify several users, |
---|
116 | groups, or printers at once. |
---|
117 | |
---|
118 | - Account balances can be set, incremented, or |
---|
119 | decremented. |
---|
120 | |
---|
121 | - Both printers and users can be automatically added on |
---|
122 | first print in a completely configurable way. |
---|
123 | |
---|
124 | - Quota report generator available either from the |
---|
125 | command line or in any web browser. |
---|
126 | The web-based quota report generator can be |
---|
127 | user/password protected. |
---|
128 | |
---|
129 | - Print quote generator can tell users how much |
---|
130 | a print job will cost them in advance. |
---|
131 | |
---|
132 | - Policy with regard to unregistered users can |
---|
133 | be configured for each printer to either deny |
---|
134 | printing, allow printing, or delegate the |
---|
135 | decision to any external tool. |
---|
136 | |
---|
137 | - Warning and error messages can be automatically |
---|
138 | sent via email to the administrator, the user, |
---|
139 | both, or none. |
---|
140 | |
---|
141 | - Warning and error messages' content is completely |
---|
142 | configurable. |
---|
143 | |
---|
144 | - Configuration can be changed without needing to |
---|
145 | restart the printing system. |
---|
146 | |
---|
147 | - Complete print job history is kept. This can be |
---|
148 | disabled if needed. |
---|
149 | |
---|
150 | - Automated low quota or balance remainder can be |
---|
151 | scheduled regularly or launched manually. |
---|
152 | |
---|
153 | User Interface : |
---|
154 | |
---|
155 | - All the command line tools accept the -h | --help |
---|
156 | command line option which prints all the available |
---|
157 | options and show usage examples. |
---|
158 | |
---|
159 | - Completely internationalized. Actually supports the |
---|
160 | English, French, Spanish, Portuguese, Brasilian, Swedish |
---|
161 | and Italian languages. More to come. |
---|
162 | |
---|
163 | ==================================================================== |
---|
164 | |
---|
165 | Planned features are described in the TODO file. |
---|
166 | |
---|
167 | Actually two (or an infinity of) page accounting methods are |
---|
168 | implemented : |
---|
169 | |
---|
170 | - The 'hardware' method consists in querying the printer (via SNMP |
---|
171 | or Netatalk or any other method of your choice) for its total pages |
---|
172 | counter. |
---|
173 | |
---|
174 | With CUPS, this is done both at the beginning and at the end of a |
---|
175 | print job. The counters difference is then immediately used to |
---|
176 | decrease the user's account balance or increase his quota usage. |
---|
177 | |
---|
178 | With LPRng, this is done just before the beginning of a job, and used |
---|
179 | this to modify the *preceding* user's quota. So you're always late |
---|
180 | of one print job, but this is generally ok. |
---|
181 | |
---|
182 | - The 'software' method consists in delegating the computation of the |
---|
183 | job's size in number of pages to any external command of your choice. |
---|
184 | The command can read the job's data from its standard input and MUST |
---|
185 | output the job's size on its standard output. Changes to the user |
---|
186 | account are reported immediately, both with CUPS and LPRng. |
---|
187 | |
---|
188 | PyKota is known to work fine with HP Laserjet 2100 and 2200, and |
---|
189 | Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under |
---|
190 | Debian GNU/Linux (Sarge and Sid) operating systems. It should work |
---|
191 | fine with most network printers. |
---|
192 | |
---|
193 | ============================================================ |
---|
194 | |
---|
195 | INSTALLATION: |
---|
196 | ============= |
---|
197 | |
---|
198 | NB : |
---|
199 | ==== |
---|
200 | |
---|
201 | You may learn more about PyKota, if it fits your own organization, |
---|
202 | its internal working, and some potential performance drawbacks and |
---|
203 | how to avoid them, in a WiKi administered by Ryan Suarez at : |
---|
204 | |
---|
205 | http://webcrossing.macosxlabs.org/webx?14@30.QAu3a5k0c4z.7@.26bf4661 |
---|
206 | |
---|
207 | Prerequisite : |
---|
208 | -------------- |
---|
209 | |
---|
210 | You need to have the following tools installed on the CUPS Server : |
---|
211 | |
---|
212 | - CUPS or LPRng |
---|
213 | - Python v2.1 or above |
---|
214 | - eGenix' mxDateTime Python extension |
---|
215 | - SNMP tools (specifically the snmpget command) if you plan to |
---|
216 | request your printer's lifetime page counter via SNMP. |
---|
217 | - Netatalk (specifically the pap command) if you plan to |
---|
218 | request your printer's lifetime page counter via AppleTalk. |
---|
219 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
220 | libraries if you plan to use PostgreSQL as the Quota Storage |
---|
221 | backend. |
---|
222 | or |
---|
223 | - python-ldap Python module and the OpenLDAP client libraries |
---|
224 | if you plan to use OpenLDAP as the Quota Storage backend. |
---|
225 | |
---|
226 | You may also benefit from having the following tools installed to |
---|
227 | deal with some printers : |
---|
228 | |
---|
229 | - npadmin |
---|
230 | - netcat |
---|
231 | - ghostscript |
---|
232 | |
---|
233 | You need to have the following tools installed on the Quota Storage |
---|
234 | Server : |
---|
235 | |
---|
236 | - PostgreSQL |
---|
237 | |
---|
238 | or |
---|
239 | |
---|
240 | - OpenLDAP |
---|
241 | |
---|
242 | NB : |
---|
243 | |
---|
244 | PygreSQL must be linked with the PostgreSQL client libraries on |
---|
245 | the Print Server. The PostgreSQL client libraries' version must |
---|
246 | match the PostgreSQL version used on the Quota Storage Server. |
---|
247 | BEWARE : under Debian Sarge, as of March 15th 2004, there's a |
---|
248 | problem with python2.2-pygresql and python-2.3-pygresql, so please |
---|
249 | install python2.1-pygresql and use Python 2.1 to install and run |
---|
250 | PyKota. This is not a bug in PyKota, and this should be fixed |
---|
251 | by Debian in a few days I hope. |
---|
252 | |
---|
253 | or |
---|
254 | |
---|
255 | python-ldap must be linked with the OpenLDAP client libraries on the |
---|
256 | Print Server. The OpenLDAP client libraries' version must match the |
---|
257 | OpenLDAP version used on the Quota Storage Server. |
---|
258 | |
---|
259 | This list of prerequisite software may change in the future, when |
---|
260 | PyKota will support more functionnalities you will be given |
---|
261 | alternatives. |
---|
262 | |
---|
263 | Of course the Print Server and the Quota Storage Server can be the |
---|
264 | very same machine if you've got a tiny network, or you can have |
---|
265 | multiple Print Servers all storing their quotas on the same Quota |
---|
266 | Storage Server if you've got a bigger network. |
---|
267 | |
---|
268 | Then : |
---|
269 | ------ |
---|
270 | |
---|
271 | Download the latest PyKota version from the CVS tree on : |
---|
272 | |
---|
273 | http://savannah.nongnu.org/projects/pykota |
---|
274 | |
---|
275 | Just type : |
---|
276 | |
---|
277 | python setup.py install |
---|
278 | |
---|
279 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
280 | |
---|
281 | The installation script will now automatically check if some software |
---|
282 | is missing and ask you if you still want to proceed with the |
---|
283 | installation or abort it completely. |
---|
284 | |
---|
285 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
286 | the appropriate storage backend for your configuration. Read |
---|
287 | the associated README file and execute the initialization script |
---|
288 | to create an empty PyKota Storage. Upgrade scripts may be |
---|
289 | provided as well. |
---|
290 | |
---|
291 | Copy the conf/pykota.conf.sample and conf/pykotadmin.conf.sample |
---|
292 | sample configuration files to /etc/pykota/pykota.conf and |
---|
293 | /etc/pykota/pykotadmin.conf. The installation script tries to do |
---|
294 | this for you if needed and you agreed to this action. You need to |
---|
295 | adapt these files to your own needs. Especially you have to create |
---|
296 | sections named after your own printers, and change the |
---|
297 | administrator's email address which by default is root@localhost. |
---|
298 | Read and try to understand these two very well commented files, |
---|
299 | so that you'll encounter less problems later. |
---|
300 | |
---|
301 | Also be sure to double check that commands that query printers |
---|
302 | for their internal page counter work from the command line |
---|
303 | before using them in PyKota's configuration. |
---|
304 | |
---|
305 | The rest of the installation depends on your printing system : |
---|
306 | |
---|
307 | - CUPS Printing System : |
---|
308 | |
---|
309 | Once and for all : |
---|
310 | |
---|
311 | Create a symbolic link to the cupspykota backend |
---|
312 | in CUPS's backend directory : |
---|
313 | |
---|
314 | $ cd /usr/lib/cups/backend |
---|
315 | $ ln -s /usr/share/pykota/cupspykota cupspykota |
---|
316 | |
---|
317 | Restart CUPS so that the new backend can be detected. |
---|
318 | |
---|
319 | $ /etc/init.d/cupsys restart |
---|
320 | |
---|
321 | For new printers : |
---|
322 | |
---|
323 | Go to CUPS management interface (http://localhost:631) |
---|
324 | and choose the appropriate PyKota managed device depending |
---|
325 | on the type of printer you use. For example, if your |
---|
326 | printer is waiting on : |
---|
327 | |
---|
328 | socket://myprinter.example.com:9100 |
---|
329 | |
---|
330 | Then choose : |
---|
331 | |
---|
332 | cupspykota:socket://myprinter.example.com:9100 |
---|
333 | |
---|
334 | Configure your printer as usual. |
---|
335 | |
---|
336 | Now double check /etc/pykota/pykota.conf |
---|
337 | This file should contain a section named after the |
---|
338 | printer you've just added, unless you have set |
---|
339 | all options globally. |
---|
340 | The new pkhint command can help you with correct settings |
---|
341 | for your printers, but don't rely on it because it is still |
---|
342 | incomplete. |
---|
343 | |
---|
344 | That's all. |
---|
345 | |
---|
346 | For existing printers : |
---|
347 | |
---|
348 | If you had already installed a version of PyKota earlier |
---|
349 | than 1.16alpha7, then remove the *cupsFilter lines in your |
---|
350 | PPD files for each printer already managed printers. Each |
---|
351 | line to remove is of the form : |
---|
352 | |
---|
353 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/share/pykota/pykota" |
---|
354 | |
---|
355 | This means that each time the pstops filter will be executed, it will |
---|
356 | pass the job's data through the pykota filter which is present in |
---|
357 | /usr/share/pykota |
---|
358 | |
---|
359 | Don't touch anything else, especially any other *cupsFilter line. |
---|
360 | Then save each of these files. |
---|
361 | |
---|
362 | Then, the easiest is to directly modify the DeviceURI lines |
---|
363 | in /etc/cups/printers.conf, you just have to put |
---|
364 | 'cupspykota:' in front of what is already on these lines. |
---|
365 | For example, replace : |
---|
366 | |
---|
367 | DeviceURI socket://myprinter.example.com:9100 |
---|
368 | |
---|
369 | with : |
---|
370 | |
---|
371 | DeviceURI cupspykota:socket://myprinter.example.com:9100 |
---|
372 | |
---|
373 | or : |
---|
374 | |
---|
375 | DeviceURI cupspykota://socket://myprinter.example.com:9100 |
---|
376 | |
---|
377 | Save the file and restart CUPS. |
---|
378 | |
---|
379 | - LPRng Printing System : |
---|
380 | |
---|
381 | For now LPRng support in PyKota is deactivated. Please be patient. |
---|
382 | |
---|
383 | Now you can begin to populate the PyKota's database with printers, |
---|
384 | users and groups : |
---|
385 | |
---|
386 | Add printers and users to the quota system and set their quota values : |
---|
387 | |
---|
388 | Starting from version 1.18alpha2, the preferred command to manage |
---|
389 | printers is named pkprinters |
---|
390 | |
---|
391 | $ pkprinters --help |
---|
392 | |
---|
393 | will tell you how to create, manage or delete printers and |
---|
394 | printers groups. |
---|
395 | |
---|
396 | $ pkprinters --add --charge 0.05 hp2100 |
---|
397 | |
---|
398 | would add the printer named hp2100 with a price per page |
---|
399 | of 0.05 unit. |
---|
400 | |
---|
401 | Now set quotas for users on this printer : |
---|
402 | |
---|
403 | $ edpykota --add -P hp2100 -S 40 -H 50 user1 ... userN |
---|
404 | |
---|
405 | launching edpykota without any argument or with the --help |
---|
406 | command line option will show you all the possibilities. |
---|
407 | |
---|
408 | by default, each user is limited by "quota", this means that on |
---|
409 | each printer he can have a different soft and hard limit. |
---|
410 | You may want to limit the user by his account balance value, |
---|
411 | in which case, the print quota is shared between all printers |
---|
412 | instead of being different. To do this, use the following : |
---|
413 | |
---|
414 | $ edpykota --add -P hp2100 --limitby balance --balance 10 user1 ... userN |
---|
415 | |
---|
416 | This will put 10 $ (or Euros, PyKota doesn't care) on each user's account |
---|
417 | balance, and tell PyKota to limit them by their account balance value. |
---|
418 | Whenever they print on any printer, their account balance value is |
---|
419 | decreased by an amount which depends on the particular price per page |
---|
420 | and per job that you may have defined on the printer with edpykota's |
---|
421 | --charge command line option. |
---|
422 | Soft and Hard limits are not used if "--limitby balance" is used, |
---|
423 | but you can define a "poorman"'s threshold in /etc/pykota/pykota.conf |
---|
424 | to obtain a similar result (warning message when quota is low). |
---|
425 | |
---|
426 | Restart CUPS or LPRng, for example under Debian GNU/Linux systems : |
---|
427 | |
---|
428 | $ /etc/init.d/cupsys restart |
---|
429 | |
---|
430 | or : |
---|
431 | |
---|
432 | $ /etc/init.d/lprng restart |
---|
433 | |
---|
434 | Your users now should be able to print but not exceed their |
---|
435 | printing quota. |
---|
436 | |
---|
437 | To see printer quota usage, you can use : |
---|
438 | |
---|
439 | $ repykota --printer lp |
---|
440 | |
---|
441 | or : |
---|
442 | |
---|
443 | $ repykota |
---|
444 | |
---|
445 | which will print quota usage for all users on all printers, |
---|
446 | along with totals, if you are the root user. If you are |
---|
447 | a regular user, only your own quota report will be produced. |
---|
448 | |
---|
449 | Quota reports are also available remotely by using the CGI script |
---|
450 | printquota.cgi provided in the cgi-bin/ subdirectory. You can |
---|
451 | also use the CSS stylesheet present in the stylesheets/ subdirectory |
---|
452 | and put it at your web server's DocumentRoot, to benefit from a nicer |
---|
453 | look, especially quota violations will appear in different colors. |
---|
454 | |
---|
455 | For different security concerns, please give a look at the SECURITY |
---|
456 | file which is part of this software. |
---|
457 | |
---|
458 | ============================================================ |
---|
459 | |
---|
460 | Mailing list : |
---|
461 | -------------- |
---|
462 | |
---|
463 | A mailing list is dedicated to Pykota, you can subscribe to it |
---|
464 | or consult its archives at : |
---|
465 | |
---|
466 | http://cgi.librelogiciel.com/mailman/listinfo/pykota |
---|
467 | |
---|
468 | IRC : |
---|
469 | ----- |
---|
470 | |
---|
471 | You can also chat with us : |
---|
472 | |
---|
473 | /server irc.freenode.net |
---|
474 | /join #pykota |
---|
475 | |
---|
476 | ============================================================ |
---|
477 | |
---|
478 | Please e-mail bugs to the mailing list at : pykota@librelogiciel.com |
---|
479 | or to the main author at : alet@librelogiciel.com (Jerome Alet) |
---|