elog2labfolder/installation_cups.rst~
author weiher
Wed, 07 Feb 2018 16:53:37 +0100
changeset 13 a21f3604f1db
child 15 523ca1dfd077
permissions -rw-r--r--
Added new chapter about CUPS printers
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     1
Printing via CUPS and attaching files to labfolder logbooks
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     2
===========================================================
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     3
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     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::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     5
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     6
	sudo apt-get install cups cups-client cups-bsd
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     7
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     8
Next, you need to configure ``/etc/cups/cupsd.conf``. This is how it looks like on *lftest*::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
     9
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    10
	# Sample configuration file for the CUPS scheduler.  See "man cupsd.conf" for a
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    11
	# complete description of this file.
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    12
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    13
	# Log general information in error_log - change "warn" to "debug"
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    14
	# for troubleshooting...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    15
	LogLevel debug
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    16
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    17
	# Deactivate CUPS' internal logrotating, as we provide a better one, especially
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    18
	# LogLevel debug2 gets usable now
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    19
	MaxLogSize 0
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    20
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    21
	# Administrator user group...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    22
	SystemGroup lpadmin
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    23
	ServerAdmin weiher@fhi-berlin.mpg.de
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    24
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    25
	HostNameLookups On
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    26
	ServerAlias *
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    27
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    28
	# Only listen for connections from the local machine.
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    29
	Listen lftest.rz-berlin.mpg.de:631
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    30
	Listen /var/run/cups/cups.sock
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    31
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    32
	# Show shared printers on the local network.
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    33
	Browsing Off
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    34
	BrowseOrder allow,deny
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    35
	BrowseAllow all
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    36
	BrowseLocalProtocols CUPS dnssd
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    37
	BrowseAddress @LOCAL
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    38
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    39
	# Default authentication type, when authentication is required...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    40
	DefaultAuthType Basic
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    41
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    42
	# Web interface setting...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    43
	WebInterface Yes
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    44
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    45
	# Restrict access to the server...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    46
	<Location />
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    47
	  Satisfy All
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    48
	  Allow localhost
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    49
	  Allow 141.14.*
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    50
	  Allow 172.16.*
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    51
	  Allow 192.*
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    52
	  Allow all
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    53
	  # Allow shared printing and remote administration...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    54
	  Order allow,deny
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    55
	  Allow all
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    56
	</Location>
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    57
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    58
	# Restrict access to the admin pages...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    59
	<Location /admin>
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    60
	  Order deny,allow
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    61
	  Satisfy All
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    62
	  AuthType Basic
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    63
	  Require user @SYSTEM
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    64
	  Deny All
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    65
	  Allow localhost
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    66
	  Allow 141.14.*
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    67
	  Allow 172.16.*
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    68
	</Location>
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    69
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    70
	# Restrict access to configuration files...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    71
	<Location /admin/conf>
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    72
	  Order deny,allow
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    73
	  AuthType Default
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    74
	  Require user @SYSTEM
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    75
	  Satisfy All
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    76
	  Require user root
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    77
	  Deny All
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    78
	  Allow 127.0.0.1
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    79
	  Allow 141.14.*
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    80
	  Allow 172.16.*
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    81
	</Location>
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    82
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    83
	# Set the default printer/job policies...
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    84
	<Policy default>
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    85
	  ... # probably as in the original
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    86
	</Policy>
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    87
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    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::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    89
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    90
	/usr/local/labfolder/printers/FEL/operating$ mkfifo prnt
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    91
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    92
Adapt rights and ownership of lplisten and prnt::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    93
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    94
	$ chmod 744 lplisten
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    95
	$ chmod 666 prnt
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    96
	$ chown lp:lpadmin lplisten prnt
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    97
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    98
Add the labfolder user to the lpadmin group in /etc/group::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
    99
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   100
	lpadmin:x:115:labfolder
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   101
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   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:
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   103
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   104
.. image:: _static/cups_print_operating.png
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   105
   :width: 100 %
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   106
   :align: center
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   107
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   108
To prevent ``DENIED`` errors from apparmor install and set the following::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   109
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   110
	sudo apt-get install apparmor-utils apparmor-profiles
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   111
	sudo aa-complain cupsd
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   112
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   113
Restart the CUPS server::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   114
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   115
	$ service cupsd restart
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   116
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   117
Start the lplisten script in the background::
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   118
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   119
	/usr/local/labfolder/printers/FEL/operating$ ./lplisten &
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   120
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   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:
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   122
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   123
.. image:: _static/create_local_printer01.png
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   124
   :width: 70 %
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   125
   :align: center
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   126
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   127
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   128
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   129
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   130
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   131
a21f3604f1db Added new chapter about CUPS printers
weiher
parents:
diff changeset
   132