1 | # $Id$ |
---|
2 | |
---|
3 | PyKota - Print Quota for CUPS and LPRng |
---|
4 | |
---|
5 | (c) 2003 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 | READ SPECIAL LICENSING AND REDISTRIBUTION TERMS IN THE FILE 'LICENSE' |
---|
23 | |
---|
24 | ==================================================================== |
---|
25 | |
---|
26 | PyKota features : |
---|
27 | ----------------- |
---|
28 | |
---|
29 | Operating systems : |
---|
30 | |
---|
31 | - Any Unix-like system as print server. |
---|
32 | |
---|
33 | - Any operating system as client. |
---|
34 | |
---|
35 | Printing systems : |
---|
36 | |
---|
37 | - Supports CUPS as the printing system. |
---|
38 | |
---|
39 | - Supports LPRng as the printing system. |
---|
40 | |
---|
41 | Databases : |
---|
42 | |
---|
43 | - Supports PostgreSQL as the Quota Storage backend. |
---|
44 | Complete database creation SQL script is included. |
---|
45 | |
---|
46 | - Supports OpenLDAP as the Quota Storage backend. |
---|
47 | Complete LDAP schema and sample tree are included. |
---|
48 | Plugging PyKota into your existing LDAP infrastructure |
---|
49 | is really easy thanks to PyKota's great configurability. |
---|
50 | |
---|
51 | Printers : |
---|
52 | |
---|
53 | - Supports any printer which can report its internal |
---|
54 | page counter. |
---|
55 | |
---|
56 | - Supports any other printer via GhostScript. |
---|
57 | Depending on the printer some configuration may |
---|
58 | be needed. |
---|
59 | |
---|
60 | - Can ask printers for their internal page counter |
---|
61 | via SNMP, Netatalk, or any other mean of your |
---|
62 | choice. This is completely configurable. |
---|
63 | |
---|
64 | - External accounting methods are configurable. |
---|
65 | |
---|
66 | Quota systems : |
---|
67 | |
---|
68 | - Supports user and groups quotas. |
---|
69 | |
---|
70 | - Supports page quotas. |
---|
71 | Page quotas can be set differently on a per printer |
---|
72 | and per user/group basis. |
---|
73 | |
---|
74 | - Supports account balance quotas in any currency. |
---|
75 | Account balance quotas can be set on a per user |
---|
76 | basis. The account balance is shared amongst |
---|
77 | all printers. |
---|
78 | |
---|
79 | - Experimental support for printer groups, so that |
---|
80 | you can share quota between printers of the same |
---|
81 | type but in different locations. |
---|
82 | |
---|
83 | - Page quota and account balance can be set/reset |
---|
84 | independantly. |
---|
85 | |
---|
86 | - Limiting factor, page quota or account balance, |
---|
87 | can be set on a per user or per group basis. |
---|
88 | |
---|
89 | - Price per page and per job can be set differently |
---|
90 | on any printer. |
---|
91 | |
---|
92 | - Low level of page quota or account balance are |
---|
93 | configurable. |
---|
94 | |
---|
95 | - Both soft and hard limit with configurable grace delay |
---|
96 | can be set for page quota. |
---|
97 | |
---|
98 | - Possibility to disable quota enforcement for any user |
---|
99 | or group, while still keeping page accounting. |
---|
100 | |
---|
101 | Administration : |
---|
102 | |
---|
103 | - Powerful administration tools can be used to |
---|
104 | automate setting or resetting of quotas or |
---|
105 | account balances at specific intervals. |
---|
106 | |
---|
107 | - Administration tools can modify several users, |
---|
108 | groups, or printers at once. |
---|
109 | |
---|
110 | - Account balances can be set, incremented, or |
---|
111 | decremented. |
---|
112 | |
---|
113 | - Users can be automatically added on first print |
---|
114 | in a completely configurable way. |
---|
115 | |
---|
116 | - Quota report generator available either from the |
---|
117 | command line or in any web browser. |
---|
118 | The web-based quota report generator can be |
---|
119 | user/password protected. |
---|
120 | |
---|
121 | - Print quote generator can tell users how much |
---|
122 | a print job will cost them in advance. |
---|
123 | |
---|
124 | - Policy with regard to unregistered users can |
---|
125 | be configured for each printer to either deny |
---|
126 | printing, allow printing, or delegate the |
---|
127 | decision to any external tool. |
---|
128 | |
---|
129 | - Warning and error messages can be automatically |
---|
130 | sent via email to the administrator, the user, |
---|
131 | both, or none. |
---|
132 | |
---|
133 | - Warning and error messages' content is completely |
---|
134 | configurable. |
---|
135 | |
---|
136 | - Configuration can be changed without needing to |
---|
137 | restart the printing system. |
---|
138 | |
---|
139 | - Complete print job history is kept. This can be |
---|
140 | disabled if needed. |
---|
141 | |
---|
142 | - Automated low quota or balance remainder can be |
---|
143 | scheduled regularly or launched manually. |
---|
144 | |
---|
145 | User Interface : |
---|
146 | |
---|
147 | - All the command line tools accept the -h | --help |
---|
148 | command line option which prints all the available |
---|
149 | options and show usage examples. |
---|
150 | |
---|
151 | - Completely internationalized. Actually supports the |
---|
152 | English and French languages. More to come. |
---|
153 | |
---|
154 | ==================================================================== |
---|
155 | |
---|
156 | Planned features are described in the TODO file. |
---|
157 | |
---|
158 | Actually three (or an infinity of) page accounting methods are |
---|
159 | implemented : |
---|
160 | |
---|
161 | - The 'querying' method consists in querying the printer (via SNMP |
---|
162 | or Netatalk or any other method of your choice) for its total pages |
---|
163 | counter, just before the beginning of a job, and use this to modify |
---|
164 | the *preceding* user's quota. So you're always late of one print job, |
---|
165 | but this is generally ok, especially because a check is also done to |
---|
166 | see if the current user is allowed or not to print. |
---|
167 | |
---|
168 | - The 'external' method consists in delegating the computation of the |
---|
169 | job's size in number of pages to any external command of your choice. |
---|
170 | The command can read the job's data from its standard input and MUST |
---|
171 | output the job's size on its standard output. |
---|
172 | |
---|
173 | - The 'stupid' method consists in counting the 'showpage' PostSript |
---|
174 | statements in the job. THIS IS UNRELIABLE, but can serve as an |
---|
175 | example if you plan to write your own accounting method for |
---|
176 | integration into PyKota. |
---|
177 | |
---|
178 | PyKota is known to work fine with HP Laserjet 2100 and 2200, and |
---|
179 | Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under |
---|
180 | Debian GNU/Linux (Sarge and Sid) operating systems. |
---|
181 | |
---|
182 | I'm interested in receiving success or failure reports with other |
---|
183 | brands or models of printers, as well as with other operating |
---|
184 | systems. |
---|
185 | |
---|
186 | ============================================================ |
---|
187 | |
---|
188 | INSTALLATION: |
---|
189 | ============= |
---|
190 | |
---|
191 | WARNING : |
---|
192 | ========= |
---|
193 | |
---|
194 | If you run a PyKota version lower than 1.03, you definitely have to |
---|
195 | upgrade you Quota Storage Database. Please read the documentation |
---|
196 | included in the initscripts subdirectory first ! |
---|
197 | |
---|
198 | Users of MacOS-X may find the following tutorial useful : |
---|
199 | |
---|
200 | http://ell-tech.com/pages/pykota.php |
---|
201 | |
---|
202 | Prerequisite : |
---|
203 | -------------- |
---|
204 | |
---|
205 | You need to have the following tools installed on the CUPS Server : |
---|
206 | |
---|
207 | - CUPS or LPRng |
---|
208 | - Python v2.1 or above |
---|
209 | - eGenix' mxDateTime Python extension |
---|
210 | - SNMP tools (specifically the snmpget command) if you plan to |
---|
211 | request your printer's lifetime page counter via SNMP. |
---|
212 | - Netatalk (specifically the pap command) if you plan to |
---|
213 | request your printer's lifetime page counter via AppleTalk. |
---|
214 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
215 | libraries if you plan to use PostgreSQL as the Quota Storage |
---|
216 | backend. |
---|
217 | or |
---|
218 | - python-ldap Python module and the OpenLDAP client libraries |
---|
219 | if you plan to use OpenLDAP as the Quota Storage backend. |
---|
220 | |
---|
221 | You need to have the following tools installed on the Quota Storage |
---|
222 | Server : |
---|
223 | |
---|
224 | - PostgreSQL |
---|
225 | |
---|
226 | or |
---|
227 | |
---|
228 | - OpenLDAP |
---|
229 | |
---|
230 | NB : |
---|
231 | |
---|
232 | PygreSQL must be linked with the PostgreSQL client libraries on |
---|
233 | the Print Server. The PostgreSQL client libraries' version must |
---|
234 | match the PostgreSQL version used on the Quota Storage Server. |
---|
235 | |
---|
236 | or |
---|
237 | |
---|
238 | python-ldap must be linked with the OpenLDAP client libraries on the |
---|
239 | Print Server. The OpenLDAP client libraries' version must match the |
---|
240 | OpenLDAP version used on the Quota Storage Server. |
---|
241 | |
---|
242 | This list of prerequisite software may change in the future, when |
---|
243 | PyKota will support more functionnalities you will be given |
---|
244 | alternatives. |
---|
245 | |
---|
246 | Of course the Print Server and the Quota Storage Server can be the |
---|
247 | very same machine if you've got a tiny network, or you can have |
---|
248 | multiple Print Servers all storing their quotas on the same Quota |
---|
249 | Storage Server if you've got a bigger network. |
---|
250 | |
---|
251 | Then : |
---|
252 | ------ |
---|
253 | |
---|
254 | Download the latest PyKota version from the CVS tree on : |
---|
255 | |
---|
256 | http://savannah.nongnu.org/projects/pykota |
---|
257 | |
---|
258 | Just type : |
---|
259 | |
---|
260 | python setup.py install |
---|
261 | |
---|
262 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
263 | |
---|
264 | The installation script will now automatically check if some software |
---|
265 | is missing and ask you if you still want to proceed with the |
---|
266 | installation or abort it completely. |
---|
267 | |
---|
268 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
269 | the appropriate storage backend for your configuration. Read |
---|
270 | the associated README file and execute the initialization script |
---|
271 | to create an empty PyKota Storage. Upgrade scripts may be |
---|
272 | provided as well. |
---|
273 | |
---|
274 | Copy the conf/pykota.conf.sample and conf/pykotadmin.conf.sample |
---|
275 | sample configuration files to /etc/pykota/pykota.conf and |
---|
276 | /etc/pykota/pykotadmin.conf. The installation script tries to do this |
---|
277 | for you if needed and you agreed to this action. |
---|
278 | You need to adapt these files to your own needs. |
---|
279 | Especially you have to create sections named after your own |
---|
280 | printers, and change the administrator's email address. |
---|
281 | |
---|
282 | - CUPS Printing System : |
---|
283 | |
---|
284 | Once and for all : |
---|
285 | |
---|
286 | Create a symbolic link to the cupspykota backend |
---|
287 | in CUPS's backend directory : |
---|
288 | |
---|
289 | $ cd /usr/lib/cups/backend |
---|
290 | $ ln -s /usr/bin/cupspykota cupspykota |
---|
291 | |
---|
292 | Restart CUPS so that the new backend can be detected. |
---|
293 | |
---|
294 | $ /etc/init.d/cupsys restart |
---|
295 | |
---|
296 | For new printers : |
---|
297 | |
---|
298 | Go to CUPS management interface (http://localhost:631) |
---|
299 | and choose the appropriate PyKota managed device depending |
---|
300 | on the type of printer you use. For example, if your |
---|
301 | printer is waiting on : |
---|
302 | |
---|
303 | socket://myprinter.domain.com:9100 |
---|
304 | |
---|
305 | Then choose : |
---|
306 | |
---|
307 | cupspykota:socket://myprinter.domain.com:9100 |
---|
308 | |
---|
309 | Configure your printer as usual. |
---|
310 | |
---|
311 | That's all. |
---|
312 | |
---|
313 | For existing printers : |
---|
314 | |
---|
315 | If you had already installed PyKota, then remove |
---|
316 | the *cupsFilter lines in your PPD files for each |
---|
317 | printer already managed printers. Each line to |
---|
318 | remove is of the form : |
---|
319 | |
---|
320 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/bin/pykota" |
---|
321 | |
---|
322 | Don't touch anything else, especially any other *cupsFilter line. |
---|
323 | Then save each of these files and restart CUPS. |
---|
324 | |
---|
325 | Then, the easiest is to directly modify the DeviceURI lines |
---|
326 | in /etc/cups/printers.conf, you just have to put |
---|
327 | 'cupspykota:' in front of what is already on these lines. |
---|
328 | For example, replace : |
---|
329 | |
---|
330 | DeviceURI socket://myprinter.domain.com:9100 |
---|
331 | |
---|
332 | with : |
---|
333 | |
---|
334 | DeviceURI cupspykota:socket://myprinter.domain.com:9100 |
---|
335 | |
---|
336 | Save the file and restart CUPS. |
---|
337 | |
---|
338 | - LPRng Printing System : |
---|
339 | |
---|
340 | Modify the /etc/printcap file to add two lines identical to these ones : |
---|
341 | |
---|
342 | :achk=true |
---|
343 | :as=|/usr/bin/pykota |
---|
344 | |
---|
345 | For each printer on which you want to use print accounting. |
---|
346 | |
---|
347 | Add printers and users to the quota system and set their quota values : |
---|
348 | |
---|
349 | $ edpykota --add -P hp2100 -S 40 -H 50 user1 ... userN |
---|
350 | |
---|
351 | launching edpykota without any argument or with the --help |
---|
352 | command line option will show you all the possibilities. |
---|
353 | |
---|
354 | by default, each user is limited by "quota", this means that on |
---|
355 | each printer he can have a different soft and hard limit. |
---|
356 | You may want to limit the user by his account balance value, |
---|
357 | in which case, the print quota is shared between all printers |
---|
358 | instead of being different. To do this, use the following : |
---|
359 | |
---|
360 | $ edpykota --add -P hp2100 --limitby balance --balance 10 user1 ... userN |
---|
361 | |
---|
362 | This will put 10 $ (or Euros, PyKota doesn't care) on each user's account |
---|
363 | balance, and tell PyKota to limit them by their account balance value. |
---|
364 | Whenever they print on any printer, their account balance value is |
---|
365 | decreased by an amount which depends on the particular price per page |
---|
366 | and per job that you may have defined on the printer with edpykota's |
---|
367 | --charge command line option. |
---|
368 | Soft and Hard limits are not used if "--limitby balance" is used, |
---|
369 | but you can define a "poorman"'s threshold in /etc/pykota/pykota.conf |
---|
370 | to obtain a similar result (warning message when quota is low). |
---|
371 | |
---|
372 | Restart CUPS or LPRng, for example under Debian GNU/Linux systems : |
---|
373 | |
---|
374 | $ /etc/init.d/cupsys restart |
---|
375 | |
---|
376 | or : |
---|
377 | |
---|
378 | $ /etc/init.d/lprng restart |
---|
379 | |
---|
380 | Your users now should be able to print but not exceed their |
---|
381 | printing quota. |
---|
382 | |
---|
383 | To see printer quota usage, you can use : |
---|
384 | |
---|
385 | $ repykota --printer lp |
---|
386 | |
---|
387 | or : |
---|
388 | |
---|
389 | $ repykota |
---|
390 | |
---|
391 | which will print quota usage for all users on all printers, |
---|
392 | along with totals, if you are the root user. If you are |
---|
393 | a regular user, only your own quota report will be produced. |
---|
394 | |
---|
395 | Quota reports are also available remotely by using the CGI script |
---|
396 | printquota.cgi provided in the cgi-bin/ subdirectory. |
---|
397 | |
---|
398 | For different security concerns, please give a look at the SECURITY |
---|
399 | file which is part of this software. |
---|
400 | |
---|
401 | ============================================================ |
---|
402 | |
---|
403 | Mailing list : |
---|
404 | -------------- |
---|
405 | |
---|
406 | A mailing list is dedicated to Pykota, you can subscribe to it |
---|
407 | or consult its archives at : |
---|
408 | |
---|
409 | http://cgi.librelogiciel.com/mailman/listinfo/pykota |
---|
410 | |
---|
411 | IRC : |
---|
412 | ----- |
---|
413 | |
---|
414 | You can also chat with us : |
---|
415 | |
---|
416 | /server irc.freenode.net |
---|
417 | /join #pykota |
---|
418 | |
---|
419 | ============================================================ |
---|
420 | |
---|
421 | Please e-mail bugs to the mailing list at : pykota@librelogiciel.com |
---|
422 | or to the main author at : alet@librelogiciel.com (Jerome Alet) |
---|