elog2labfolder/_build/latex/elog2labfolder.tex
changeset 18 57431f642e82
parent 15 523ca1dfd077
equal deleted inserted replaced
17:02a3741242b2 18:57431f642e82
    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{Mar 27, 2018}
    58 \date{Jun 04, 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
   196     \PYG{n}{ProxyPassReverse} \PYG{o}{/} \PYG{n}{http}\PYG{p}{:}\PYG{o}{/}\PYG{o}{/}\PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{l+m+mf}{138.230}\PYG{p}{:}\PYG{l+m+mi}{9091}\PYG{o}{/}
   196     \PYG{n}{ProxyPassReverse} \PYG{o}{/} \PYG{n}{http}\PYG{p}{:}\PYG{o}{/}\PYG{o}{/}\PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{l+m+mf}{138.230}\PYG{p}{:}\PYG{l+m+mi}{9091}\PYG{o}{/}
   197 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{VirtualHost}\PYG{o}{\PYGZgt{}}
   197 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{VirtualHost}\PYG{o}{\PYGZgt{}}
   198 \end{sphinxVerbatim}
   198 \end{sphinxVerbatim}
   199 
   199 
   200 
   200 
   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}}
       
   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:
       
   209 
       
   210 \fvset{hllines={, ,}}%
       
   211 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   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}
       
   213 \end{sphinxVerbatim}
       
   214 
       
   215 Next, configure \sphinxcode{/etc/cups/cupsd.conf}:
       
   216 
       
   217 \fvset{hllines={, ,}}%
       
   218 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   219 \PYG{c+c1}{\PYGZsh{} Sample configuration file for the CUPS scheduler.  See \PYGZdq{}man cupsd.conf\PYGZdq{} for a}
       
   220 \PYG{c+c1}{\PYGZsh{} complete description of this file.}
       
   221 
       
   222 \PYG{c+c1}{\PYGZsh{} Log general information in error\PYGZus{}log \PYGZhy{} change \PYGZdq{}warn\PYGZdq{} to \PYGZdq{}debug\PYGZdq{}}
       
   223 \PYG{c+c1}{\PYGZsh{} for troubleshooting...}
       
   224 \PYG{n}{LogLevel} \PYG{n}{debug}
       
   225 
       
   226 \PYG{c+c1}{\PYGZsh{} Deactivate CUPS\PYGZsq{} internal logrotating, as we provide a better one, especially}
       
   227 \PYG{c+c1}{\PYGZsh{} LogLevel debug2 gets usable now}
       
   228 \PYG{n}{MaxLogSize} \PYG{l+m+mi}{0}
       
   229 
       
   230 \PYG{c+c1}{\PYGZsh{} Administrator user group...}
       
   231 \PYG{n}{SystemGroup} \PYG{n}{lpadmin}
       
   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}
       
   233 
       
   234 \PYG{n}{HostNameLookups} \PYG{n}{On}
       
   235 \PYG{n}{ServerAlias} \PYG{o}{*}
       
   236 
       
   237 \PYG{c+c1}{\PYGZsh{} Only listen for connections from the local machine.}
       
   238 \PYG{n}{Listen} \PYG{n}{lftest}\PYG{o}{.}\PYG{n}{rz}\PYG{o}{\PYGZhy{}}\PYG{n}{berlin}\PYG{o}{.}\PYG{n}{mpg}\PYG{o}{.}\PYG{n}{de}\PYG{p}{:}\PYG{l+m+mi}{631}
       
   239 \PYG{n}{Listen} \PYG{o}{/}\PYG{n}{var}\PYG{o}{/}\PYG{n}{run}\PYG{o}{/}\PYG{n}{cups}\PYG{o}{/}\PYG{n}{cups}\PYG{o}{.}\PYG{n}{sock}
       
   240 
       
   241 \PYG{c+c1}{\PYGZsh{} Show shared printers on the local network.}
       
   242 \PYG{n}{Browsing} \PYG{n}{Off}
       
   243 \PYG{n}{BrowseOrder} \PYG{n}{allow}\PYG{p}{,}\PYG{n}{deny}
       
   244 \PYG{n}{BrowseAllow} \PYG{n+nb}{all}
       
   245 \PYG{n}{BrowseLocalProtocols} \PYG{n}{CUPS} \PYG{n}{dnssd}
       
   246 \PYG{n}{BrowseAddress} \PYG{n+nd}{@LOCAL}
       
   247 
       
   248 \PYG{c+c1}{\PYGZsh{} Default authentication type, when authentication is required...}
       
   249 \PYG{n}{DefaultAuthType} \PYG{n}{Basic}
       
   250 
       
   251 \PYG{c+c1}{\PYGZsh{} Web interface setting...}
       
   252 \PYG{n}{WebInterface} \PYG{n}{Yes}
       
   253 
       
   254 \PYG{c+c1}{\PYGZsh{} Restrict access to the server...}
       
   255 \PYG{o}{\PYGZlt{}}\PYG{n}{Location} \PYG{o}{/}\PYG{o}{\PYGZgt{}}
       
   256   \PYG{n}{Satisfy} \PYG{n}{All}
       
   257   \PYG{n}{Allow} \PYG{n}{localhost}
       
   258   \PYG{n}{Allow} \PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{o}{*}
       
   259   \PYG{n}{Allow} \PYG{l+m+mf}{172.16}\PYG{o}{.}\PYG{o}{*}
       
   260   \PYG{n}{Allow} \PYG{l+m+mf}{192.}\PYG{o}{*}
       
   261   \PYG{n}{Allow} \PYG{n+nb}{all}
       
   262   \PYG{c+c1}{\PYGZsh{} Allow shared printing and remote administration...}
       
   263   \PYG{n}{Order} \PYG{n}{allow}\PYG{p}{,}\PYG{n}{deny}
       
   264   \PYG{n}{Allow} \PYG{n+nb}{all}
       
   265 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Location}\PYG{o}{\PYGZgt{}}
       
   266 
       
   267 \PYG{c+c1}{\PYGZsh{} Restrict access to the admin pages...}
       
   268 \PYG{o}{\PYGZlt{}}\PYG{n}{Location} \PYG{o}{/}\PYG{n}{admin}\PYG{o}{\PYGZgt{}}
       
   269   \PYG{n}{Order} \PYG{n}{deny}\PYG{p}{,}\PYG{n}{allow}
       
   270   \PYG{n}{Satisfy} \PYG{n}{All}
       
   271   \PYG{n}{AuthType} \PYG{n}{Basic}
       
   272   \PYG{n}{Require} \PYG{n}{user} \PYG{n+nd}{@SYSTEM}
       
   273   \PYG{n}{Deny} \PYG{n}{All}
       
   274   \PYG{n}{Allow} \PYG{n}{localhost}
       
   275   \PYG{n}{Allow} \PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{o}{*}
       
   276   \PYG{n}{Allow} \PYG{l+m+mf}{172.16}\PYG{o}{.}\PYG{o}{*}
       
   277 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Location}\PYG{o}{\PYGZgt{}}
       
   278 
       
   279 \PYG{c+c1}{\PYGZsh{} Restrict access to configuration files...}
       
   280 \PYG{o}{\PYGZlt{}}\PYG{n}{Location} \PYG{o}{/}\PYG{n}{admin}\PYG{o}{/}\PYG{n}{conf}\PYG{o}{\PYGZgt{}}
       
   281   \PYG{n}{Order} \PYG{n}{deny}\PYG{p}{,}\PYG{n}{allow}
       
   282   \PYG{n}{AuthType} \PYG{n}{Default}
       
   283   \PYG{n}{Require} \PYG{n}{user} \PYG{n+nd}{@SYSTEM}
       
   284   \PYG{n}{Satisfy} \PYG{n}{All}
       
   285   \PYG{n}{Require} \PYG{n}{user} \PYG{n}{root}
       
   286   \PYG{n}{Deny} \PYG{n}{All}
       
   287   \PYG{n}{Allow} \PYG{l+m+mf}{127.0}\PYG{o}{.}\PYG{l+m+mf}{0.1}
       
   288   \PYG{n}{Allow} \PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{o}{*}
       
   289   \PYG{n}{Allow} \PYG{l+m+mf}{172.16}\PYG{o}{.}\PYG{o}{*}
       
   290 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Location}\PYG{o}{\PYGZgt{}}
       
   291 
       
   292 \PYG{c+c1}{\PYGZsh{} Set the default printer/job policies...}
       
   293 \PYG{o}{\PYGZlt{}}\PYG{n}{Policy} \PYG{n}{default}\PYG{o}{\PYGZgt{}}
       
   294   \PYG{o}{.}\PYG{o}{.}\PYG{o}{.} \PYG{c+c1}{\PYGZsh{} probably as in the original}
       
   295 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Policy}\PYG{o}{\PYGZgt{}}
       
   296 \end{sphinxVerbatim}
       
   297 
       
   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}.
       
   299 
       
   300 Get the package for creating new printers from git:
       
   301 
       
   302 \fvset{hllines={, ,}}%
       
   303 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   304 labfolder@lftest:\PYGZti{}\PYGZdl{} git clone https://github.molgen.mpg.de/weiher/cupsPrinters
       
   305 labfolder@lftest:\PYGZti{}\PYGZdl{} ls
       
   306 cupsPrinters  labfolder
       
   307 \end{sphinxVerbatim}
       
   308 
       
   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:
       
   310 
       
   311 \fvset{hllines={, ,}}%
       
   312 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   313 labfolder@lftest:\PYGZti{}/cupsPrinters\PYGZdl{} sudo ./newPrinter.sh
       
   314 \end{sphinxVerbatim}
       
   315 
       
   316 To prevent \sphinxcode{DENIED} errors from apparmor install and set the following and restart the CUPS server:
       
   317 
       
   318 \fvset{hllines={, ,}}%
       
   319 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   320 \PYGZdl{} sudo apt\PYGZhy{}get install apparmor\PYGZhy{}utils apparmor\PYGZhy{}profiles
       
   321 \PYGZdl{} sudo aa\PYGZhy{}complain cupsd
       
   322 \PYGZdl{} sudo service cups restart
       
   323 \end{sphinxVerbatim}
       
   324 
       
   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}
       
   326 
       
   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:
       
   328 
       
   329 \fvset{hllines={, ,}}%
       
   330 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   331 \PYGZdl{} mysql \PYGZhy{}u root \PYGZhy{}p
       
   332 Enter password:
       
   333 ...
       
   334 mysql\PYGZgt{} use labfolder;
       
   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{});
       
   336 \end{sphinxVerbatim}
       
   337 
       
   338 
       
   339 \section{Printing to labfolder projects}
       
   340 \label{\detokenize{installation_cups:printing-to-labfolder-projects}}\label{\detokenize{installation_cups:section-cups-user}}
       
   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:
       
   342 
       
   343 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer01}.png}\hspace*{\fill}}
       
   344 
       
   345 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer02}.png}\hspace*{\fill}}
       
   346 
       
   347 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer03}.png}\hspace*{\fill}}
       
   348 
       
   349 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer04}.png}\hspace*{\fill}}
       
   350 
       
   351 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer05}.png}\hspace*{\fill}}
       
   352 
       
   353 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer06}.png}\hspace*{\fill}}
       
   354 
       
   355 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer07}.png}\hspace*{\fill}}
       
   356 
       
   357 
       
   358 \chapter{Groups, ownership and sharing in labfolder}
   201 \chapter{Groups, ownership and sharing in labfolder}
   359 \label{\detokenize{groups:groups-ownership-and-sharing-in-labfolder}}\label{\detokenize{groups::doc}}
   202 \label{\detokenize{groups:groups-ownership-and-sharing-in-labfolder}}\label{\detokenize{groups::doc}}
   360 As labfolder user you can create groups (ultimately: group projects) and private projects. In \sphinxstyleemphasis{Manage \textgreater{} Projects} you see all projects that you own and that you are a member of.
   203 As labfolder user you can create groups (ultimately: group projects) and private projects. In \sphinxstyleemphasis{Manage \textgreater{} Projects} you see all projects that you own and that you are a member of.
   361 
   204 
   362 
   205 
   446 The \sphinxstylestrong{JSON export} is only useable via the API endpoint \sphinxcode{GET /entries}. However, at the moment the response only contains useful information such as dates and tags. The author name is hidden behind the author ID and the entry text content is completely missing.
   289 The \sphinxstylestrong{JSON export} is only useable via the API endpoint \sphinxcode{GET /entries}. However, at the moment the response only contains useful information such as dates and tags. The author name is hidden behind the author ID and the entry text content is completely missing.
   447 
   290 
   448 
   291 
   449 \chapter{Importing projects from e.g. the ELOGbook to Labfolder at the FHI}
   292 \chapter{Importing projects from e.g. the ELOGbook to Labfolder at the FHI}
   450 \label{\detokenize{importing_from_elog:importing-projects-from-e-g-the-elogbook-to-labfolder-at-the-fhi}}\label{\detokenize{importing_from_elog::doc}}
   293 \label{\detokenize{importing_from_elog:importing-projects-from-e-g-the-elogbook-to-labfolder-at-the-fhi}}\label{\detokenize{importing_from_elog::doc}}
       
   294 This is how you generally do it:
       
   295 
       
   296 \fvset{hllines={, ,}}%
       
   297 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   298 \PYG{l+m+mf}{1.} \PYG{n}{In} \PYG{n}{labfolder}\PYG{p}{,} \PYG{n}{create} \PYG{n}{a} \PYG{n}{new} \PYG{n}{group} \PYG{n}{project}\PYG{o}{.}
       
   299 \PYG{l+m+mf}{2.} \PYG{n}{Get} \PYG{n}{the} \PYG{n}{ELOG} \PYG{n}{logbook} \PYG{l+s+s2}{\PYGZdq{}}\PYG{l+s+s2}{operating}\PYG{l+s+s2}{\PYGZdq{}} \PYG{o+ow}{and} \PYG{n}{export} \PYG{n}{it} \PYG{k}{as} \PYG{n}{RAW}\PYG{o}{.} \PYG{n}{Remember} \PYG{n}{where} \PYG{n}{you}\PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{ve put the text file with the raw output and the directory with attachments files.}
       
   300 \PYG{l+m+mf}{3.} \PYG{n}{Only} \PYG{n}{once}\PYG{p}{:} \PYG{n}{Get} \PYG{n}{the} \PYG{n}{elog2labfolder} \PYG{n}{repository} \PYG{k+kn}{from} \PYG{n+nn}{github}\PYG{n+nn}{.}
       
   301 \PYG{l+m+mf}{4.} \PYG{n}{Adapt} \PYG{n}{elog2labfolder}\PYG{o}{.}\PYG{n}{py} \PYG{n}{to} \PYG{n}{your} \PYG{n}{needs}\PYG{o}{.} \PYG{n}{Specify} \PYG{n}{the} \PYG{n}{name} \PYG{n}{of} \PYG{n}{the} \PYG{n}{project} \PYG{n}{that} \PYG{n}{you} \PYG{n}{created} \PYG{n}{previously}\PYG{o}{.}
       
   302 \PYG{l+m+mf}{4.} \PYG{n}{Run} \PYG{n}{elog2labfolder}\PYG{o}{.}\PYG{n}{py}
       
   303 \end{sphinxVerbatim}
       
   304 
       
   305 These steps are explained in more detail in the following.
       
   306 
       
   307 
       
   308 \section{Creating a group project}
       
   309 \label{\detokenize{importing_from_elog:creating-a-group-project}}
       
   310 As the group admin (or one of the admins) in labfolder create a group project, for example, “operating” in a group named “FEL”. You are now the owner of this project. Make sure you don’t have several projects of the same name in one group.
       
   311 
       
   312 
       
   313 \section{Entries from ELOG}
       
   314 \label{\detokenize{importing_from_elog:entries-from-elog}}
   451 The ELOG entries of a certain project need to be exported as \sphinxstyleemphasis{Raw} which looks like this:
   315 The ELOG entries of a certain project need to be exported as \sphinxstyleemphasis{Raw} which looks like this:
   452 
   316 
   453 \fvset{hllines={, ,}}%
   317 \fvset{hllines={, ,}}%
   454 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   318 \begin{sphinxVerbatim}[commandchars=\\\{\}]
   455 \PYGZdl{}@MID@\PYGZdl{}: 12
   319 \PYGZdl{}@MID@\PYGZdl{}: 12
   487 \PYGZdl{} git clone https://github.molgen.mpg.de/weiher/elog2labfolder.git
   351 \PYGZdl{} git clone https://github.molgen.mpg.de/weiher/elog2labfolder.git
   488 \end{sphinxVerbatim}
   352 \end{sphinxVerbatim}
   489 
   353 
   490 The script \sphinxstyleemphasis{elog2labfolder.py} is meant to be executed from remote, that is, not on the machine on which labfolder is running. A prerequisit is the python MySQLDB package because for a few methods the labfolder API cannot be used, instead, direct manipulation of the labfolder MySQL database is needed. The actual labfolder API is applied in the methodes collected in \sphinxstyleemphasis{myPythonAPIv1.py} and \sphinxstyleemphasis{myPythonAPIv2.py}. Mostly, API version 2 is used but adding text at the end of an entry can only be accomplished by using the version 1 API call. \sphinxstyleemphasis{getListOfAuthors.py} gives you a list of all authors that are mentioned in a raw ELOG export file.
   354 The script \sphinxstyleemphasis{elog2labfolder.py} is meant to be executed from remote, that is, not on the machine on which labfolder is running. A prerequisit is the python MySQLDB package because for a few methods the labfolder API cannot be used, instead, direct manipulation of the labfolder MySQL database is needed. The actual labfolder API is applied in the methodes collected in \sphinxstyleemphasis{myPythonAPIv1.py} and \sphinxstyleemphasis{myPythonAPIv2.py}. Mostly, API version 2 is used but adding text at the end of an entry can only be accomplished by using the version 1 API call. \sphinxstyleemphasis{getListOfAuthors.py} gives you a list of all authors that are mentioned in a raw ELOG export file.
   491 
   355 
       
   356 To finally import an ELOG logbook to a labfolder project you need to run \sphinxcode{\$ python elog2labfolder.py}. Prior to this you need to make some changes to the header of the file, that is, these lines:
       
   357 
       
   358 \fvset{hllines={, ,}}%
       
   359 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   360 \PYG{c+c1}{\PYGZsh{}\PYGZsh{}\PYGZsh{} Set the hostname}
       
   361 \PYG{c+c1}{\PYGZsh{}hostname = \PYGZsq{}lftest\PYGZsq{}}
       
   362 \PYG{n}{hostname} \PYG{o}{=} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{labfolder}\PYG{l+s+s1}{\PYGZsq{}}
       
   363 
       
   364 \PYG{k}{if} \PYG{n}{hostname} \PYG{o}{==} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{lftest}\PYG{l+s+s1}{\PYGZsq{}}\PYG{p}{:}
       
   365     \PYG{n}{server} \PYG{o}{=} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{http://}\PYG{l+s+s1}{\PYGZsq{}} \PYG{o}{+} \PYG{n}{hostname} \PYG{o}{+} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{.rz\PYGZhy{}berlin.mpg.de:9091}\PYG{l+s+s1}{\PYGZsq{}}
       
   366 \PYG{k}{elif} \PYG{n}{hostname} \PYG{o}{==} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{labfolder}\PYG{l+s+s1}{\PYGZsq{}}\PYG{p}{:}
       
   367     \PYG{n}{server} \PYG{o}{=} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{https://}\PYG{l+s+s1}{\PYGZsq{}} \PYG{o}{+} \PYG{n}{hostname} \PYG{o}{+} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{.rz\PYGZhy{}berlin.mpg.de:9091}\PYG{l+s+s1}{\PYGZsq{}}
       
   368 
       
   369 \PYG{c+c1}{\PYGZsh{}\PYGZsh{}\PYGZsh{} The entries will be created using the following labfolder account which specifies the author of the entry. During the creation process, however, the entry\PYGZsq{}s author ID will be changed to the real          author\PYGZsq{}s ID if the real author is already contained in the user table of the labfolder DB.}
       
   370 \PYG{n}{email} \PYG{o}{=} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{weiher@fhi\PYGZhy{}berlin.mpg.de}\PYG{l+s+s1}{\PYGZsq{}}
       
   371 \PYG{n}{password} \PYG{o}{=} \PYG{n}{getpass}\PYG{o}{.}\PYG{n}{getpass}\PYG{p}{(}\PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{Enter the labfolder password associated with }\PYG{l+s+s1}{\PYGZsq{}} \PYG{o}{+} \PYG{n}{emailAddress}\PYG{o}{+}\PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{: }\PYG{l+s+s1}{\PYGZsq{}}\PYG{p}{)}
       
   372 
       
   373 \PYG{c+c1}{\PYGZsh{}\PYGZsh{}\PYGZsh{} Specify the absolute path to the raw ELOG export file.}
       
   374 \PYG{n}{elogExportFile} \PYG{o}{=} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{/home/stefan/Dokumente/labfolder/OperatingLogbook\PYGZus{}exportRaw\PYGZus{}ORIGINAL.txt}\PYG{l+s+s1}{\PYGZsq{}}
       
   375 
       
   376 \PYG{c+c1}{\PYGZsh{}\PYGZsh{}\PYGZsh{} Full path to where the attachments of the logbook to be imported are stored:}
       
   377 \PYG{n}{attachmentsDirectory} \PYG{o}{=} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{/home/stefan/Dokumente/labfolder/Operating/}\PYG{l+s+s1}{\PYGZsq{}}
       
   378 
       
   379 \PYG{c+c1}{\PYGZsh{}\PYGZsh{}\PYGZsh{} Project name in labfolder}
       
   380 \PYG{n}{projectName} \PYG{o}{=} \PYG{l+s+s1}{\PYGZsq{}}\PYG{l+s+s1}{operating}\PYG{l+s+s1}{\PYGZsq{}}
       
   381 \end{sphinxVerbatim}
       
   382 
   492 
   383 
   493 \section{Alternatives to manipulating the labfolder DB on MySQL level}
   384 \section{Alternatives to manipulating the labfolder DB on MySQL level}
   494 \label{\detokenize{importing_from_elog:alternatives-to-manipulating-the-labfolder-db-on-mysql-level}}
   385 \label{\detokenize{importing_from_elog:alternatives-to-manipulating-the-labfolder-db-on-mysql-level}}
   495 As mentioned previously: a few methods in the python API use a direct manipulation of the labfolder DB via MySQL queries. These methods are:
   386 As mentioned previously: a few methods in the python API use a direct manipulation of the labfolder DB via MySQL queries. These methods are:
   496 \begin{itemize}
   387 \begin{itemize}
   517 Date and time: Since you cannot change creation and modification time stamp of an entry via the API you could instead create custom dates during the import of an entry. The original entry creation timestamp could be “Original entry creation” followed by the creation time and date of the import. All entries can be filtered and searched by the custom dates.
   408 Date and time: Since you cannot change creation and modification time stamp of an entry via the API you could instead create custom dates during the import of an entry. The original entry creation timestamp could be “Original entry creation” followed by the creation time and date of the import. All entries can be filtered and searched by the custom dates.
   518 
   409 
   519 \end{itemize}
   410 \end{itemize}
   520 
   411 
   521 
   412 
       
   413 \chapter{Printing via CUPS and attaching files to labfolder logbooks}
       
   414 \label{\detokenize{installation_cups:printing-via-cups-and-attaching-files-to-labfolder-logbooks}}\label{\detokenize{installation_cups::doc}}
       
   415 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}}}}.
       
   416 
       
   417 
       
   418 \section{Set up CUPS as labfolder admin}
       
   419 \label{\detokenize{installation_cups:section-cups-admin}}\label{\detokenize{installation_cups:set-up-cups-as-labfolder-admin}}
       
   420 First, you need to install CUPS on the virtual machine that runs labfolder:
       
   421 
       
   422 \fvset{hllines={, ,}}%
       
   423 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   424 \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}
       
   425 \end{sphinxVerbatim}
       
   426 
       
   427 Next, configure \sphinxcode{/etc/cups/cupsd.conf}:
       
   428 
       
   429 \fvset{hllines={, ,}}%
       
   430 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   431 \PYG{c+c1}{\PYGZsh{} Sample configuration file for the CUPS scheduler.  See \PYGZdq{}man cupsd.conf\PYGZdq{} for a}
       
   432 \PYG{c+c1}{\PYGZsh{} complete description of this file.}
       
   433 
       
   434 \PYG{c+c1}{\PYGZsh{} Log general information in error\PYGZus{}log \PYGZhy{} change \PYGZdq{}warn\PYGZdq{} to \PYGZdq{}debug\PYGZdq{}}
       
   435 \PYG{c+c1}{\PYGZsh{} for troubleshooting...}
       
   436 \PYG{n}{LogLevel} \PYG{n}{debug}
       
   437 
       
   438 \PYG{c+c1}{\PYGZsh{} Deactivate CUPS\PYGZsq{} internal logrotating, as we provide a better one, especially}
       
   439 \PYG{c+c1}{\PYGZsh{} LogLevel debug2 gets usable now}
       
   440 \PYG{n}{MaxLogSize} \PYG{l+m+mi}{0}
       
   441 
       
   442 \PYG{c+c1}{\PYGZsh{} Administrator user group...}
       
   443 \PYG{n}{SystemGroup} \PYG{n}{lpadmin}
       
   444 \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}
       
   445 
       
   446 \PYG{n}{HostNameLookups} \PYG{n}{On}
       
   447 \PYG{n}{ServerAlias} \PYG{o}{*}
       
   448 
       
   449 \PYG{c+c1}{\PYGZsh{} Only listen for connections from the local machine.}
       
   450 \PYG{n}{Listen} \PYG{n}{lftest}\PYG{o}{.}\PYG{n}{rz}\PYG{o}{\PYGZhy{}}\PYG{n}{berlin}\PYG{o}{.}\PYG{n}{mpg}\PYG{o}{.}\PYG{n}{de}\PYG{p}{:}\PYG{l+m+mi}{631}
       
   451 \PYG{n}{Listen} \PYG{o}{/}\PYG{n}{var}\PYG{o}{/}\PYG{n}{run}\PYG{o}{/}\PYG{n}{cups}\PYG{o}{/}\PYG{n}{cups}\PYG{o}{.}\PYG{n}{sock}
       
   452 
       
   453 \PYG{c+c1}{\PYGZsh{} Show shared printers on the local network.}
       
   454 \PYG{n}{Browsing} \PYG{n}{Off}
       
   455 \PYG{n}{BrowseOrder} \PYG{n}{allow}\PYG{p}{,}\PYG{n}{deny}
       
   456 \PYG{n}{BrowseAllow} \PYG{n+nb}{all}
       
   457 \PYG{n}{BrowseLocalProtocols} \PYG{n}{CUPS} \PYG{n}{dnssd}
       
   458 \PYG{n}{BrowseAddress} \PYG{n+nd}{@LOCAL}
       
   459 
       
   460 \PYG{c+c1}{\PYGZsh{} Default authentication type, when authentication is required...}
       
   461 \PYG{n}{DefaultAuthType} \PYG{n}{Basic}
       
   462 
       
   463 \PYG{c+c1}{\PYGZsh{} Web interface setting...}
       
   464 \PYG{n}{WebInterface} \PYG{n}{Yes}
       
   465 
       
   466 \PYG{c+c1}{\PYGZsh{} Restrict access to the server...}
       
   467 \PYG{o}{\PYGZlt{}}\PYG{n}{Location} \PYG{o}{/}\PYG{o}{\PYGZgt{}}
       
   468   \PYG{n}{Satisfy} \PYG{n}{All}
       
   469   \PYG{n}{Allow} \PYG{n}{localhost}
       
   470   \PYG{n}{Allow} \PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{o}{*}
       
   471   \PYG{n}{Allow} \PYG{l+m+mf}{172.16}\PYG{o}{.}\PYG{o}{*}
       
   472   \PYG{n}{Allow} \PYG{l+m+mf}{192.}\PYG{o}{*}
       
   473   \PYG{n}{Allow} \PYG{n+nb}{all}
       
   474   \PYG{c+c1}{\PYGZsh{} Allow shared printing and remote administration...}
       
   475   \PYG{n}{Order} \PYG{n}{allow}\PYG{p}{,}\PYG{n}{deny}
       
   476   \PYG{n}{Allow} \PYG{n+nb}{all}
       
   477 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Location}\PYG{o}{\PYGZgt{}}
       
   478 
       
   479 \PYG{c+c1}{\PYGZsh{} Restrict access to the admin pages...}
       
   480 \PYG{o}{\PYGZlt{}}\PYG{n}{Location} \PYG{o}{/}\PYG{n}{admin}\PYG{o}{\PYGZgt{}}
       
   481   \PYG{n}{Order} \PYG{n}{deny}\PYG{p}{,}\PYG{n}{allow}
       
   482   \PYG{n}{Satisfy} \PYG{n}{All}
       
   483   \PYG{n}{AuthType} \PYG{n}{Basic}
       
   484   \PYG{n}{Require} \PYG{n}{user} \PYG{n+nd}{@SYSTEM}
       
   485   \PYG{n}{Deny} \PYG{n}{All}
       
   486   \PYG{n}{Allow} \PYG{n}{localhost}
       
   487   \PYG{n}{Allow} \PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{o}{*}
       
   488   \PYG{n}{Allow} \PYG{l+m+mf}{172.16}\PYG{o}{.}\PYG{o}{*}
       
   489 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Location}\PYG{o}{\PYGZgt{}}
       
   490 
       
   491 \PYG{c+c1}{\PYGZsh{} Restrict access to configuration files...}
       
   492 \PYG{o}{\PYGZlt{}}\PYG{n}{Location} \PYG{o}{/}\PYG{n}{admin}\PYG{o}{/}\PYG{n}{conf}\PYG{o}{\PYGZgt{}}
       
   493   \PYG{n}{Order} \PYG{n}{deny}\PYG{p}{,}\PYG{n}{allow}
       
   494   \PYG{n}{AuthType} \PYG{n}{Default}
       
   495   \PYG{n}{Require} \PYG{n}{user} \PYG{n+nd}{@SYSTEM}
       
   496   \PYG{n}{Satisfy} \PYG{n}{All}
       
   497   \PYG{n}{Require} \PYG{n}{user} \PYG{n}{root}
       
   498   \PYG{n}{Deny} \PYG{n}{All}
       
   499   \PYG{n}{Allow} \PYG{l+m+mf}{127.0}\PYG{o}{.}\PYG{l+m+mf}{0.1}
       
   500   \PYG{n}{Allow} \PYG{l+m+mf}{141.14}\PYG{o}{.}\PYG{o}{*}
       
   501   \PYG{n}{Allow} \PYG{l+m+mf}{172.16}\PYG{o}{.}\PYG{o}{*}
       
   502 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Location}\PYG{o}{\PYGZgt{}}
       
   503 
       
   504 \PYG{c+c1}{\PYGZsh{} Set the default printer/job policies...}
       
   505 \PYG{o}{\PYGZlt{}}\PYG{n}{Policy} \PYG{n}{default}\PYG{o}{\PYGZgt{}}
       
   506   \PYG{o}{.}\PYG{o}{.}\PYG{o}{.} \PYG{c+c1}{\PYGZsh{} probably as in the original}
       
   507 \PYG{o}{\PYGZlt{}}\PYG{o}{/}\PYG{n}{Policy}\PYG{o}{\PYGZgt{}}
       
   508 \end{sphinxVerbatim}
       
   509 
       
   510 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}.
       
   511 
       
   512 Get the package for creating new printers from git:
       
   513 
       
   514 \fvset{hllines={, ,}}%
       
   515 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   516 labfolder@lftest:\PYGZti{}\PYGZdl{} git clone https://github.molgen.mpg.de/weiher/cupsPrinters
       
   517 labfolder@lftest:\PYGZti{}\PYGZdl{} ls
       
   518 cupsPrinters  labfolder
       
   519 \end{sphinxVerbatim}
       
   520 
       
   521 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:
       
   522 
       
   523 \fvset{hllines={, ,}}%
       
   524 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   525 labfolder@lftest:\PYGZti{}/cupsPrinters\PYGZdl{} sudo ./newPrinter.sh
       
   526 \end{sphinxVerbatim}
       
   527 
       
   528 To prevent \sphinxcode{DENIED} errors from apparmor install and set the following and restart the CUPS server:
       
   529 
       
   530 \fvset{hllines={, ,}}%
       
   531 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   532 \PYGZdl{} sudo apt\PYGZhy{}get install apparmor\PYGZhy{}utils apparmor\PYGZhy{}profiles
       
   533 \PYGZdl{} sudo aa\PYGZhy{}complain cupsd
       
   534 \PYGZdl{} sudo service cups restart
       
   535 \end{sphinxVerbatim}
       
   536 
       
   537 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}
       
   538 
       
   539 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:
       
   540 
       
   541 \fvset{hllines={, ,}}%
       
   542 \begin{sphinxVerbatim}[commandchars=\\\{\}]
       
   543 \PYGZdl{} mysql \PYGZhy{}u root \PYGZhy{}p
       
   544 Enter password:
       
   545 ...
       
   546 mysql\PYGZgt{} use labfolder;
       
   547 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{});
       
   548 \end{sphinxVerbatim}
       
   549 
       
   550 Das Passwort steht für “test1234”. Der entsprechende Hash-Wert im MySQL-Kommando wurde von Florian Hauer (labfolder) erstellt.
       
   551 
       
   552 
       
   553 \section{Printing to labfolder projects}
       
   554 \label{\detokenize{installation_cups:printing-to-labfolder-projects}}\label{\detokenize{installation_cups:section-cups-user}}
       
   555 The last thing you need to do is to set up a printer, for example, \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:
       
   556 
       
   557 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer01}.png}\hspace*{\fill}}
       
   558 
       
   559 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer02}.png}\hspace*{\fill}}
       
   560 
       
   561 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer03}.png}\hspace*{\fill}}
       
   562 
       
   563 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer04}.png}\hspace*{\fill}}
       
   564 
       
   565 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer05}.png}\hspace*{\fill}}
       
   566 
       
   567 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer06}.png}\hspace*{\fill}}
       
   568 
       
   569 \noindent{\hspace*{\fill}\sphinxincludegraphics[width=0.700\linewidth]{{create_local_printer07}.png}\hspace*{\fill}}
       
   570 
       
   571 Now, just select this printer when printing a webpage or a picture to a labfolder project.
       
   572 
       
   573 
   522 
   574 
   523 \renewcommand{\indexname}{Index}
   575 \renewcommand{\indexname}{Index}
   524 \printindex
   576 \printindex
   525 \end{document}
   577 \end{document}