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