#!/bin/bash # Install BibGlimpse on Linux # (c) Thomas Tuechler 2008 # Define BibGlimpse installation path WG2PRE="$HOME/BibGlimpse"; # Install Apache locally ... LOCAPA='Y'; # [Y/N] # ... OR use an existing Apache APSERVERURL="your.server.cc"; APSERVERPORT="4080"; APHOME="/usr/lib/apache"; APHTTPDCONF="$APHOME/conf/httpd.conf"; APHTDOCSLOC="$APHOME/htdocs"; APCGILOC="$APHOME/cgi-bin"; APCGIWEB="cgi-bin"; APWEBUSER="nobody"; # Output verbosity V=''; # '' or '-v' # No changes required below this line ####################################################################### WG2TAR=`pwd`; WG2NAM="BibGlimpse"; WG2DIR="$WG2PRE/$WG2NAM"; WG2GLI="$WG2PRE/$WG2NAM/glimpse"; WG2APA="$WG2PRE/$WG2NAM/apache"; WG2HOM="$WG2PRE/$WG2NAM/wg2"; WG2PRT="$WG2PRE/$WG2NAM/prints"; WG2LIB="$WG2HOM"; echo ""; echo "CHECKING REQUIREMENTS"; echo "----------------------------------------------------------------"; echo ""; # check shell commands WHICHBASH=`which bash`; if [ ! -x "$WHICHBASH" ]; then echo "You need to install 'bash' first..."; exit; fi WHICHGCC=`which gcc`; if [ ! -x "$WHICHGCC" ]; then echo "You need to install 'gcc' first..."; exit; fi WHICHFLEX=`which flex`; if [ ! -x "$WHICHFLEX" ]; then echo "You need to install 'flex' first..."; exit; fi WHICHMAKE=`which make`; if [ ! -x "$WHICHMAKE" ]; then echo "You need to install 'make' first..."; exit; fi WHICHSED=`which sed`; if [ ! -x "$WHICHSED" ]; then echo "You need to install the bash command 'sed' first..."; exit; fi WHICHAWK=`which awk`; if [ ! -x "$WHICHAWK" ]; then echo "You need to install 'awk' first..."; exit; fi WHICHSTAT=`which stat`; if [ ! -x "$WHICHSTAT" ]; then echo "You need to install the bash command 'stat' first..."; exit; fi WHICHMD5SUM=`which md5sum`; if [ ! -x "$WHICHMD5SUM" ]; then echo "You need to install the bash command 'md5sum' first..."; exit; fi WHICHPERL=`which perl`; if [ ! -x "$WHICHPERL" ]; then echo "You need to install 'perl' first..."; exit; else perl wrCheckPerl.pl || exit; fi WHICHRSYNC=`which rsync`; if [ ! -x "$WHICHRSYNC" ]; then echo "You need to install 'rsync' first..."; exit; fi WHICHPDFTOTEXT=`which pdftotext`; if [ ! -x "$WHICHPDFTOTEXT" ]; then echo "You need to install 'pdftotext' first..."; exit; fi # check and create directories if [ -d "$WG2PRE" ]; then echo "$WG2PRE already exists. Type 'Y' to remove..."; read goon; if [ "$goon" != 'Y' ]; then echo "Leaving BibGlimpse.SETUP without anything done..."; exit; else echo "Removing directory..."; rm -rf "$WG2PRE"; fi fi if [ ! -w "$WG2TAR" ]; then echo "You need to have write permission in $WG2TAR"; exit; fi mkdir $V "$WG2PRE" || exit; mkdir $V "$WG2DIR" || exit; mkdir $V "$WG2GLI" || exit; mkdir $V "$WG2APA" || exit; mkdir $V "$WG2PRT" || exit; cp $V "$WG2TAR/prints/"*.pdf "$WG2PRT/"; # check for glimpse WHICHGLIMPSE=`which glimpse`; if [ ! -x "$WHICHGLIMPSE" ]; then echo ""; echo "INSTALLING GLIMPSE"; echo "----------------------------------------------------------------"; echo ""; # install glimpse echo "Installing glimpse..."; cd "$WG2TAR"/glimpse || exit; echo "Unpacking glimpse sources..."; tar -xzf "$WG2TAR"/glimpse/glimpse-latest.tar.gz || exit; cd "$WG2TAR"/glimpse/glimpse-4.18.5 || exit; ./configure --prefix="$WG2GLI" --with-file-end-mark='\t' --enable-structured-queries | tee glimpse_configure.log; make | tee glimpse_make.log; make install | tee glimpse_make_install.log; # check glimpse installation if [ ! -x "$WG2GLI"/bin/glimpse ]; then echo "Installing glimpse failed."; echo "Check log files in $WG2TAR/glimpse/glimpse-4.18.5"; exit; fi if [ ! -x "$WG2GLI"/bin/glimpseindex ]; then echo "Installing glimpseindex failed."; echo "Check log files in $WG2TAR/glimpse/glimpse-4.18.5"; exit; else echo "Glimpse installation looks good."; LOCGLI='Y'; fi else # make sure that Glimpse is configured with the following two flags: echo "Glimpse is already installed on you system."; echo "Are you sure that glimpse was configured with" echo "the following two flags:"; echo ""; echo " ./configure --with-file-end-mark='\t'"; echo " --enable-structured-queries;"; echo ""; echo "If not, please recompile glimpse first,"; echo "else press enter to continue..."; read goon; fi # local apache if [ $LOCAPA = 'Y' ]; then echo ""; echo "LOCAL APACHE 2.2.9 INSTALLATION"; echo "----------------------------------------------------------------"; echo ""; # install apache echo "Installing Apache locally..."; cd "$WG2APA" || exit; echo "Unpacking Apache sources..."; tar -xzf "$WG2TAR"/apache/httpd-2.2.9.tar.gz || exit; cd httpd-2.2.9 || exit; ./configure --prefix="$WG2APA" | tee apache_configure.log; make | tee apache_make.log; make install | tee apache_make_install.log; # start and test apache on port 4080 echo "Starting Apache..."; cd "$WG2APA" || exit; mv $V conf/httpd.conf conf/old.httpd.conf; sed -e "s^Listen 80^Listen 4080^" < conf/old.httpd.conf > conf/httpd.conf; ./bin/apachectl -k start; echo "Open a browser and try if the site below works:"; echo "http://localhost:4080/"; echo ""; echo "Press enter if 'It works!'"; read goon; # define Apache ... APSERVERURL="localhost"; APSERVERPORT="4080"; APHOME="$WG2APA"; APHTTPDCONF="$APHOME/conf/httpd.conf"; APHTDOCSLOC="$APHOME/htdocs"; APCGILOC="$APHOME/cgi-bin"; APCGIWEB="cgi-bin"; APWEBUSER=`whoami`; fi # link prints into htdocs echo "Linking $WG2PRT folder into htdocs..."; cd "$APHTDOCSLOC" || exit; ln -s "$WG2PRT" || exit; echo ""; echo "INSTALLING WEBGLIMPSE"; echo "----------------------------------------------------------------"; echo ""; # create file with wg options # (if glimpse is already installed two \n less and no $WG2GLI) cd "$WG2TAR" || exit; if [ $LOCGLI = 'Y' ]; then cat > "$WG2TAR/wgInput.txt" << EOF $WG2HOM $WG2GLI/bin $APHTTPDCONF $APSERVERURL $APHTDOCSLOC $WG2HOM/archives $APCGILOC/$WG2NAM $APCGIWEB/$WG2NAM $APWEBUSER N $WG2HOM N Y Y linux Y admin admin N N EOF else cat > "$WG2TAR/wgInput.txt" << EOF $WG2HOM $APHTTPDCONF $APSERVERURL $APHTDOCSLOC $WG2HOM/archives $APCGILOC/$WG2NAM $APCGIWEB/$WG2NAM $APWEBUSER N $WG2HOM N Y Y linux Y admin admin N N EOF fi # run wgInstall echo "Setting up Webglimpse via $WG2TAR/wginstall..."; echo "Options used and logfile of setup:" ; echo "$WG2TAR"/wgInput.txt; echo "$WG2TAR"/wgInput.log; echo ""; if [ -s "$WG2TAR"/wgInput.txt ]; then cat "$WG2TAR"/wgInput.txt | perl "$WG2TAR"/wginstall.pl | tee "$WG2TAR"/wgInput.log; fi echo "Installed Webglimpse."; echo ""; echo "Open a browser and try if the site below opens,"; echo "but do NOT yet configure anything:"; echo "http://$APSERVERURL:$APSERVERPORT/$APCGIWEB/$WG2NAM/wgarcmin.cgi"; echo ""; echo "Press enter if you get the Webglimpse Admin interface."; read goon; # Configures BibGlimpse for running WebGlimpse installations echo ""; echo "ADAPTING FOR BIBGLIMPSE"; echo "----------------------------------------------------------------"; echo ""; # 0) Glimpse installation # ----------------------------------------------------------------------------- # make sure that WebGlimpse was successfully installed: echo ""; echo "Are you sure that WebGlimpse is successfully installed and that"; echo "there are currently no archives configured?"; echo ""; echo "If not, please make sure the above is the case,"; echo "else press enter to continue..."; read goon; # 1) getting the paths # ----------------------------------------------------------------------------- # getting and checking the WG2LIB installation path while [ ! -s "$WG2LIB"/lib/wrMedline.pl ]; do echo "Please specify the path of the Webglimpse installation (/usr/local/lib/wg2):"; read WG2LIB; if [ ! -s "$WG2LIB"/lib/wrMedline.pl ]; then echo "'$WG2LIB' does not contain the BibGlimpse modules."; fi done; # extract rest from wgHeader.pm WG2HPM=$WG2LIB/"lib/wgHeader.pm"; # check the lib path WG2HOM=`grep '$WGHOME = .*' "$WG2HPM"`; WG2HOM=${WG2HOM#*\"}; WG2HOM=${WG2HOM%\"*}; if [ ! "$WG2LIB" = "$WG2HOM" ]; then echo "The Webglimpse home directory you specified, $WG2LIB, is incorrect."; exit; fi # find the cgi path WG2CGI=`grep '$CGIBIN_DIR = .*' "$WG2HPM"`; WG2CGI=${WG2CGI#*\"}; WG2CGI=${WG2CGI%\"*}; # find the archive path WG2ARC=`grep '$WGARCHIVE_DIR = .*' "$WG2HPM"`; WG2ARC=${WG2ARC#*\"}; WG2ARC=${WG2ARC%\"*}; # find the standard bin path USRBIN=`grep '$CAT = .*' "$WG2HPM"`; USRBIN=${USRBIN#*\"}; USRBIN=${USRBIN%/cat\"*}; # checking the WG2CGI path if [ ! -s "$WG2CGI"/wrrepos.cgi ]; then while [ ! -s "$WG2CGI"/wrrepos.cgi ]; do echo "Please specify the cgi-bin path (/usr/local/lib/apache/cgi-bin):"; read WG2CGI; if [ ! -s "$WG2CGI"/wrrepos.cgi ]; then echo "'$WG2CGI' does not contain the BibGlimpse modules."; fi done; fi # checking the WG2ARC path if [ ! -d "$WG2ARC" ]; then while [ ! -d "$WG2ARC" ] && [ -z "$WG2ARC" ]; do echo "Please specify the archive path (/usr/local/lib/apache/wg2/archives):"; read WG2ARC; if [ ! -d "$WG2ARC" ]; then echo "'$WG2ARC' is not a directory."; fi done; fi # checking the USRBIN path if [ ! -d "$USRBIN" ]; then while [ ! -d "$USRBIN" ] && [ -z "$USRBIN" ]; do echo "Please specify the bin path (/usr/local/bin):"; read USRBIN; if [ ! -d "$USRBIN" ]; then echo "'$USRBIN' is not a directory."; fi done; fi # 2) $WG/lib/(wr)usexpdf.sh # ----------------------------------------------------------------------------- # use the advanced pdf filtering tool wrusexpdf.sh instead of the old one # and include the correct binaries path for pdftotext, md5sum etc. echo ""; echo "Including the special PDF filter 'wrusexpdf.sh'..."; mv $V "$WG2LIB"/lib/usexpdf.sh "$WG2LIB"/lib/old.usexpdf.sh; sed "s^export PATH\=\/usr\/local\/bin\:\$PATH\;^export PATH\=$USRBIN\:\$PATH\;^" < "$WG2LIB"/lib/wrusexpdf.sh > "$WG2LIB"/lib/usexpdf.sh; [ -s "$WG2LIB"/lib/usexpdf.sh ] && rm $V "$WG2LIB"/lib/wrusexpdf.sh; chmod +x "$WG2LIB"/lib/usexpdf.sh; # 3) $WG/templates/.glimpse_filters # ----------------------------------------------------------------------------- # add the paths to usexpdf.sh to the .glimpse_filters template. this will # make the program index pdf files as well. echo "Setting the '.glimpse_filters' to use 'usexpdf.sh'..."; echo -e "*.pdf\t|WGHOME|/lib/usexpdf.sh\n*.PDF\t|WGHOME|/lib/usexpdf.sh" >> "$WG2LIB"/templates/.glimpse_filters; # 4) $WG/dist/wgfilter-index # ----------------------------------------------------------------------------- # adapt this template file such that it accepts *.pdf's by replacing and adding echo "Setting the 'wgfilter-index' to allow PDFs..."; mv $V "$WG2LIB"/dist/wgfilter-index "$WG2LIB"/dist/old.wgfilter-index; sed -e "s^Deny \\\\.pdf\\$^Allow \\\\.pdf\\$\nAllow \\\\.PDF\\$^" -e "s^Allow \\\\..?html?\\$^Deny \\\\.s?html?\\$^" < "$WG2LIB"/dist/old.wgfilter-index > "$WG2LIB"/dist/wgfilter-index; echo -e "Deny \.pl$\nDeny \.sh$\nDeny \.tmp$\nDeny \.ag\.\nDeny \.bib\$\nDeny \.medline\$\nDeny \.medl\$\nDeny \.suppl\$\nDeny \.pubmed\$\nDeny \.anno\$\nDeny \.htaccess\nDeny README\.txt" >> "$WG2LIB"/dist/wgfilter-index; # 5) $WG/templates/wgreindex # ----------------------------------------------------------------------------- # enable the glimpseindex building with structured fields with -s and -z flag: echo "Enabling indexbuilding with structured queries in 'wgreindex'..."; mv $V "$WG2LIB"/templates/wgreindex "$WG2LIB"/templates/old.wgreindex; sed -e "s^-H |INDEXDIR| -t -o^-H |INDEXDIR| -s -z -t -o^g" < "$WG2LIB"/templates/old.wgreindex > "$WG2LIB"/templates/wgreindex; # 6) $WG/lib/wgHeader.pm # ----------------------------------------------------------------------------- # Change the $FILE_END_MARK=" " definition in the $WG/lib/wgHeader.pm file # to "\t". in accordance with the --file-end-mark='\t' flag used in the # Glimpse installation. This will allow filenames with spaces. echo "Enabling the BibGlimpse features in 'wgHeader.pm'..."; mv $V "$WG2LIB"/lib/wgHeader.pm "$WG2LIB"/lib/old.wgHeader.pm; sed -e "s^\$FILE_END_MARK = \" \"^\$FILE_END_MARK = \"\\\t\"^" -e "s^\$WRREPOS = 0^\$WRREPOS = 1^" < "$WG2LIB"/lib/old.wgHeader.pm > "$WG2LIB"/lib/wgHeader.pm; # 7) $CGI/wrrepos.cgi # $CGI/wrsearch.cgi # ----------------------------------------------------------------------------- # Specify path to webglimpse libraries (eg. to '/usr/lib/wg2'): echo "Linking 'wrrepos.cgi' and 'wrsearch.cgi' to the Webglimpse libraries..."; sed "s^\$WEBGLIMPSE_LIB='';^\$WEBGLIMPSE_LIB='$WG2LIB/lib';^" < "$WG2CGI"/wrrepos.cgi > "$WG2CGI"/new.wrrepos.cgi; mv $V "$WG2CGI"/new.wrrepos.cgi "$WG2CGI"/wrrepos.cgi; chmod +x "$WG2CGI"/wrrepos.cgi; sed "s^\$WEBGLIMPSE_LIB='';^\$WEBGLIMPSE_LIB='$WG2LIB/lib';^" < "$WG2CGI"/wrsearch.cgi > "$WG2CGI"/new.wrsearch.cgi; mv $V "$WG2CGI"/new.wrsearch.cgi "$WG2CGI"/wrsearch.cgi; chmod +x "$WG2CGI"/wrsearch.cgi; # 8) $CGI/logout/logout.cgi # ----------------------------------------------------------------------------- # If you want to restrict access to your repository by means of .htaccess, # create a logout directory within $CGI, that has a separate .htaccess # file containing: # # AuthName "Logout" # AuthUserFile /your/path/to/.htpasswd # Require user logout # # which allows for the user 'logout' only. Do not forget to provide # a user 'logout' with password logout in your .htpasswd file! # All this provides a basic logout option using .htaccess user control. if [ ]; then echo ""; echo "If you want to have use .htaccess access control,"; echo "please consult the BibGlimpse.README..."; mkdir $WG2CGI/logout; cat > "$WG2CGI"/logout/logout.cgi << EOF #!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); my \$q = new CGI; print \$q->header(); my $user = \$ENV\{REMOTE_USER\}; print "You are now logged out!
", "Current REMOTE_USER is set to \$user.
", "
", "(On some browsers you still need to close the browser,
", " to ensure that the previous pages can not be reloaded!)"; EOF chmod +x "$WG2CGI"/logout/logout.cgi fi echo ""; echo "CONFIGURING THE BIBGLIMPSE ARCHIVES"; echo "----------------------------------------------------------------"; echo ""; # 11) configure archive via webinterface # ----------------------------------------------------------------------------- echo "Configuring archives..."; # create file with wg options cat > "$WG2TAR/wgcmdInput.txt" << EOF N BibGlimpse D $WG2PRT http://$APSERVERURL:$APSERVERPORT/prints 99999 N N BibGlimpse D $WG2PRT http://$APSERVERURL:$APSERVERPORT/prints 99999 N 1 X EOF # run wgcmd to configure archives echo "Changing port in $WG2HOM/archives/wgsites.conf"; mv $V "$WG2HOM/archives/wgsites.conf" "$WG2HOM/archives/old.wgsites.conf"; sed -e "s^Port\t80^Port\t$APSERVERPORT^" < "$WG2HOM"/archives/old.wgsites.conf > "$WG2HOM"/archives/wgsites.conf; echo ""; echo "Configuring archive via $WG2HOM/wgcmd..."; echo "Options used and logfiles:"; echo "$WG2TAR"/wgcmdInput.txt; echo "$WG2TAR"/wgcmdInput.log; echo ""; if [ -s "$WG2TAR"/wgcmdInput.txt ]; then cat "$WG2TAR"/wgcmdInput.txt | perl "$WG2HOM/wgcmd" | tee "$WG2TAR"/wgcmdInput.log; fi echo "Configured archives..."; # 12) Reindexing in background # ----------------------------------------------------------------------------- # From the above you should now have two directories in $ARC, # namely $ARC/1 and $ARC/2. # To keep the working archive $ARC/1 searchable while reindexing # wrwgreindex will mirror $ARC/1 to $ARC/2, build the index there # and then port the resulting index back to $ARC/1. # To do so, we need to replace the standard wgreindex script in $ARC/1. # Set $ARC to your full archive path and execute the commands below: # Note that reindexing can also be called from Crontab, as described # in the WebGlimpse documentation! # # ATTENTION: Take care that sym-links are not interpolated: # /your/archives/1 must not become # /your/somewhere/else/because/of/symlink/arch/... # or the 'sed' command in wrwgreindex will fail # and the abra retrieval in wrrepos.cgi will # silently produce crap! echo "Implementing reindexing in background..."; WG2ARC_MAIN="$WG2ARC/1"; WG2ARC_STEALTH="$WG2ARC/2"; while [ ! -w "$WG2ARC_MAIN" ] || [ ! -w "$WG2ARC_STEALTH" ] || [ ! -w "$WG2ARC_MAIN/wgreindex" ]; do echo "You need to change permissions on"; echo " $WG2ARC/1 and"; echo " $WG2ARC/2"; echo " $WG2ARC/1/wgreindex"; echo "such that the BibGlimpse Installer can write there."; read goon; done # replace the wgreindex command cat > "$WG2ARC_MAIN"/wgreindex << EOF #!$WHICHBASH # Since this is the visible archive we will not do any # reindexing here; instead we will move the reindexing # to the stealth twin of this archive. # # (c) Boku Bioinformatics # Thomas Tuechler, David Kreil 2008 # rm -f /tmp/.wg*; "$WG2ARC_MAIN"/wrwgreindex \$1 "$WG2ARC_STEALTH"; EOF # fix permissions and index archive echo "Making archive writeable for webuser..."; chmod -R a+rwx "$WG2HOM/archives"; if [ $LOCAPA != 'Y' ]; then echo "Making $WG2PRT writeable for webuser..."; chmod -R a+rw "$WG2PRT"; echo ""; echo "Open a new shell and change ownership"; echo "of archive to webuser with:"; echo ""; echo "sudo -u root"; echo "chown -R $APWEBUSER $WG2HOM/archives"; echo "chmod -R u+w $WG2HOM/archives"; echo ""; echo "Press enter when done..." read goon; ARCOWN=`ls -l $WG2HOM/archives | awk '{print $3}' | tail -1`; if [ "$APWEBUSER" != "$ARCOWN" ]; then goon=''; while [ "$goon" != 'Yes' ]; do echo "$WG2HOM/archives belongs to $ARCOWN." echo "It should belong the the webuser $APWEBUSER."; echo "Type 'Yes' to go on with this setup..."; read goon; ARCOWN=`ls -l $WG2HOM/archives | awk '{print $3}' | tail -1`; done fi ABRA=''; while [ -z "$ABRA" ]; do echo ""; echo "Open a new shell and index"; echo "archive as $APWEBUSER with:"; echo ""; echo "sudo -u $APWEBUSER"; echo "cd $WG2ARC_MAIN || exit"; echo "./wgreindex"; echo ""; echo "Press enter when done..." read goon; ABRA=`find $WG2ARC_MAIN/.cache -name '*.abra' | head -1`; done else echo "Indexing archive..."; cd "$WG2ARC_MAIN" || exit; ./wgreindex; fi cd "$WG2PRE" || exit; # final remarks echo ""; echo "BIBGLIMPSE INSTALLATION FINISHED"; echo "----------------------------------------------------------------"; echo ""; echo "Installed BibGlimpse and indexed directory:"; echo "$WG2PRT"; echo ""; echo "The archive is now accessible on your browser via:"; echo "http://$APSERVERURL:$APSERVERPORT/$APCGIWEB/$WG2NAM/wrsearch.cgi?ID=1"; echo ""; echo "Searching for 'bibf=Prives' will find the example PDF:"; echo "p73 induction after DNA damage is regulated by checkpoint kinases Chk1 and Chk2."; echo "Urist M, Tanaka T, Poyurovsky MV, Prives C."; echo "Genes Dev. 2004 Dec 15;18(24):3041-54."; echo "FAU - Prives, Carol"; echo ""; echo "Find further information on BibGlimpse at:"; echo "http://bioinf.boku.ac.at/bibglimpse"; echo "";