elog2labfolder/installation_cups.rst~
changeset 15 523ca1dfd077
parent 13 a21f3604f1db
child 17 02a3741242b2
equal deleted inserted replaced
13:a21f3604f1db 15:523ca1dfd077
     1 Printing via CUPS and attaching files to labfolder logbooks
     1 Printing via CUPS and attaching files to labfolder logbooks
     2 ===========================================================
     2 ===========================================================
     3 
     3 
     4 If you want to print a webpage as PDF and send it to onf of labfolder's logbooks you could create a CUPS printer for each logbook that uses the labfolder API to attach this PDF to a newly created entry. First, you need to install CUPS on the virtual machine that runs labfolder::
     4 Follow this guide to set up CUPS virtual printers to be able to print webpages and pictures/files (PDF, PNG, JPG, PS) to one of labfolder's logbooks, thus, creating a new entry with an attachment. If you are an admin of the labfolder VM read the section :ref:`section_cups_admin`. Users of labfolder read the section :ref:`section_cups_user`.
       
     5 
       
     6 
       
     7 .. _section_cups_admin:
       
     8 
       
     9 Set up CUPS as labfolder admin
       
    10 ------------------------------
       
    11 
       
    12 First, you need to install CUPS on the virtual machine that runs labfolder::
     5 
    13 
     6 	sudo apt-get install cups cups-client cups-bsd
    14 	sudo apt-get install cups cups-client cups-bsd
     7 
    15 
     8 Next, you need to configure ``/etc/cups/cupsd.conf``. This is how it looks like on *lftest*::
    16 Next, configure ``/etc/cups/cupsd.conf``::
     9 
    17 
    10 	# Sample configuration file for the CUPS scheduler.  See "man cupsd.conf" for a
    18 	# Sample configuration file for the CUPS scheduler.  See "man cupsd.conf" for a
    11 	# complete description of this file.
    19 	# complete description of this file.
    12 
    20 
    13 	# Log general information in error_log - change "warn" to "debug"
    21 	# Log general information in error_log - change "warn" to "debug"
    18 	# LogLevel debug2 gets usable now
    26 	# LogLevel debug2 gets usable now
    19 	MaxLogSize 0
    27 	MaxLogSize 0
    20 
    28 
    21 	# Administrator user group...
    29 	# Administrator user group...
    22 	SystemGroup lpadmin
    30 	SystemGroup lpadmin
    23 	ServerAdmin weiher@fhi-berlin.mpg.de
    31 	ServerAdmin <name>@fhi-berlin.mpg.de
    24 
    32 
    25 	HostNameLookups On
    33 	HostNameLookups On
    26 	ServerAlias *
    34 	ServerAlias *
    27 
    35 
    28 	# Only listen for connections from the local machine.
    36 	# Only listen for connections from the local machine.
    83 	# Set the default printer/job policies...
    91 	# Set the default printer/job policies...
    84 	<Policy default>
    92 	<Policy default>
    85 	  ... # probably as in the original
    93 	  ... # probably as in the original
    86 	</Policy>
    94 	</Policy>
    87 
    95 
    88 Now, you need to create a file system that will hold all CUPS printers, For example, the printers belonging to the logbooks *FEL/operating* and *FEL/installation* could be put in ``/usr/local/labfolder/printers/FEL``. Copy the lplisten script from the git repository ``https://github.molgen.mpg.de/weiher/elog2labfolder.git`` to ``/usr/local/labfolder/printers/FEL/operating`` and to ``.../FEL/installation``. Also, create a pipe that redirects the printer input to the lplisten script::
    96 Change the *Server Admin*'s e-mail address and the server that shall be listened to (see the ``Listen`` statement). Set `FileDevice Yes` in ``/etc/cups/cups-files.conf``. Now, create a directory where all printers will go, e.g. ``/usr/local/labfolder/printers``.
    89 
    97 
    90 	/usr/local/labfolder/printers/FEL/operating$ mkfifo prnt
    98 Get the package for creating new printers from git::
    91 
    99 
    92 Adapt rights and ownership of lplisten and prnt::
   100 	labfolder@lftest:~$ git clone https://github.molgen.mpg.de/weiher/cupsPrinters
       
   101 	labfolder@lftest:~$ ls
       
   102 	cupsPrinters  labfolder
    93 
   103 
    94 	$ chmod 744 lplisten
   104 The only file you need to adapt is ``newPrinter.sh``. It is not a must but it is suggested to name the printers like the projects. For example, the FEL projects *operating* and *installation* could be placed at ``.../printers/FEL/operating`` and ``.../printers/FEL/installation``. Execute the script with sudo rights::
    95 	$ chmod 666 prnt
       
    96 	$ chown lp:lpadmin lplisten prnt
       
    97 
   105 
    98 Add the labfolder user to the lpadmin group in /etc/group::
   106 	labfolder@lftest:~/cupsPrinters$ sudo ./newPrinter.sh
    99 
   107 
   100 	lpadmin:x:115:labfolder
   108 To prevent ``DENIED`` errors from apparmor install and set the following and restart the CUPS server::
   101 
   109 
   102 Now, create the CUPS printers via the web interface at ``http://lftest.rz-berlin.mpg.de:631/`` (as configured in cupsd.conf). For example, the *operating* printer points at ``FEL/operating/prnt``. The ready configured printer looks like this in the web interface:
   110 	$ sudo apt-get install apparmor-utils apparmor-profiles
       
   111 	$ sudo aa-complain cupsd
       
   112 	$ sudo service cups restart
   103 
   113 
   104 .. image:: _static/cups_print_operating.png
   114 In case you need to debug some logfiles can be found here: */var/log/syslog*, */var/log/cups/error_log* and */var/log/cups/acces_log*
   105    :width: 100 %
       
   106    :align: center
       
   107 
   115 
   108 To prevent ``DENIED`` errors from apparmor install and set the following::
   116 One last change is that you need to once add a user named *Printer Print* (firstname lastname) to the labfolder database. This can be done manually inside the DB by this command::
   109 
   117 
   110 	sudo apt-get install apparmor-utils apparmor-profiles
   118 	$ mysql -u root -p
   111 	sudo aa-complain cupsd
   119 	Enter password:
       
   120 	...
       
   121 	mysql> use labfolder;
       
   122 	mysql> INSERT INTO user (email, password, firstname, lastname, signupTimestamp, maxStorage) VALUES ('printer@fhi-berlin.mpg.de', '91a13f2aba4a35b00c35dfacadd1d75f4a5171dfa7a465fca9c40e6b007ce982', 'Printer', 'Print', '2018-03-21 10:54:00', '10000000');
   112 
   123 
   113 Restart the CUPS server::
       
   114 
   124 
   115 	$ service cupsd restart
   125 .. _section_cups_user:
   116 
   126 
   117 Start the lplisten script in the background::
   127 Printing to labfolder projects
   118 
   128 ------------------------------
   119 	/usr/local/labfolder/printers/FEL/operating$ ./lplisten &
       
   120 
   129 
   121 The last thing you need to do is to set up a printer *operating* on your local machine. In Ubuntu Gnome hit Alt+F2 keys and enter ``system-config-printer``. In this printer config interface add a new printer *operating* as follows:
   130 The last thing you need to do is to set up a printer *operating* on your local machine. In Ubuntu Gnome hit Alt+F2 keys and enter ``system-config-printer``. In this printer config interface add a new printer *operating* as follows:
   122 
   131 
   123 .. image:: _static/create_local_printer01.png
   132 .. image:: _static/create_local_printer01.png
   124    :width: 70 %
   133    :width: 70 %
   125    :align: center
   134    :align: center
   126 
   135 
   127 
   136 
       
   137 .. image:: _static/create_local_printer02.png   
       
   138    :width: 70 %
       
   139    :align: center
   128 
   140 
   129 
   141 
       
   142 .. image:: _static/create_local_printer03.png
       
   143    :width: 70 %
       
   144    :align: center
   130 
   145 
   131 
   146 
       
   147 .. image:: _static/create_local_printer04.png
       
   148    :width: 70 %
       
   149    :align: center
   132 
   150 
       
   151 
       
   152 .. image:: _static/create_local_printer05.png
       
   153    :width: 70 %
       
   154    :align: center
       
   155 
       
   156 
       
   157 .. image:: _static/create_local_printer06.png
       
   158    :width: 70 %
       
   159    :align: center
       
   160 
       
   161 
       
   162 .. image:: _static/create_local_printer07.png
       
   163    :width: 70 %
       
   164    :align: center
       
   165