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