root / pykota / trunk / README @ 3270

Revision 3270, 21.3 kB (checked in by jerome, 16 years ago)

Added something about unix domain sockets which are unsupported
by pkipplib for now.

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