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