elog2labfolder/_build/latex/elog2labfolder.tex
changeset 15 523ca1dfd077
parent 13 a21f3604f1db
child 18 57431f642e82
equal deleted inserted replaced
13:a21f3604f1db 15:523ca1dfd077
    53 \setcounter{tocdepth}{1}
    53 \setcounter{tocdepth}{1}
    54 
    54 
    55 
    55 
    56 
    56 
    57 \title{Labfolder at FHI Documentation}
    57 \title{Labfolder at FHI Documentation}
    58 \date{Feb 07, 2018}
    58 \date{Mar 27, 2018}
    59 \release{1.0}
    59 \release{1.0}
    60 \author{Stefan Weiher}
    60 \author{Stefan Weiher}
    61 \newcommand{\sphinxlogo}{\vbox{}}
    61 \newcommand{\sphinxlogo}{\vbox{}}
    62 \renewcommand{\releasename}{Release}
    62 \renewcommand{\releasename}{Release}
    63 \makeindex
    63 \makeindex
   198 \end{sphinxVerbatim}
   198 \end{sphinxVerbatim}
   199 
   199 
   200 
   200 
   201 \chapter{Printing via CUPS and attaching files to labfolder logbooks}
   201 \chapter{Printing via CUPS and attaching files to labfolder logbooks}
   202 \label{\detokenize{installation_cups:printing-via-cups-and-attaching-files-to-labfolder-logbooks}}\label{\detokenize{installation_cups::doc}}
   202 \label{\detokenize{installation_cups:printing-via-cups-and-attaching-files-to-labfolder-logbooks}}\label{\detokenize{installation_cups::doc}}
   203 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:
   203 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 {\hyperref[\detokenize{installation_cups:section-cups-admin}]{\sphinxcrossref{\DUrole{std,std-ref}{Set up CUPS as labfolder admin}}}}. Users of labfolder read the section {\hyperref[\detokenize{installation_cups:section-cups-user}]{\sphinxcrossref{\DUrole{std,std-ref}{Printing to labfolder projects}}}}.
       
   204 
       
   205 
       
   206 \section{Set up CUPS as labfolder admin}
       
   207 \label{\detokenize{installation_cups:section-cups-admin}}\label{\detokenize{installation_cups:set-up-cups-as-labfolder-admin}}
       
   208 First, you need to install CUPS on the virtual machine that runs labfolder:
   204 
   209 
   205 \fvset{hllines={, ,}}%
   210 \fvset{hllines={, ,}}%
   206 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   211 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   207 \PYG{n}{sudo} \PYG{n}{apt}\PYG{o}{\PYGZhy{}}\PYG{n}{get} \PYG{n}{install} \PYG{n}{cups} \PYG{n}{cups}\PYG{o}{\PYGZhy{}}\PYG{n}{client} \PYG{n}{cups}\PYG{o}{\PYGZhy{}}\PYG{n}{bsd}
   212 \PYG{n}{sudo} \PYG{n}{apt}\PYG{o}{\PYGZhy{}}\PYG{n}{get} \PYG{n}{install} \PYG{n}{cups} \PYG{n}{cups}\PYG{o}{\PYGZhy{}}\PYG{n}{client} \PYG{n}{cups}\PYG{o}{\PYGZhy{}}\PYG{n}{bsd}
   208 \end{sphinxVerbatim}
   213 \end{sphinxVerbatim}
   209 
   214 
   210 Next, you need to configure \sphinxcode{/etc/cups/cupsd.conf}. This is how it looks like on \sphinxstyleemphasis{lftest}:
   215 Next, configure \sphinxcode{/etc/cups/cupsd.conf}:
   211 
   216 
   212 \fvset{hllines={, ,}}%
   217 \fvset{hllines={, ,}}%
   213 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   218 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   214 \PYG{c+c1}{\PYGZsh{} Sample configuration file for the CUPS scheduler.  See \PYGZdq{}man cupsd.conf\PYGZdq{} for a}
   219 \PYG{c+c1}{\PYGZsh{} Sample configuration file for the CUPS scheduler.  See \PYGZdq{}man cupsd.conf\PYGZdq{} for a}
   215 \PYG{c+c1}{\PYGZsh{} complete description of this file.}
   220 \PYG{c+c1}{\PYGZsh{} complete description of this file.}
   222 \PYG{c+c1}{\PYGZsh{} LogLevel debug2 gets usable now}
   227 \PYG{c+c1}{\PYGZsh{} LogLevel debug2 gets usable now}
   223 \PYG{n}{MaxLogSize} \PYG{l+m+mi}{0}
   228 \PYG{n}{MaxLogSize} \PYG{l+m+mi}{0}
   224 
   229 
   225 \PYG{c+c1}{\PYGZsh{} Administrator user group...}
   230 \PYG{c+c1}{\PYGZsh{} Administrator user group...}
   226 \PYG{n}{SystemGroup} \PYG{n}{lpadmin}
   231 \PYG{n}{SystemGroup} \PYG{n}{lpadmin}
   227 \PYG{n}{ServerAdmin} \PYG{n}{weiher}\PYG{n+nd}{@fhi}\PYG{o}{\PYGZhy{}}\PYG{n}{berlin}\PYG{o}{.}\PYG{n}{mpg}\PYG{o}{.}\PYG{n}{de}
   232 \PYG{n}{ServerAdmin} \PYG{o}{\PYGZlt{}}\PYG{n}{name}\PYG{o}{\PYGZgt{}}\PYG{n+nd}{@fhi}\PYG{o}{\PYGZhy{}}\PYG{n}{berlin}\PYG{o}{.}\PYG{n}{mpg}\PYG{o}{.}\PYG{n}{de}
   228 
   233 
   229 \PYG{n}{HostNameLookups} \PYG{n}{On}
   234 \PYG{n}{HostNameLookups} \PYG{n}{On}
   230 \PYG{n}{ServerAlias} \PYG{o}{*}
   235 \PYG{n}{ServerAlias} \PYG{o}{*}
   231 
   236 
   232 \PYG{c+c1}{\PYGZsh{} Only listen for connections from the local machine.}
   237 \PYG{c+c1}{\PYGZsh{} Only listen for connections from the local machine.}
   288 \PYG{o}{\PYGZlt{}}\PYG{n}{Policy} \PYG{n}{default}\PYG{o}{\PYGZgt{}}
   293 \PYG{o}{\PYGZlt{}}\PYG{n}{Policy} \PYG{n}{default}\PYG{o}{\PYGZgt{}}
   289   \PYG{o}{.}\PYG{o}{.}\PYG{o}{.} \PYG{c+c1}{\PYGZsh{} probably as in the original}
   294   \PYG{o}{.}\PYG{o}{.}\PYG{o}{.} \PYG{c+c1}{\PYGZsh{} probably as in the original}
   290 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Policy}\PYG{o}{\PYGZgt{}}
   295 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Policy}\PYG{o}{\PYGZgt{}}
   291 \end{sphinxVerbatim}
   296 \end{sphinxVerbatim}
   292 
   297 
   293 Now, you need to create a file system that will hold all CUPS printers, For example, the printers belonging to the logbooks \sphinxstyleemphasis{FEL/operating} and \sphinxstyleemphasis{FEL/installation} could be put in \sphinxcode{/usr/local/labfolder/printers/FEL}. Copy the lplisten script from the git repository \sphinxcode{https://github.molgen.mpg.de/weiher/elog2labfolder.git} to \sphinxcode{/usr/local/labfolder/printers/FEL/operating} and to \sphinxcode{.../FEL/installation}. Also, create a pipe that redirects the printer input to the lplisten script:
   298 Change the \sphinxstyleemphasis{Server Admin}’s e-mail address and the server that shall be listened to (see the \sphinxcode{Listen} statement). Set \sphinxcode{FileDevice Yes} in \sphinxcode{/etc/cups/cups-files.conf}. Now, create a directory where all printers will go, e.g. \sphinxcode{/usr/local/labfolder/printers}.
   294 
   299 
   295 \fvset{hllines={, ,}}%
   300 Get the package for creating new printers from git:
   296 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   301 
   297 /usr/local/labfolder/printers/FEL/operating\PYGZdl{} mkfifo prnt
   302 \fvset{hllines={, ,}}%
   298 \end{sphinxVerbatim}
   303 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   299 
   304 labfolder@lftest:\PYGZti{}\PYGZdl{} git clone https://github.molgen.mpg.de/weiher/cupsPrinters
   300 Adapt rights and ownership of lplisten and prnt:
   305 labfolder@lftest:\PYGZti{}\PYGZdl{} ls
   301 
   306 cupsPrinters  labfolder
   302 \fvset{hllines={, ,}}%
   307 \end{sphinxVerbatim}
   303 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   308 
   304 \PYGZdl{} chmod 744 lplisten
   309 The only file you need to adapt is \sphinxcode{newPrinter.sh}. It is not a must but it is suggested to name the printers like the projects. For example, the FEL projects \sphinxstyleemphasis{operating} and \sphinxstyleemphasis{installation} could be placed at \sphinxcode{.../printers/FEL/operating} and \sphinxcode{.../printers/FEL/installation}. Execute the script with sudo rights:
   305 \PYGZdl{} chmod 666 prnt
   310 
   306 \PYGZdl{} chown lp:lpadmin lplisten prnt
   311 \fvset{hllines={, ,}}%
   307 \end{sphinxVerbatim}
   312 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   308 
   313 labfolder@lftest:\PYGZti{}/cupsPrinters\PYGZdl{} sudo ./newPrinter.sh
   309 Add the labfolder user to the lpadmin group in /etc/group:
   314 \end{sphinxVerbatim}
   310 
   315 
   311 \fvset{hllines={, ,}}%
   316 To prevent \sphinxcode{DENIED} errors from apparmor install and set the following and restart the CUPS server:
   312 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   317 
   313 \PYG{n}{lpadmin}\PYG{p}{:}\PYG{n}{x}\PYG{p}{:}\PYG{l+m+mi}{115}\PYG{p}{:}\PYG{n}{labfolder}
   318 \fvset{hllines={, ,}}%
   314 \end{sphinxVerbatim}
   319 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   315 
   320 \PYGZdl{} sudo apt\PYGZhy{}get install apparmor\PYGZhy{}utils apparmor\PYGZhy{}profiles
   316 Now, create the CUPS printers via the web interface at \sphinxcode{http://lftest.rz-berlin.mpg.de:631/} (as configured in cupsd.conf). For example, the \sphinxstyleemphasis{operating} printer points at \sphinxcode{FEL/operating/prnt}. The ready configured printer looks like this in the web interface:
   321 \PYGZdl{} sudo aa\PYGZhy{}complain cupsd
   317 
   322 \PYGZdl{} sudo service cups restart
   318 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=1.000\linewidth]{{cups_print_operating}.png}\hspace*{\fill}}
   323 \end{sphinxVerbatim}
   319 
   324 
   320 To prevent \sphinxcode{DENIED} errors from apparmor install and set the following:
   325 In case you need to debug some logfiles can be found here: \sphinxstyleemphasis{/var/log/syslog}, \sphinxstyleemphasis{/var/log/cups/error\_log} and \sphinxstyleemphasis{/var/log/cups/acces\_log}
   321 
   326 
   322 \fvset{hllines={, ,}}%
   327 One last change is that you need to once add a user named \sphinxstyleemphasis{Printer Print} (firstname lastname) to the labfolder database. This can be done manually inside the DB by this command:
   323 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   328 
   324 \PYG{n}{sudo} \PYG{n}{apt}\PYG{o}{\PYGZhy{}}\PYG{n}{get} \PYG{n}{install} \PYG{n}{apparmor}\PYG{o}{\PYGZhy{}}\PYG{n}{utils} \PYG{n}{apparmor}\PYG{o}{\PYGZhy{}}\PYG{n}{profiles}
   329 \fvset{hllines={, ,}}%
   325 \PYG{n}{sudo} \PYG{n}{aa}\PYG{o}{\PYGZhy{}}\PYG{n}{complain} \PYG{n}{cupsd}
   330 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   326 \end{sphinxVerbatim}
   331 \PYGZdl{} mysql \PYGZhy{}u root \PYGZhy{}p
   327 
   332 Enter password:
   328 Restart the CUPS server:
   333 ...
   329 
   334 mysql\PYGZgt{} use labfolder;
   330 \fvset{hllines={, ,}}%
   335 mysql\PYGZgt{} INSERT INTO user (email, password, firstname, lastname, signupTimestamp, maxStorage) VALUES (\PYGZsq{}printer@fhi\PYGZhy{}berlin.mpg.de\PYGZsq{}, \PYGZsq{}91a13f2aba4a35b00c35dfacadd1d75f4a5171dfa7a465fca9c40e6b007ce982\PYGZsq{}, \PYGZsq{}Printer\PYGZsq{}, \PYGZsq{}Print\PYGZsq{}, \PYGZsq{}2018\PYGZhy{}03\PYGZhy{}21 10:54:00\PYGZsq{}, \PYGZsq{}10000000\PYGZsq{});
   331 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   336 \end{sphinxVerbatim}
   332 \PYGZdl{} service cupsd restart
   337 
   333 \end{sphinxVerbatim}
   338 
   334 
   339 \section{Printing to labfolder projects}
   335 Start the lplisten script in the background:
   340 \label{\detokenize{installation_cups:printing-to-labfolder-projects}}\label{\detokenize{installation_cups:section-cups-user}}
   336 
       
   337 \fvset{hllines={, ,}}%
       
   338 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   339 /usr/local/labfolder/printers/FEL/operating\PYGZdl{} ./lplisten \PYGZam{}
       
   340 \end{sphinxVerbatim}
       
   341 
       
   342 The last thing you need to do is to set up a printer \sphinxstyleemphasis{operating} on your local machine. In Ubuntu Gnome hit Alt+F2 keys and enter \sphinxcode{system-config-printer}. In this printer config interface add a new printer \sphinxstyleemphasis{operating} as follows:
   341 The last thing you need to do is to set up a printer \sphinxstyleemphasis{operating} on your local machine. In Ubuntu Gnome hit Alt+F2 keys and enter \sphinxcode{system-config-printer}. In this printer config interface add a new printer \sphinxstyleemphasis{operating} as follows:
   343 
   342 
   344 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer01}.png}\hspace*{\fill}}
   343 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer01}.png}\hspace*{\fill}}
   345 
   344 
   346 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer02}.png}\hspace*{\fill}}
   345 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer02}.png}\hspace*{\fill}}