[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. |
---|
| 48 | |
---|
| 49 | Printers : |
---|
| 50 | |
---|
| 51 | - Supports any printer which can report its internal |
---|
| 52 | page counter. |
---|
| 53 | |
---|
| 54 | - Supports any other printer via GhostScript. |
---|
[739] | 55 | |
---|
[1154] | 56 | - Can ask printers for their internal page counter |
---|
| 57 | via SNMP, Netatalk, or any other mean of your |
---|
| 58 | choice. This is completely configurable. |
---|
| 59 | |
---|
| 60 | - External accounting methods are configurable |
---|
| 61 | |
---|
| 62 | Quota systems : |
---|
| 63 | |
---|
| 64 | - Supports user and groups quotas. |
---|
[739] | 65 | |
---|
[1154] | 66 | - Supports page quotas. |
---|
| 67 | Page quotas can be set differently on a per printer |
---|
| 68 | and per user/group basis. |
---|
[739] | 69 | |
---|
[1154] | 70 | - Supports account balance quotas in any currency. |
---|
| 71 | Account balance quotas can be set on a per user |
---|
| 72 | basis. The account balance is shared amongst |
---|
| 73 | all printers. |
---|
[980] | 74 | |
---|
[1154] | 75 | - Experimental support for printer groups, so that |
---|
| 76 | you can share quota between printers of the same |
---|
| 77 | type but in different locations. |
---|
| 78 | |
---|
| 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 | |
---|
[1154] | 109 | - Users can be automatically added on first print |
---|
| 110 | in a completely configurable way. |
---|
| 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 |
---|
| 158 | or Netatalk) for its total pages counter, just before the beginning |
---|
| 159 | of a job, and use this to modify the *preceding* user's quota. So |
---|
| 160 | you're always late of one print job, but this is generally ok, |
---|
| 161 | especially because a check is also done to see if the current user |
---|
| 162 | is allowed or not to print. You're not limited to SNMP or Netatalk, |
---|
| 163 | because you can also use any external command instead if you want. |
---|
| 164 | |
---|
| 165 | - The 'external' method consists in delegating the computation of the |
---|
| 166 | job's size in number of pages to any external command of your choice. |
---|
| 167 | The command can read the job's data from its standard input and MUST |
---|
| 168 | output the job's size on its standard output. |
---|
| 169 | |
---|
| 170 | - The 'stupid' method consists in counting the 'showpage' PostSript |
---|
| 171 | statements in the job. THIS IS UNRELIABLE, but can serve as an |
---|
| 172 | example if you plan to write your own accounting method for |
---|
| 173 | integration into PyKota. |
---|
[724] | 174 | |
---|
[919] | 175 | PyKota is known to work fine with HP Laserjet 2100 and 2200, and |
---|
[980] | 176 | Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under |
---|
| 177 | Debian GNU/Linux (Sarge and Sid) operating systems. |
---|
[724] | 178 | |
---|
[980] | 179 | I'm interested in receiving success or failure reports with other |
---|
| 180 | brands or models of printers, as well as with other operating |
---|
| 181 | systems. |
---|
[859] | 182 | |
---|
[695] | 183 | ============================================================ |
---|
| 184 | |
---|
| 185 | INSTALLATION: |
---|
| 186 | ============= |
---|
| 187 | |
---|
[887] | 188 | WARNING : |
---|
| 189 | ========= |
---|
| 190 | |
---|
[942] | 191 | If you run a PyKota version lower than 1.03, you definitely have to |
---|
[887] | 192 | upgrade you Quota Storage Database. Please read the documentation |
---|
| 193 | included in the initscripts subdirectory first ! |
---|
| 194 | |
---|
[1034] | 195 | Users of MacOS-X may find the following tutorial useful : |
---|
| 196 | |
---|
| 197 | http://ell-tech.com/pages/pykota.php |
---|
| 198 | |
---|
[714] | 199 | Prerequisite : |
---|
| 200 | -------------- |
---|
| 201 | |
---|
| 202 | You need to have the following tools installed on the CUPS Server : |
---|
| 203 | |
---|
[952] | 204 | - CUPS or LPRng |
---|
[809] | 205 | - Python v2.1 or above |
---|
[714] | 206 | - eGenix' mxDateTime Python extension |
---|
[919] | 207 | - SNMP tools (specifically the snmpget command) if you plan to |
---|
| 208 | request your printer's lifetime page counter via SNMP. |
---|
| 209 | - Netatalk (specifically the pap command) if you plan to |
---|
| 210 | request your printer's lifetime page counter via AppleTalk. |
---|
[1043] | 211 | - PostgreSQL's PygreSQL Python extension and the PostgreSQL client |
---|
| 212 | libraries if you plan to use PostgreSQL as the Quota Storage |
---|
| 213 | backend. |
---|
| 214 | or |
---|
| 215 | - python-ldap Python module and the OpenLDAP client libraries |
---|
| 216 | if you plan to use OpenLDAP as the Quota Storage backend. |
---|
[714] | 217 | |
---|
| 218 | You need to have the following tools installed on the Quota Storage |
---|
| 219 | Server : |
---|
| 220 | |
---|
| 221 | - PostgreSQL |
---|
| 222 | |
---|
[1043] | 223 | or |
---|
| 224 | |
---|
| 225 | - OpenLDAP |
---|
| 226 | |
---|
[1086] | 227 | NB : |
---|
| 228 | |
---|
| 229 | PygreSQL must be linked with the PostgreSQL client libraries on |
---|
| 230 | the Print Server. The PostgreSQL client libraries' version must |
---|
| 231 | match the PostgreSQL version used on the Quota Storage Server. |
---|
[714] | 232 | |
---|
[1043] | 233 | or |
---|
| 234 | |
---|
[1086] | 235 | python-ldap must be linked with the OpenLDAP client libraries on the |
---|
| 236 | Print Server. The OpenLDAP client libraries' version must match the |
---|
| 237 | OpenLDAP version used on the Quota Storage Server. |
---|
[1043] | 238 | |
---|
[714] | 239 | This list of prerequisite software may change in the future, when |
---|
| 240 | PyKota will support more functionnalities you will be given |
---|
| 241 | alternatives. |
---|
| 242 | |
---|
[952] | 243 | Of course the Print Server and the Quota Storage Server can be the |
---|
[851] | 244 | very same machine if you've got a tiny network, or you can have |
---|
[952] | 245 | multiple Print Servers all storing their quotas on the same Quota |
---|
[851] | 246 | Storage Server if you've got a bigger network. |
---|
| 247 | |
---|
[714] | 248 | Then : |
---|
| 249 | ------ |
---|
| 250 | |
---|
[724] | 251 | Download the latest PyKota version from the CVS tree on : |
---|
[695] | 252 | |
---|
[725] | 253 | http://savannah.nongnu.org/projects/pykota |
---|
[695] | 254 | |
---|
[714] | 255 | Just type : |
---|
[695] | 256 | |
---|
[725] | 257 | python setup.py install |
---|
[695] | 258 | |
---|
| 259 | You may need to be logged in with sufficient privileges (e.g. root) |
---|
| 260 | |
---|
[878] | 261 | The installation script will now automatically check if some software |
---|
| 262 | is missing and ask you if you still want to proceed with the |
---|
| 263 | installation or abort it completely. |
---|
| 264 | |
---|
[695] | 265 | Go to the initscripts subdirectory of PyKota's sources, and choose |
---|
| 266 | the appropriate storage backend for your configuration. Read |
---|
| 267 | the associated README file and execute the initialization script |
---|
[878] | 268 | to create an empty PyKota Storage. Upgrade scripts may be |
---|
| 269 | provided as well. |
---|
[695] | 270 | |
---|
[1107] | 271 | Copy the conf/pykota.conf.sample and conf/pykotadmin.conf.sample |
---|
| 272 | sample configuration files to /etc/pykota/pykota.conf and |
---|
| 273 | /etc/pykota/pykotadmin.conf. The installation script tries to do this |
---|
| 274 | for you if needed and you agreed to this action. |
---|
| 275 | You need to adapt these files to your own needs. |
---|
[1015] | 276 | Especially you have to create sections named after your own |
---|
| 277 | printers, and change the administrator's email address. |
---|
[695] | 278 | |
---|
[952] | 279 | - CUPS Print Backend : |
---|
| 280 | |
---|
| 281 | Modify the PPD files for each printer on which you want to manage |
---|
| 282 | print quotas, for example /etc/cups/ppd/lp.ppd : |
---|
| 283 | |
---|
| 284 | --- Add the line below exactly as-is somewhere near the top --- |
---|
| 285 | *cupsFilter: "application/vnd.cups-postscript 0 /usr/bin/pykota" |
---|
| 286 | --- Add the line above exactly as-is somewhere near the top --- |
---|
| 287 | |
---|
| 288 | Modify the path to the pykota executable if needed, unfortunately |
---|
| 289 | you have to supply the correct absolute path here due to CUPS |
---|
| 290 | internals, or put the pykota executable into /usr/lib/cups/filter |
---|
| 291 | instead of into /usr/bin. |
---|
| 292 | |
---|
| 293 | Do this for each ppd file present in this directory if you want |
---|
| 294 | to enable quota on every printer. |
---|
| 295 | |
---|
| 296 | WARNING : In the case you've got a non-postscript printer, chances |
---|
| 297 | are that the *cupsFilter is already filled-in and points |
---|
| 298 | to cupsomatic or such a print filter. In this case please |
---|
| 299 | check if you can switch your printer to PostScript mode |
---|
| 300 | or if there's a way to make it accept PostScript jobs. |
---|
| 301 | If yes then ensure that your workstations uses a PostScript |
---|
| 302 | printer driver, and replace the *cupsFilter line with the |
---|
| 303 | one pointing to the pykota filter. This should work, but |
---|
| 304 | is currently untested. |
---|
| 305 | If your printer really needs the original *cupsFilter line |
---|
| 306 | then you may not be able to use PyKota easily for now. |
---|
[695] | 307 | |
---|
[952] | 308 | - LPRng Print Backend : |
---|
| 309 | |
---|
| 310 | Modify the /etc/printcap file to add two lines identical to these ones : |
---|
| 311 | |
---|
| 312 | :achk=true |
---|
| 313 | :as=|/usr/bin/pykota |
---|
| 314 | |
---|
| 315 | For each printer on which you want to use print accounting. |
---|
| 316 | |
---|
[716] | 317 | Add printers and users to the quota system and set their quota values : |
---|
[695] | 318 | |
---|
[1086] | 319 | $ edpykota --add -P hp2100 -S 40 -H 50 user1 ... userN |
---|
[724] | 320 | |
---|
[725] | 321 | launching edpykota without any argument or with the --help |
---|
| 322 | command line option will show you all the possibilities. |
---|
[1086] | 323 | |
---|
| 324 | by default, each user is limited by "quota", this means that on |
---|
| 325 | each printer he can have a different soft and hard limit. |
---|
| 326 | You may want to limit the user by his account balance value, |
---|
[1107] | 327 | in which case, the print quota is shared between all printers |
---|
[1086] | 328 | instead of being different. To do this, use the following : |
---|
| 329 | |
---|
| 330 | $ edpykota --add -P hp2100 --limitby balance --balance 10 user1 ... userN |
---|
| 331 | |
---|
| 332 | This will put 10 $ (or Euros, PyKota doesn't care) on each user's account |
---|
| 333 | balance, and tell PyKota to limit them by their account balance value. |
---|
| 334 | Whenever they print on any printer, their account balance value is |
---|
| 335 | decreased by an amount which depends on the particular price per page |
---|
| 336 | and per job that you may have defined on the printer with edpykota's |
---|
| 337 | --charge command line option. |
---|
[1107] | 338 | Soft and Hard limits are not used if "--limitby balance" is used, |
---|
| 339 | but you can define a "poorman"'s threshold in /etc/pykota/pykota.conf |
---|
| 340 | to obtain a similar result (warning message when quota is low). |
---|
[695] | 341 | |
---|
[990] | 342 | Restart CUPS or LPRng, for example under Debian GNU/Linux systems : |
---|
[695] | 343 | |
---|
[725] | 344 | $ /etc/init.d/cupsys restart |
---|
[990] | 345 | |
---|
| 346 | or : |
---|
| 347 | |
---|
| 348 | $ /etc/init.d/lprng restart |
---|
[695] | 349 | |
---|
| 350 | Your users now should be able to print but not exceed their |
---|
| 351 | printing quota. |
---|
| 352 | |
---|
[1149] | 353 | To see printer quota usage, you can use : |
---|
[794] | 354 | |
---|
| 355 | $ repykota --printer lp |
---|
| 356 | |
---|
| 357 | or : |
---|
| 358 | |
---|
| 359 | $ repykota |
---|
| 360 | |
---|
| 361 | which will print quota usage for all users on all printers, |
---|
[1107] | 362 | along with totals, if you are the root user. If you are |
---|
| 363 | a regular user, only your own quota report will be produced. |
---|
[794] | 364 | |
---|
[1107] | 365 | Quota reports are also available remotely by using the CGI script |
---|
| 366 | printquota.cgi provided in the cgi-bin/ subdirectory. |
---|
[990] | 367 | |
---|
[980] | 368 | For different security concerns, please give a look at the SECURITY |
---|
| 369 | file which is part of this software. |
---|
[741] | 370 | |
---|
[695] | 371 | ============================================================ |
---|
| 372 | |
---|
[958] | 373 | Mailing list : |
---|
| 374 | -------------- |
---|
| 375 | |
---|
| 376 | A mailing list is dedicated to Pykota, you can subscribe to it |
---|
| 377 | or consult its archives at : |
---|
| 378 | |
---|
| 379 | http://cgi.librelogiciel.com/mailman/listinfo/pykota |
---|
| 380 | |
---|
| 381 | ============================================================ |
---|
| 382 | |
---|
[1107] | 383 | Please e-mail bugs to the mailing list at : pykota@librelogiciel.com |
---|
| 384 | or to the main author at : alet@librelogiciel.com (Jerome Alet) |
---|