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