[695] | 1 | # $Id$ |
---|
| 2 | |
---|
[952] | 3 | PyKota - Print Quota for CUPS and LPRng |
---|
[695] | 4 | |
---|
| 5 | (c) 2003 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 | |
---|
| 68 | - Supports user and groups quotas. |
---|
[739] | 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 | - 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. |
---|
[794] | 91 | |
---|
[1154] | 92 | - Low level of page quota or account balance are |
---|
| 93 | configurable. |
---|
[739] | 94 | |
---|
[1154] | 95 | - Both soft and hard limit with configurable grace delay |
---|
| 96 | can be set for page quota. |
---|
[900] | 97 | |
---|
[1154] | 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. |
---|
[925] | 106 | |
---|
[1154] | 107 | - Administration tools can modify several users, |
---|
| 108 | groups, or printers at once. |
---|
[925] | 109 | |
---|
[1154] | 110 | - Account balances can be set, incremented, or |
---|
| 111 | decremented. |
---|
[1153] | 112 | |
---|
[1154] | 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. |
---|
[739] | 138 | |
---|
[1154] | 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 | |
---|
[1155] | 145 | User Interface : |
---|
| 146 | |
---|
[1154] | 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. |
---|
[1155] | 150 | |
---|
| 151 | - Completely internationalized. Actually supports the |
---|
| 152 | English and French languages. More to come. |
---|
[1154] | 153 | |
---|
| 154 | ==================================================================== |
---|
| 155 | |
---|
[739] | 156 | Planned features are described in the TODO file. |
---|
| 157 | |
---|
[980] | 158 | Actually three (or an infinity of) page accounting methods are |
---|
| 159 | implemented : |
---|
[695] | 160 | |
---|
[980] | 161 | - The 'querying' method consists in querying the printer (via SNMP |
---|
[1181] | 162 | or Netatalk or any other method of your choice) for its total pages |
---|
[1186] | 163 | counter. |
---|
[980] | 164 | |
---|
[1186] | 165 | With CUPS, this is done both at the beginning and at the end of a |
---|
| 166 | print job. The counters difference is then immediately used to |
---|
| 167 | decrease the user's account balance or increase his quota usage. |
---|
| 168 | |
---|
| 169 | With LPRng, this is done just before the beginning of a job, and used |
---|
| 170 | this to modify the *preceding* user's quota. So you're always late |
---|
| 171 | of one print job, but this is generally ok, especially because a |
---|
| 172 | check is also done to see if the current user is allowed or not to |
---|
| 173 | print. |
---|
| 174 | |
---|
[980] | 175 | - The 'external' method consists in delegating the computation of the |
---|
| 176 | job's size in number of pages to any external command of your choice. |
---|
| 177 | The command can read the job's data from its standard input and MUST |
---|
[1186] | 178 | output the job's size on its standard output. Changes to the user |
---|
| 179 | account are reported immediately, both with CUPS and LPRng. |
---|
[980] | 180 | |
---|
| 181 | - The 'stupid' method consists in counting the 'showpage' PostSript |
---|
| 182 | statements in the job. THIS IS UNRELIABLE, but can serve as an |
---|
| 183 | example if you plan to write your own accounting method for |
---|
[1186] | 184 | integration into PyKota. It basically works like the 'external' |
---|
| 185 | method, but does the computation internally. |
---|
[724] | 186 | |
---|
[919] | 187 | PyKota is known to work fine with HP Laserjet 2100 and 2200, and |
---|
[980] | 188 | Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under |
---|
| 189 | Debian GNU/Linux (Sarge and Sid) operating systems. |
---|
[724] | 190 | |
---|
[980] | 191 | I'm interested in receiving success or failure reports with other |
---|
| 192 | brands or models of printers, as well as with other operating |
---|
| 193 | systems. |
---|
[859] | 194 | |
---|
[695] | 195 | ============================================================ |
---|
| 196 | |
---|
| 197 | INSTALLATION: |
---|
| 198 | ============= |
---|
| 199 | |
---|
[1186] | 200 | NB : |
---|
| 201 | ==== |
---|
[887] | 202 | |
---|
[1034] | 203 | Users of MacOS-X may find the following tutorial useful : |
---|
| 204 | |
---|
| 205 | http://ell-tech.com/pages/pykota.php |
---|
| 206 | |
---|
[714] | 207 | Prerequisite : |
---|
| 208 | -------------- |
---|
| 209 | |
---|
| 210 | You need to have the following tools installed on the CUPS Server : |
---|
| 211 | |
---|
[952] | 212 | - CUPS or LPRng |
---|
[809] | 213 | - Python v2.1 or above |
---|
[714] | 214 | - eGenix' mxDateTime Python extension |
---|
[919] | 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. |
---|
[1043] | 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. |
---|
[714] | 225 | |
---|
[1186] | 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 | |
---|
[714] | 233 | You need to have the following tools installed on the Quota Storage |
---|
| 234 | Server : |
---|
| 235 | |
---|
| 236 | - PostgreSQL |
---|
| 237 | |
---|
[1043] | 238 | or |
---|
| 239 | |
---|
| 240 | - OpenLDAP |
---|
| 241 | |
---|
[1086] | 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. |
---|
[714] | 247 | |
---|
[1043] | 248 | or |
---|
| 249 | |
---|
[1086] | 250 | python-ldap must be linked with the OpenLDAP client libraries on the |
---|
| 251 | Print Server. The OpenLDAP client libraries' version must match the |
---|
| 252 | OpenLDAP version used on the Quota Storage Server. |
---|
[1043] | 253 | |
---|
[714] | 254 | This list of prerequisite software may change in the future, when |
---|
| 255 | PyKota will support more functionnalities you will be given |
---|
| 256 | alternatives. |
---|
| 257 | |
---|
[952] | 258 | Of course the Print Server and the Quota Storage Server can be the |
---|
[851] | 259 | very same machine if you've got a tiny network, or you can have |
---|
[952] | 260 | multiple Print Servers all storing their quotas on the same Quota |
---|
[851] | 261 | Storage Server if you've got a bigger network. |
---|
| 262 | |
---|
[714] | 263 | Then : |
---|
| 264 | ------ |
---|
| 265 | |
---|
[724] | 266 | Download the latest PyKota version from the CVS tree on : |
---|
[695] | 267 | |
---|
[725] | 268 | http://savannah.nongnu.org/projects/pykota |
---|
[695] | 269 | |
---|
[714] | 270 | Just type : |
---|
[695] | 271 | |
---|
[725] | 272 | python setup.py install |
---|
[695] | 273 | |
---|
| 274 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
| 275 | |
---|
[878] | 276 | The installation script will now automatically check if some software |
---|
| 277 | is missing and ask you if you still want to proceed with the |
---|
| 278 | installation or abort it completely. |
---|
| 279 | |
---|
[695] | 280 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
| 281 | the appropriate storage backend for your configuration. Read |
---|
| 282 | the associated README file and execute the initialization script |
---|
[878] | 283 | to create an empty PyKota Storage. Upgrade scripts may be |
---|
| 284 | provided as well. |
---|
[695] | 285 | |
---|
[1186] | 286 | Copy the conf/pykota.conf.sample and conf/pykotadmin.conf.sample |
---|
[1107] | 287 | sample configuration files to /etc/pykota/pykota.conf and |
---|
[1186] | 288 | /etc/pykota/pykotadmin.conf. The installation script tries to do |
---|
| 289 | this for you if needed and you agreed to this action. You need to |
---|
| 290 | adapt these files to your own needs. Especially you have to create |
---|
| 291 | sections named after your own printers, and change the |
---|
| 292 | administrator's email address which by default is root@localhost. |
---|
| 293 | Read and try to understand these two very well commented files, |
---|
| 294 | so that you'll encounter less problems later. |
---|
[1198] | 295 | |
---|
| 296 | Also be sure to double check that commands that query printers |
---|
[1186] | 297 | for their internal page counter work from the command line |
---|
| 298 | before using them in PyKota's configuration. |
---|
[695] | 299 | |
---|
[1186] | 300 | The rest of the installation depends on your printing system : |
---|
| 301 | |
---|
[1185] | 302 | - CUPS Printing System : |
---|
[952] | 303 | |
---|
[1185] | 304 | Once and for all : |
---|
[952] | 305 | |
---|
[1185] | 306 | Create a symbolic link to the cupspykota backend |
---|
| 307 | in CUPS's backend directory : |
---|
| 308 | |
---|
| 309 | $ cd /usr/lib/cups/backend |
---|
| 310 | $ ln -s /usr/bin/cupspykota cupspykota |
---|
| 311 | |
---|
| 312 | Restart CUPS so that the new backend can be detected. |
---|
| 313 | |
---|
| 314 | $ /etc/init.d/cupsys restart |
---|
| 315 | |
---|
| 316 | For new printers : |
---|
[952] | 317 | |
---|
[1185] | 318 | Go to CUPS management interface (http://localhost:631) |
---|
| 319 | and choose the appropriate PyKota managed device depending |
---|
| 320 | on the type of printer you use. For example, if your |
---|
| 321 | printer is waiting on : |
---|
| 322 | |
---|
| 323 | socket://myprinter.domain.com:9100 |
---|
| 324 | |
---|
| 325 | Then choose : |
---|
| 326 | |
---|
| 327 | cupspykota:socket://myprinter.domain.com:9100 |
---|
| 328 | |
---|
| 329 | Configure your printer as usual. |
---|
| 330 | |
---|
[1186] | 331 | Now double check /etc/pykota/pykota.conf |
---|
| 332 | This file should contain a section named after the |
---|
| 333 | printer you've just added. |
---|
| 334 | |
---|
[1185] | 335 | That's all. |
---|
[952] | 336 | |
---|
[1185] | 337 | For existing printers : |
---|
| 338 | |
---|
[1186] | 339 | If you had already installed a version of PyKota earlier |
---|
| 340 | than 1.16alpha7, then remove the *cupsFilter lines in your |
---|
| 341 | PPD files for each printer already managed printers. Each |
---|
| 342 | line to remove is of the form : |
---|
[1185] | 343 | |
---|
| 344 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/bin/pykota" |
---|
| 345 | |
---|
| 346 | Don't touch anything else, especially any other *cupsFilter line. |
---|
[1186] | 347 | Then save each of these files. |
---|
[1185] | 348 | |
---|
| 349 | Then, the easiest is to directly modify the DeviceURI lines |
---|
| 350 | in /etc/cups/printers.conf, you just have to put |
---|
| 351 | 'cupspykota:' in front of what is already on these lines. |
---|
| 352 | For example, replace : |
---|
| 353 | |
---|
| 354 | DeviceURI socket://myprinter.domain.com:9100 |
---|
| 355 | |
---|
| 356 | with : |
---|
| 357 | |
---|
| 358 | DeviceURI cupspykota:socket://myprinter.domain.com:9100 |
---|
| 359 | |
---|
| 360 | Save the file and restart CUPS. |
---|
[695] | 361 | |
---|
[1185] | 362 | - LPRng Printing System : |
---|
[952] | 363 | |
---|
| 364 | Modify the /etc/printcap file to add two lines identical to these ones : |
---|
| 365 | |
---|
| 366 | :achk=true |
---|
| 367 | :as=|/usr/bin/pykota |
---|
| 368 | |
---|
| 369 | For each printer on which you want to use print accounting. |
---|
[1186] | 370 | |
---|
| 371 | And then save the file and restart LPRng : |
---|
| 372 | |
---|
| 373 | $ /etc/init.d/lprng restart |
---|
| 374 | |
---|
| 375 | Now you can begin to populate the PyKota's database with printers, |
---|
| 376 | users and groups : |
---|
[952] | 377 | |
---|
[716] | 378 | Add printers and users to the quota system and set their quota values : |
---|
[695] | 379 | |
---|
[1086] | 380 | $ edpykota --add -P hp2100 -S 40 -H 50 user1 ... userN |
---|
[724] | 381 | |
---|
[725] | 382 | launching edpykota without any argument or with the --help |
---|
| 383 | command line option will show you all the possibilities. |
---|
[1086] | 384 | |
---|
| 385 | by default, each user is limited by "quota", this means that on |
---|
| 386 | each printer he can have a different soft and hard limit. |
---|
| 387 | You may want to limit the user by his account balance value, |
---|
[1107] | 388 | in which case, the print quota is shared between all printers |
---|
[1086] | 389 | instead of being different. To do this, use the following : |
---|
| 390 | |
---|
| 391 | $ edpykota --add -P hp2100 --limitby balance --balance 10 user1 ... userN |
---|
| 392 | |
---|
| 393 | This will put 10 $ (or Euros, PyKota doesn't care) on each user's account |
---|
| 394 | balance, and tell PyKota to limit them by their account balance value. |
---|
| 395 | Whenever they print on any printer, their account balance value is |
---|
| 396 | decreased by an amount which depends on the particular price per page |
---|
| 397 | and per job that you may have defined on the printer with edpykota's |
---|
| 398 | --charge command line option. |
---|
[1107] | 399 | Soft and Hard limits are not used if "--limitby balance" is used, |
---|
| 400 | but you can define a "poorman"'s threshold in /etc/pykota/pykota.conf |
---|
| 401 | to obtain a similar result (warning message when quota is low). |
---|
[695] | 402 | |
---|
[990] | 403 | Restart CUPS or LPRng, for example under Debian GNU/Linux systems : |
---|
[695] | 404 | |
---|
[725] | 405 | $ /etc/init.d/cupsys restart |
---|
[990] | 406 | |
---|
| 407 | or : |
---|
| 408 | |
---|
| 409 | $ /etc/init.d/lprng restart |
---|
[695] | 410 | |
---|
| 411 | Your users now should be able to print but not exceed their |
---|
| 412 | printing quota. |
---|
| 413 | |
---|
[1149] | 414 | To see printer quota usage, you can use : |
---|
[794] | 415 | |
---|
| 416 | $ repykota --printer lp |
---|
| 417 | |
---|
| 418 | or : |
---|
| 419 | |
---|
| 420 | $ repykota |
---|
| 421 | |
---|
| 422 | which will print quota usage for all users on all printers, |
---|
[1107] | 423 | along with totals, if you are the root user. If you are |
---|
| 424 | a regular user, only your own quota report will be produced. |
---|
[794] | 425 | |
---|
[1107] | 426 | Quota reports are also available remotely by using the CGI script |
---|
| 427 | printquota.cgi provided in the cgi-bin/ subdirectory. |
---|
[990] | 428 | |
---|
[980] | 429 | For different security concerns, please give a look at the SECURITY |
---|
| 430 | file which is part of this software. |
---|
[741] | 431 | |
---|
[695] | 432 | ============================================================ |
---|
| 433 | |
---|
[958] | 434 | Mailing list : |
---|
| 435 | -------------- |
---|
| 436 | |
---|
| 437 | A mailing list is dedicated to Pykota, you can subscribe to it |
---|
| 438 | or consult its archives at : |
---|
| 439 | |
---|
| 440 | http://cgi.librelogiciel.com/mailman/listinfo/pykota |
---|
| 441 | |
---|
[1181] | 442 | IRC : |
---|
| 443 | ----- |
---|
| 444 | |
---|
| 445 | You can also chat with us : |
---|
| 446 | |
---|
| 447 | /server irc.freenode.net |
---|
| 448 | /join #pykota |
---|
| 449 | |
---|
[958] | 450 | ============================================================ |
---|
| 451 | |
---|
[1107] | 452 | Please e-mail bugs to the mailing list at : pykota@librelogiciel.com |
---|
| 453 | or to the main author at : alet@librelogiciel.com (Jerome Alet) |
---|