root / pykota / trunk / README @ 3413

Revision 3413, 18.9 kB (checked in by jerome, 16 years ago)

Removed unnecessary spaces at EOL.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[695]1# $Id$
2
[3259]3PyKota - Print Quotas for CUPS
[695]4
[3279]5(c) 2003, 2004, 2005, 2006, 2007, 2008 Jerome Alet <alet@librelogiciel.com>
[3259]6This program is free software: you can redistribute it and/or modify
[873]7it under the terms of the GNU General Public License as published by
[3259]8the Free Software Foundation, either version 3 of the License, or
[873]9(at your option) any later version.
[695]10
[873]11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14GNU General Public License for more details.
[695]15
[873]16You should have received a copy of the GNU General Public License
[3259]17along with this program.  If not, see <http://www.gnu.org/licenses/>.
[873]18
[761]19====================================================================
[695]20
[1052]21READ SPECIAL LICENSING AND REDISTRIBUTION TERMS IN THE FILE 'LICENSE'
[761]22
23====================================================================
24
[1154]25PyKota features :
26-----------------
[695]27
[3038]28        http://www.pykota.com/software/pykota/features/
[2638]29
[1154]30====================================================================
[3413]31
[739]32Planned features are described in the TODO file.
33
[3104]34Actually three (or an infinity of) page accounting methods are
[980]35implemented :
[695]36
[1475]37  - The 'hardware' method consists in querying the printer (via SNMP
[3413]38    or Netatalk or any other method of your choice) for its internal
[3104]39    pages counter.
[1600]40    This is done both at the beginning and at the end of a
[3413]41    print job. The counters difference is then used to
[1186]42    decrease the user's account balance or increase his quota usage.
[3413]43
[1475]44  - The 'software' method consists in delegating the computation of the
[980]45    job's size in number of pages to any external command of your choice.
46    The command can read the job's data from its standard input and MUST
[1186]47    output the job's size on its standard output. Changes to the user
[3104]48    account are reported immediately. PyKota by default internally
[3282]49    uses the code from pkpgcounter which can handle a large number
50    of Page Description Languages, and can parse documents produced
51    either by GhostScript or by a number of native printer drivers.
[3104]52    Of course this means you have to install pkpgcounter if you want to
53    use the default PDL parser.
[3282]54    An up-to-date list of supported Page Description Languages and their
55    level of support is available from :
[3413]56
[3282]57      http://www.pykota.com/software/pkpgcounter/
[3413]58
59  - The 'ink' method consists in using pkpgcounter's code to compute
[3104]60    how much of each page is covered by ink in each color of a particular
61    colorspace chosen between CMYK, CMY, RGB, and BW (grayscale).
62    These values are then summed up together and multiplied by a set
63    of coefficients defined in PyKota's configuration files.
[3413]64
[3104]65PyKota is known to work with most printers, excepted GDI ones (Windows
66only). At least one of the accounting methods above should work
67for you. If it's not the case, please report the problem : tell us
68the exact brand and model of the printer, if possible the driver used,
69and send some test files.
[724]70
[695]71============================================================
72
[2001]73SUPPORT CONTRACTS:
74==================
75
76  You can now purchase 8x5x365@NextBusinessDay Technical
[3413]77  Support Contracts from us. The yearly fee is computed with
[2126]78  the following formula :
[2001]79
80  (100.0 * NbPrintServers) + (2.5 * NbPrinters) + (0.04 * NbUsers) EUROS.
[3413]81
[2542]82  This fee includes the VAT, and a free subscription to Official
83  PyKota packages.
[2001]84
85  Please send an email to alet@librelogiciel.com if you're
[3413]86  interested in purchasing such a contract.
[2001]87
[2126]88  Remember that purchasing a support contract for Free Software like PyKota
[3413]89  is a great way to show your appreciation for the work already being done
[2126]90  on this project, and will help to improve this software in the future.
91
[2001]92============================================================
93
[695]94INSTALLATION:
95=============
96
[1186]97NB :
98====
[887]99
[2714]100  PyKota's documentation is available as DocBook SGML sources
101  files in the pykota/docs directory. If you obtained an
102  Official package, in the same directory you'll also find
[3104]103  the documentation in HTML and PDF formats. Otherwise you
104  have to compile it into HTML or PDF yourself by using
105  the appropriate tools as installed on your system.
[3413]106
[2714]107  PyKota's collaborative documentation is available from :
[3413]108
[2909]109    http://www.pykota.com/wiki/
[3413]110
[1397]111  You may learn more about PyKota, if it fits your own organization,
112  its internal working, and some potential performance drawbacks and
[2054]113  how to avoid them, in a document created by Ryan Suarez at :
[3413]114
[2005]115    http://archive.macosxlabs.org/forum/webcrossing_archive/documentation/Pykota_and_CUPS/Pykota_and_CUPS.html
[1034]116
[1651]117  You may also find the following document interesting :
[3413]118
[1651]119    http://es.tldp.org/Tutoriales/doc-openldap-samba-cups-python/
[3413]120
121  This document, written in Spanish by Sergio Gonzalez Gonzalez,
[1651]122  describes the integration of PyKota into an OpenLDAP + Samba
[3413]123  + CUPS installation. Even for people who can't read spanish
[1651]124  this document is really interesting, and contains lots of
125  screenshots.
[3413]126
127
128Prerequisite :
[714]129--------------
[3413]130
[2714]131  See :
[3413]132
[2909]133    http://www.pykota.com/wiki/Dependencies
[3413]134
[2714]135  for an up-to-date list, or see below (maybe not up-to-date) :
[3413]136
[714]137  You need to have the following tools installed on the CUPS Server :
[3413]138
[3282]139    - CUPS (http://www.cups.org). PyKota v1.27 requires CUPS v1.3.4 or higher.
[3201]140    - Python v2.3 or higher (http://www.python.org)
[1886]141    - eGenix' mxDateTime Python extension (http://www.egenix.com)
[2345]142    - The pkpgcounter command line tool, version 1.56 or higher. This
[3413]143      tool is now mandatory for PyKota to work.
[2909]144      (http://www.pykota.com/software/pkpgcounter)
[3413]145    - The pkipplib Python library (http://www.pykota.com/software/pkipplib)
[1771]146    - The JAXML Python module to be able to dump datas in the XML format.
[1886]147      (http://www.librelogiciel.com/software/)
[3413]148    - The Python-PAM module if you need the pknotify command to be able
[3006]149      to check usernames and passwords. (http://www.pangalactic.org/PyPAM)
[1771]150    - The Python-SNMP module to query printers for their page counter.
[3413]151      (http://pysnmp.sourceforge.net)
[2877]152      IMPORTANT : version 3.4.2 or higher is REQUIRED.
153      Versions 2.x won't work. Versions 4.x now work (tested with v4.1.5a).
[1771]154    - The Python-OSD module to use the graphical print quota reminder.
[2189]155      (http://repose.cx/pyosd/)
[1771]156    - SNMP tools (specifically the snmpget command) if you prefer to
[3287]157      use your own script to request query printers instead of PyKota's
158      internal SNMP handling facilities, which is not recommanded...
[2189]159      (http://www.net-snmp.org)
[919]160    - Netatalk (specifically the pap command) if you plan to
161      request your printer's lifetime page counter via AppleTalk.
[1886]162      (http://netatalk.sourceforge.net)
[3413]163    - The ReportLab Python module (http://www.reportlab.org) if you want
[1927]164      to have PyKota generate nice banners for you.
[3413]165    - The Python Imaging Library (aka PIL) module
166      (http://www.pythonware.com/downloads) if you want to have PyKota
[1927]167      generate nice banners for you.
[1043]168    - PostgreSQL's PygreSQL Python extension and the PostgreSQL client
[2597]169      libraries if you plan to use PostgreSQL as the database backend.
[1886]170      (http://www.postgresql.org and http://www.pygreql.org)
[3413]171 or
172    - python-ldap Python module and the OpenLDAP client libraries
[2597]173      if you plan to use an LDAP server as the database backend.
[1886]174      (http://www.openldap.org and http://python-ldap.sourceforge.net)
[3413]175 or
[2597]176    - SQLite v3.2.7 and the SQLite libraries if you plan to use SQLite
[3413]177      as the database backend (http://www.sqlite.org). You also need the
[2597]178      PySQLite module v2.0.5 or higher (http://www.pysqlite.org)
[2638]179 or
[3413]180    - The MySQL-python bindings.
181      IMPORTANT: If you are using MySQL 4.1, then MySQL-python must be
[2638]182      version 1.2 or greater. Version 1.0 does not work correctly with 4.1.
[3413]183
184
[1771]185  On Intel i386 architecture, and for performance reasons, it is
[3408]186  suggested that you install the Python accelerator Psyco, available from :
[3413]187
[1570]188      http://psyco.sourceforge.net
[3413]189
190  Under Debian :
191
[1571]192      $ apt-get install python-psyco
[3413]193
194  Other architectures may be supported as well in the future, check
[1600]195  this on Psyco's website.
[3413]196
197  Installing Psyco is not mandatory, but may really speed the parsing
[3408]198  of some print jobs.
[3413]199
[2597]200  You need to have the following tools installed on the database
201  server :
[3413]202
[1886]203    - PostgreSQL (http://www.postgresql.org)
[3413]204
205  or
206
[1886]207    - OpenLDAP, or any other LDAP server (http://www.openldap.org)
[3413]208
209  or
210
[2597]211    - SQLite, v3.2.7 or higher (http://www.sqlite.org).
212      Beware : with SQLite the database server and the print
213      servers MUST be the very same machine.
[3413]214
215  or
216
[3104]217    - MySQL 4.1 or higher. 5.x is recommended.
[3413]218
[714]219  This list of prerequisite software may change in the future, when
[3413]220  PyKota will support more functionnalities you will be given
[714]221  alternatives.
[3413]222
223  Of course the Print Server and the database server can be the
224  very same machine if you've got a tiny network, or you can have
[2597]225  multiple Print Servers all storing their quotas on the same database
226  server if you've got a bigger network. (NB : with SQLite, the database
227  can't be shared between several print servers)
[3413]228
229Hint :
[1886]230------
231
[3413]232  - The Debian GNU/Linux distribution is to our knowledge the
[3081]233    easiest distribution to install PyKota on, because almost all
[3408]234    of PyKota dependencies are already included.
[3104]235    We recommend you to use Debian's Etch distribution or
236    more recent. PyKota works fine on Sarge, but some additional
237    dependencies are missing in Sarge and have to be installed
238    manually.
[1886]239
[3413]240Then :
[714]241------
[3413]242
[2135]243Download the latest PyKota version from the Subversion tree :
[695]244
[3377]245    $ svn co http://svn.pykota.com/pykota/trunk pykota
[695]246
[1906]247You can now check if the dependencies are correct by typing :
[695]248
[2135]249    $ python checkdeps.py
[3413]250
[2234]251    An availability report for all the software needed by PyKota
252    will be displayed : you'll have to install the missing
253    software if you want PyKota to work correctly.
[3413]254
[1906]255To install the software, just type :
256
[2135]257    $ python setup.py install
[695]258
259You may need to be logged in with sufficient privileges (e.g. root)
260
[3081]261If you use Debian or Ubuntu, and want to use PostgreSQL as the
262database backend, just type :
263
[3201]264    $ pksetup debian
265
[3413]266or :
267
[3201]268    $ pksetup ubuntu
[3413]269
[3081]270and follow the instructions to install PyKota in interactive mode, then
271skip the remaining of the section below.
272
273Otherwise, you have to setup manually :
274
[1960]275Create a system user for PyKota :
276
[2135]277    $ adduser --system --group --home /etc/pykota --gecos PyKota pykota
[3413]278
[1960]279Put the user your printing system is run as in the pykota system group :
280
[2135]281    $ adduser lp pykota
[3413]282
[1960]283    NB : on our system, the CUPS printing system runs as system user 'lp'.
284    Please adapt this to your own system.
285
[3104]286Go to the initscripts/ subdirectory of PyKota's sources, and choose
[1600]287the appropriate storage backend for your configuration. Read carefully
[3104]288the associated README file, modify the initialization script to
289change the passwords, or, in the case of the LDAP backend, adapt it
290to your own LDAP DIT, and execute the initialization script
[3413]291to create an empty PyKota database. Upgrade scripts may be
[2269]292provided as well. NB : if you use PostgreSQL, a good way to
293make PyKota work first time is to modify PostgreSQL's pg_hba.conf
294to allow the 'trust' database connection mode. However once PyKota
295works it is HIGHLY RECOMMENDED TO CHANGE THIS TO A MORE SECURE
[3104]296VALUE. Look at the SECURITY document, PyKota's Official documentation
297and PostgreSQL's documentation for details on this subject.
[695]298
[3413]299Copy the conf/pykota.conf.sample and  conf/pykotadmin.conf.sample
300sample configuration files to ~pykota/pykota.conf and
301~pykota/pykotadmin.conf
[1905]302The installation script usually copies these files into /usr/share/pykota
[1198]303
[1979]304NB : You can move PyKota's configuration files elsewhere, they will
[3104]305be searched first in user pykota's home directory, then in /etc/pykota.
[1979]306
[3413]307You need to adapt these files to your own needs. Especially you may
308have to create sections named after your own printers, and change
309the administrator's email address which by default is
310root@localhost. Read and try to understand these two very well
311commented files, so that you'll encounter less problems later.
[1905]312
[1186]313The rest of the installation depends on your printing system :
314
[1185]315  - CUPS Printing System :
[3413]316
[1185]317    Once and for all :
[3413]318
[3270]319        Modify CUPS' cupsd.conf to make CUPS listen to 127.0.0.1:631
320        INSTEAD OF to an unix domain socket, in addition to any
321        external network interface CUPS might already be listening to.
[3413]322
323        Create a symbolic link to the cupspykota backend
[1185]324        in CUPS's backend directory :
[3413]325
[1185]326          $ cd /usr/lib/cups/backend
[1345]327          $ ln -s /usr/share/pykota/cupspykota cupspykota
[3413]328
329        If you use CUPS v1.2 or higher, please do this as well :
330
[2943]331          $ chmod 700 /usr/share/pykota/cupspykota
[3413]332
[2943]333          This allows the cupspykota backend to support other
334          backends which must be run as user root, like the
335          lpd backend for example.
[3413]336
[1185]337        Restart CUPS so that the new backend can be detected.
[3413]338
[1185]339          $ /etc/init.d/cupsys restart
[3413]340
341          for example under Debian, or any similar command depending
[3104]342          on your operating system of choice.
[3413]343
[1185]344    For new printers :
[3413]345
346        Go to CUPS management interface (http://localhost:631)
[1185]347        and choose the appropriate PyKota managed device depending
348        on the type of printer you use. For example, if your
349        printer is waiting on :
[3413]350
[1354]351            socket://myprinter.example.com:9100
[3413]352
353        Then choose :
354
[1354]355            cupspykota:socket://myprinter.example.com:9100
[3413]356
357        Configure your printer as usual.
358
359        Now double check /etc/pykota/pykota.conf
360
[1600]361        You should manually create a section named after the
[1402]362        printer you've just added, unless you have set
363        all options globally.
[3413]364
365        The new pkturnkey command can help you with correct settings
[3104]366        for your printers. To have pkturnkey give you some hints
367        about what to put into pykota.conf for a particular
368        print queue, just use its --doconf command line switch :
[3413]369
[3104]370          $ pkturnkey --doconf TheNameOfThePrintQueue
[3413]371
[2468]372        pkturnkey will try to tell you what is the best accounting
[1600]373        method for each printer and will print some lines you'll
374        just have to copy&paste in the appropriate sections in
375        /etc/pykota/pykota.conf
[3413]376
[2468]377        For more informations about what pkturnkey can do for you,
378        see pkturnkey's manual page or use the --help command
379        line switch :
[3413]380
[2468]381          $ pkturnkey --help | less
[3413]382
[1185]383        That's all.
[3413]384
[3104]385    For existing print queues :
[3413]386
[3104]387        You want to route the print queue through PyKota,
388        and you can do this in several manners.
[3413]389
[3104]390          $ pkprinters --add --cups TheNameOfThePrintQueue
[3413]391
392        or
393
[3104]394          if your printer's DeviceURI is something like :
[3413]395
[3104]396              socket://myprinter.example.com:9100
[3413]397
398          then you can do this :
399
[3104]400          $ pkprinters --add TheNameOfThePrintQueue
401          $ lpadmin -p TheNameOfThePrintQueue \
402                    -v cupspykota://socket://myprinter.example.com:9100
[3413]403
404        Finally, you could do it manually by modifying the
[3104]405        the DeviceURI lines in /etc/cups/printers.conf :
[3413]406        You would have to preprend 'cupspykota://' in front
[3104]407        of what is already on these lines. For example, replace :
[3413]408
[1354]409            DeviceURI socket://myprinter.example.com:9100
[3413]410
411        with :
412
[3104]413            DeviceURI cupspykota://socket://myprinter.example.com:9100
[3413]414
415        or :
416
[1354]417            DeviceURI cupspykota://socket://myprinter.example.com:9100
[3413]418
[3104]419        Save the file and restart CUPS for the changes to take effect.
[3413]420
[2470]421        Here too, you may find it interesting to use the pkturnkey command as
[1600]422        described above to help with manual configuration of the file
423        /etc/pykota/pykota.conf
[695]424
[1186]425Now you can begin to populate the PyKota's database with printers,
426users and groups :
[695]427
[3413]428Add printers and users to the quota system and set their quota values :
429
[2470]430You can either use pkturnkey, or do the same things manually by
[2714]431using the pkprinters, pkusers and edpykota command line tools :
[1345]432
[2714]433Create printers :
434
[1345]435    $ pkprinters --help
[3413]436
[1345]437    will tell you how to create, manage or delete printers and
438    printers groups.
[3413]439
[1402]440    $ pkprinters --add --charge 0.05 hp2100
[3413]441
[1402]442    would add the printer named hp2100 with a price per page
443    of 0.05 unit.
[1345]444
[2714]445Create users :
[1402]446
[3104]447    $ pkusers --add --limitby balance --balance 10.0 jerome
[3413]448
[2714]449    would create user jerome and give him ten credits to spend
450    on any printer.
[3413]451
[2714]452Finally create print quota entries :
[695]453
[3104]454    $ edpykota --add --printer hp2100 john paul george ringo
[3413]455
456    This will create print quota entries for The Beatles on
[2714]457    printer hp2100. The print quota entry holds the number of
458    pages printed on a particular printer for a particular
459    user, as well as optional page limits to be used instead
460    of balance limits. See pkusers and edpykota's manual
461    pages for details.
[3413]462
463Your users now should be able to print but not exceed their
[695]464printing quota.
465
[2234]466To see printer quota usage on printer hp2100, you can use :
[794]467
[2234]468    $ repykota --printer hp2100
[3413]469
[794]470or :
471
472    $ repykota
[3413]473
[794]474    which will print quota usage for all users on all printers,
[2054]475    along with totals, if you are a PyKota Administator. If you are
[1107]476    a regular user, only your own quota report will be produced.
[3104]477
[3413]478You can also use these commands :
479
480    $ pkusers --list
[3104]481    $ edpykota --list
[3413]482
[3104]483    $ pkusers --list john paul george ringo
484    $ edpykota --list --printer hp2100 john paul george ringo
[3413]485
[1107]486Quota reports are also available remotely by using the CGI script
[3413]487printquota.cgi provided in the cgi-bin/ subdirectory. You can
[1345]488also use the CSS stylesheet present in the stylesheets/ subdirectory
[3413]489and put it at your web server's DocumentRoot, to benefit from a nicer
[1402]490look, especially quota violations will appear in different colors.
[990]491
[2262]492For additionnal security concerns, please give a look at the SECURITY
[980]493file which is part of this software.
[2234]494
495To diagnose a problem when something doesn't work as expected,
[3104]496please read this FAQ entry :
497
498  http://otrs.librelogiciel.com/otrs/public.pl?ID=2
[3413]499
[695]500============================================================
501
[3408]502Mailing lists :
503---------------
[1979]504
[3408]505  A mailing list is dedicated to PyKota, you can subscribe to it
[958]506  or consult its archives at :
[3413]507
[3408]508    http://lists.pykota.com/mailman/listinfo/pykota
[3413]509
510  This mailing list is the preferred way to obtain support, because
[1600]511  all members can help and can also benefit from the solutions
[3413]512  proposed by other members.
513
[3408]514  Another mailing list, dedicated to developers, is available from :
[3413]515
[3408]516    http://lists.pykota.com/mailman/listinfo/pykota-devel
[3413]517
518  In this mailing list you can discuss implementation details, bugs,
[3408]519  ideas, and so on. All commit messages are also sent to this list.
[3413]520
[3408]521  Posts by non-members are rejected.
[3413]522
[3408]523  The mailing lists language is english and only english.
[3413]524
525IRC :
[1181]526-----
527
528  You can also chat with us :
[3413]529
[1181]530        /server irc.freenode.net
531        /join #pykota
[3413]532
533  Preferred language on this channel is english, but french
[1600]534  is also accepted. Try to avoid exposing complex problems
535  in french because english speaking people on the channel
536  wouldn't benefit from the solutions.
[3413]537
[1600]538  PyKota's main author is known as 'tamere' on IRC.
[3413]539
540Bug Tracker :
[3377]541-------------
542
543  You can report bugs to our bug tracker on the development website
544  at :
[3413]545
[3377]546      http://trac.pykota.com
Note: See TracBrowser for help on using the browser.