
diff -r a21f3604f1db -r 523ca1dfd077 elog2labfolder/_build/latex/elog2labfolder.tex
--- a/elog2labfolder/_build/latex/elog2labfolder.tex	Wed Feb 07 16:53:37 2018 +0100
+++ b/elog2labfolder/_build/latex/elog2labfolder.tex	Tue Mar 27 16:07:14 2018 +0200
@@ -55,7 +55,7 @@
 
 
 \title{Labfolder at FHI Documentation}
-\date{Feb 07, 2018}
+\date{Mar 27, 2018}
 \release{1.0}
 \author{Stefan Weiher}
 \newcommand{\sphinxlogo}{\vbox{}}
@@ -200,14 +200,19 @@
 
 \chapter{Printing via CUPS and attaching files to labfolder logbooks}
 \label{\detokenize{installation_cups:printing-via-cups-and-attaching-files-to-labfolder-logbooks}}\label{\detokenize{installation_cups::doc}}
-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:
+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}}}}.
+
+
+\section{Set up CUPS as labfolder admin}
+\label{\detokenize{installation_cups:section-cups-admin}}\label{\detokenize{installation_cups:set-up-cups-as-labfolder-admin}}
+First, you need to install CUPS on the virtual machine that runs labfolder:
 
 \fvset{hllines={, ,}}%
 \begin{sphinxVerbatim}[commandchars=\\\{\}]
 \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}
 \end{sphinxVerbatim}
 
-Next, you need to configure \sphinxcode{/etc/cups/cupsd.conf}. This is how it looks like on \sphinxstyleemphasis{lftest}:
+Next, configure \sphinxcode{/etc/cups/cupsd.conf}:
 
 \fvset{hllines={, ,}}%
 \begin{sphinxVerbatim}[commandchars=\\\{\}]
@@ -224,7 +229,7 @@
 
 \PYG{c+c1}{\PYGZsh{} Administrator user group...}
 \PYG{n}{SystemGroup} \PYG{n}{lpadmin}
-\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}
+\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}
 
 \PYG{n}{HostNameLookups} \PYG{n}{On}
 \PYG{n}{ServerAlias} \PYG{o}{*}
@@ -290,55 +295,49 @@
 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Policy}\PYG{o}{\PYGZgt{}}
 \end{sphinxVerbatim}
 
-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:
+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}.
+
+Get the package for creating new printers from git:
 
 \fvset{hllines={, ,}}%
 \begin{sphinxVerbatim}[commandchars=\\\{\}]
-/usr/local/labfolder/printers/FEL/operating\PYGZdl{} mkfifo prnt
+labfolder@lftest:\PYGZti{}\PYGZdl{} git clone https://github.molgen.mpg.de/weiher/cupsPrinters
+labfolder@lftest:\PYGZti{}\PYGZdl{} ls
+cupsPrinters  labfolder
 \end{sphinxVerbatim}
 
-Adapt rights and ownership of lplisten and prnt:
+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:
 
 \fvset{hllines={, ,}}%
 \begin{sphinxVerbatim}[commandchars=\\\{\}]
-\PYGZdl{} chmod 744 lplisten
-\PYGZdl{} chmod 666 prnt
-\PYGZdl{} chown lp:lpadmin lplisten prnt
+labfolder@lftest:\PYGZti{}/cupsPrinters\PYGZdl{} sudo ./newPrinter.sh
 \end{sphinxVerbatim}
 
-Add the labfolder user to the lpadmin group in /etc/group:
+To prevent \sphinxcode{DENIED} errors from apparmor install and set the following and restart the CUPS server:
 
 \fvset{hllines={, ,}}%
 \begin{sphinxVerbatim}[commandchars=\\\{\}]
-\PYG{n}{lpadmin}\PYG{p}{:}\PYG{n}{x}\PYG{p}{:}\PYG{l+m+mi}{115}\PYG{p}{:}\PYG{n}{labfolder}
+\PYGZdl{} sudo apt\PYGZhy{}get install apparmor\PYGZhy{}utils apparmor\PYGZhy{}profiles
+\PYGZdl{} sudo aa\PYGZhy{}complain cupsd
+\PYGZdl{} sudo service cups restart
 \end{sphinxVerbatim}
 
-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:
+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}
 
-\noindent{\hspace*{\fill}\sphinxincludegraphics[width=1.000\linewidth]{{cups_print_operating}.png}\hspace*{\fill}}
-
-To prevent \sphinxcode{DENIED} errors from apparmor install and set the following:
+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:
 
 \fvset{hllines={, ,}}%
 \begin{sphinxVerbatim}[commandchars=\\\{\}]
-\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}
-\PYG{n}{sudo} \PYG{n}{aa}\PYG{o}{\PYGZhy{}}\PYG{n}{complain} \PYG{n}{cupsd}
+\PYGZdl{} mysql \PYGZhy{}u root \PYGZhy{}p
+Enter password:
+...
+mysql\PYGZgt{} use labfolder;
+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{});
 \end{sphinxVerbatim}
 
-Restart the CUPS server:
 
-\fvset{hllines={, ,}}%
-\begin{sphinxVerbatim}[commandchars=\\\{\}]
-\PYGZdl{} service cupsd restart
-\end{sphinxVerbatim}
-
-Start the lplisten script in the background:
-
-\fvset{hllines={, ,}}%
-\begin{sphinxVerbatim}[commandchars=\\\{\}]
-/usr/local/labfolder/printers/FEL/operating\PYGZdl{} ./lplisten \PYGZam{}
-\end{sphinxVerbatim}
-
+\section{Printing to labfolder projects}
+\label{\detokenize{installation_cups:printing-to-labfolder-projects}}\label{\detokenize{installation_cups:section-cups-user}}
 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:
 
 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer01}.png}\hspace*{\fill}}




