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