#!/bin/sh # RCSID = $Id: ha-setup,v 1.5 1998/04/02 13:42:37 stefan Exp $ # # Set up an analyzer configuration for http-analyze. # # Copyright 1998 by Stefan Stapelberg, RENT-A-GURU(TM) # LIBDIR=/usr/local/lib/http-analyze # How to suppress newline in echo: -n or \c #n="-n" c="\c" # # Prompt user # prompt() { answer='' if [ $# -eq 3 ]; then echo $n "$1 ($2) [$3]: $c" 1>&2; read answer case $answer in '') answer="$3";; esac elif [ $# -eq 2 -a "$2" != "-" ]; then echo $n "$1 [$2]: $c" 1>&2; read answer case $answer in '') answer="$2";; esac elif [ "$2" = "-" ]; then echo $n "$1: $c" 1>&2; read answer else until [ -n "$answer" ]; do echo $n "$1: $c" 1>&2; read answer [ -z "$answer" ] && echo "invalid input, please try again\n" 1>&2 done fi echo "$answer" return } # # Check for required files in LIBDIR # getlibdir() { if [ "$1" ]; then [ -s "$1/3Dlogo.wrl.gz" -a -s "$1/btn/RAG_sb.gif" ] && libd="$1" else if [ -s files/3Dlogo.wrl.gz -a -s files/btn/RAG_sb.gif ]; then libd=files elif [ -s 3Dlogo.wrl.gz -a -s btn/RAG_sb.gif ]; then libd=. elif [ -s $LIBDIR/3Dlogo.wrl.gz -a -s $LIBDIR/btn/RAG_sb.gif ]; then libd=$LIBDIR fi fi echo "$libd" return } # # Check for output directory, create it if necessary. # outputdir() { odir=`prompt "Name of the HTML output directory"` [ -d "$odir" ] || { \ ans=`prompt "Directory $odir doesn't exist, create it" y/n y`; case $ans in y|Y) mkdir $odir || exit 1 ;; esac; } echo "$odir" return } # # Install required files in an output directory. # copybtn() { odir="$1" ldir=`getlibdir` ldir=`prompt "Directory containing required files (3D*, btn/*)" $ldir` # check for required files, exit on failure case `getlibdir "$ldir"` in '') echo "Required files not found, did you install" \ "them in directory '$ldir'?" 1>&2; exit 1 ;; /*) ans='' until [ -n "$ans" ]; do ans=`prompt "Create symlinks (s) or copy files (c)" s` case $ans in 's') ln -s $ldir/3D* $ldir/btn $odir || { \ echo "Couldn't create symlinks - check permissions" 1>&2; exit 1; } echo "\nSymlinks to the required files have been created in $odir" 1>&2 ;; 'c') [ -d "$odir/btn" ] || mkdir $odir/btn (cp $ldir/3D* $odir && cp $ldir/btn/* $odir/btn) || { \ echo "Couldn't copy required files - check permissions" 1>&2; exit 1; } echo "\nRequired files have been copied into $odir" 1>&2 ;; *) echo "Invalid answer, please try again" 1>&2 ans='' ;; esac done ;; *) [ -d "$odir/btn" ] || mkdir $odir/btn (cp $ldir/3D* $odir && cp $ldir/btn/* $odir/btn) || { \ echo "Couldn't copy required files - check permissions" 1>&2; exit 1; } echo "\nRequired files have been copied into $odir" 1>&2 ;; esac return } bugreport() { TMPFILE=/tmp/hacall$$.html cat <<-HERE http-analyze bug report ----------------------- The script creates a bug report form in the file '$TMPFILE' and starts a browser with the name of this file as an argument. HERE VINFO=`http-analyze -V 2>&1` [ -s "$LIBDIR/bugreport.html" ] || { echo "Couldn't find the file $LIBDIR/bugreport.html." echo "Did you install it using a \"make install\"?" exit 1 } [ -n "$VINFO" ] && eval "`echo \"$VINFO\" | sed -n -e 's/^\(http-analyze [^ ]*\) (\([^)]*\)).*$/VERSION=\"\1\" PLATFORM=\"\2\"/p' \ -e 's/^Registered for \(.*\) (\([^)]*\))/CUSTOMER=\"\1\" REGID=\"\2\"/p'`" CUSTOMER=`echo "$CUSTOMER" | sed -e 's/&/\\\&/g' -e 's/\"/\\\"/g' \ -e 's/\\\</g' -e 's/>/\\\>/g'` sed -e "s/\${DEF_VERSION}/${VERSION:+VALUE=\"$VERSION\"}/" \ -e "s/\${DEF_PLATFORM}/${PLATFORM:+VALUE=\"$PLATFORM\"}/" \ -e "s/\${DEF_CUSTOMER}/${CUSTOMER:+VALUE=\"$CUSTOMER\"}/" \ -e "s/\${DEF_REGID}/${REGID:+VALUE=\"$REGID\"}/" $LIBDIR/bugreport.html >$TMPFILE echo "The script now starts a browser with this filename as argument.\n" browser=`prompt "Start which browser" netscape` if [ "X$browser" = "Xnetscape" ]; then $browser -remote "openURL(file:$TMPFILE)" 2>/dev/null || $browser file:$TMPFILE & else $browser file:$TMPFILE & fi return } brand() { cat <<-\HERE http-analyze branding --------------------- You will be asked for the registration information (company name, registration ID) and for the names of the two registration images sent to you by email. The images will replace the "unregistered" buttons present in the source distribution which you downloaded from our web site. You can install those images at a central location (for example, in LIBDIR/btn, where LIBDIR usually is `/usr/local/lib/http-analyze') or in an `OutputDir/btn' directory. To share the required files among all virtual web servers, install them in a central directory (by default, they are copied into LIBDIR/btn, where LIBDIR is `/usr/local/lib/http-analyze'). Then use symbolic links in the web server's statistics output directory for the required files and the buttons subdirectory. Make sure your web server follows symbolic links! HERE company=`prompt "Please enter your company name"` regid=`prompt "Please enter your registration ID"` btnw=`prompt "Name of first registration image" free-netstore_sw.gif` btnb=`prompt "Name of second registration image" free-netstore_sb.gif` [ -f "$btnw" -a -f "$btnb" ] || { \ echo "Couldn't find the registration images," \ "check files and permissions ..." 1>&2; exit 1; } btndir=`prompt "Install registration images in" $LIBDIR/btn` [ -w "$btndir" ] || { \ echo "Can't write into $btndir," \ "check permissions ..." 1>&2; exit 1; } # brand the software http-analyze -r "$company" "$regid" || { \ echo "Couldn't succesfully brand the analyzer" \ "(exit status $?)." 1>&2; exit 1; } # copy registration images cp $btnw $btndir/netstore_sw.gif && cp $btnb $btndir/netstore_sb.gif && echo "Images successfully installed in $btndir." return } # # Install required files into a statistics directory. # instbtn() { cat <<-\HERE Install required files for http-analyze --------------------------------------- This script copies the required files (3D*, btn/*) into the statistics output directory used by http-analyze. Make sure that you copy the correct images into the statistics directory (the images that came with your registration information in the registered version). First, enter the name of the HTML output directory (for example, /usr/www/stats). The 'btn' subdirectory will be created automaically if it does not exist already. HERE outdir=`outputdir` cat <<-\HERE Now enter the name of the directory containing the required files. This is either a central directory (LIBDIR) where you did install the files and buttons directory (like /usr/local/lib/http-analyze) or the subdirectory 'files' in the directory where you unpacked the source distribution of http-analyze. HERE copybtn "$outdir" return } # # Set up an analyzer configuration. # setup() { host=`hostname 2>/dev/null` [ -z "$host" ] && host=`uname -n` [ -z "$host" ] && host=www.unknown.dom cat <<-\HERE Setup http-analyze configuration -------------------------------- This script helps you to set up an analyzer configuration for use of http-analyze with a virtual web server. It creates the output directory, installs the required files and buttons in this output directory, and lets you define default settings of a configuration file. First, enter the name of a HTML output directory which will be used for the statistics report. This directory should be either a subdirectory under your web server's document root or another directory which may be reached through your web server in some way. HERE outdir=`outputdir` cat <<-\HERE Now enter the name of the directory containing the required files. This is either a central directory (LIBDIR) where you did install the files and buttons directory (like /usr/local/lib/http-analyze) or the subdirectory 'files' in the directory where you unpacked the source distribution of http-analyze. HERE copybtn "$outdir" cat <<-\HERE Next, enter the name of the configuration file. This file should be placed outside your server's document root either inside a central directory (for example, /usr/local/http-analyze) or in a web server specific subdirectory (i.e. /usr/www/config/http-analyze.conf). HERE config=`prompt "Name of the configuration file"` if [ -s "$config" ]; then mv $config ${config}.old || { \ echo "Couldn't back up $config, check permissions" 1>&2; exit 1; } fi TMPFILE="/tmp/ha-setup.$$" trap 'rm -f $TMPFILE; exit' 2 3 15 cat <<-\HERE Now enter the full qualified domain name of the web server, for example "foo.bar.com". HERE srvname=`prompt "Name of the web server" "$host"` srvname="ServerName $srvname" cat <<-\HERE Now enter the web server's URL which is to be used as a prefix in hotlinks. For example, if the server name is '$host', the corresponding URL would be 'http://$host/'. If you leave the server's URL empty, hypertext links in statistics reports will reference documents on the server the report is located on. HERE srvurl=`prompt "Corresponding server URL" -` if [ -z "$srvurl" ]; then srvurl="#ServerURL http://$srvname/" else srvurl="ServerURL $srvurl" fi cat <<-HERE >$TMPFILE # # Sample configuration file # # Entries are separated by one or more tabulators. # Command line options always take precedence. # Customer logos (commercial version only) # One (W) for use on white background, one (B) for black background. #CustLogoW btn/RAG_sw.gif http://www.rent-a-guru.de/ #CustLogoB btn/RAG_sb.gif http://www.rent-a-guru.de/ # The name of your server. $srvname # The prefix to use in URLs for hotlinks. # Note: The trailing slash is important! $srvurl HERE cat <<-\HERE If this setup is for a software-virtual server, you can restrict analysis to this server by specifying the subdirectory where the documents for this virtual server are located. For example, if the virtual server's URL http://www.customer.com/ is mapped to the subdirectory '/customer/', specify the URL '/customer/' as the Document Root for the virtual web server. If you configure a "real" web server, just hit RETURN now. HERE virtdir=`prompt "Document Root of virtual server" -` if [ -z "$virtdir" ]; then virtdir="#DocRoot /~customer/" else virtdir="DocRoot $virtdir" fi cat <<-HERE >>$TMPFILE # The name(s) of virtual server document roots. # Note: The leading slash is important! $virtdir HERE cat <<-\HERE The next setting will be used as the web server's logfile if no filename is explicitely given at invocation of the analyzer. If you leave the default logfile name undefined, the analyzer will read it's standard input if no filename is given. HERE logfile=`prompt "Name of the default logfile" -` if [ -z "$logfile" ]; then logfile="#LogFile /usr/ns-home/www.foo.com/logs/access" else logfile="LogFile $logfile" fi cat <<-\HERE The noise level is a watermark which causes the analyzer to collect all URLs, sites, agents, and referrer URLs with hits below this level under the "Noise" entry in the overviews and detailed lists. This reduces the file size for large reports by a significant amount. Useful values are 5 to 50 depending on the total number of accesses. HERE noiselvl=`prompt "Noise level" -` if [ -z "$noiselvl" ]; then noiselvl="#NoiseLevel 7" else noiselvl="NoiseLevel $noiselvl" fi cat <<-HERE >>$TMPFILE # The name of the default logfile. $logfile # The format of the logfile: # auto Try to automatically recognize format (default) # clf Common Logfile Format (CLF) # dlf Combined Logfile Format (CLF + Referrer + UserAgent) # elf Extended Logfile Format (CLF + UserAgent + Referrer) # LogFormat auto # The default mode of operation now is full statistics ("monthly" mode). #DefaultMode monthly # Noise level: suppress details about all items with hits below # this level in order to keep the size of reports manageable. $noiselvl # The name of the directory where the output files # of the statistics report are to be created. OutputDir $outdir # The name of a private directory where detailed lists are to be placed. # Must be a subdirectory of OutputDir. Note that you have to set up server # authentication if you want to protect those lists. http-analyze just # creates the detailed list of URLs, sites, agents and referrers in this # subdirectory. See the online documentation for an example. #PrivateDir lists HERE cat <<-\HERE Now enter the name(s) of additional directory index file which are later reduced to the URL for the subdirectory (for example, 'home.html', 'Welcome.html' or any other filename you have defined in your web server's configuration file. Note that 'index.html' is pre-defined already. To specify more than one name, use commas to separate them. If you use no index files other than 'index.html', just hit RETURN. HERE homepage=`prompt "Additional directory index filenames" -` if [ -z "$homepage" ]; then homepage="#IndexFiles /Welcome.html" else homepage="IndexFiles $homepage" fi cat <<-HERE >>$TMPFILE # Alternate names for index files other than "index.html". # Note: The leading slash is important! $homepage HERE cat <<-\HERE In order to be able to compute pageviews correctly, the analyzer needs to know which files are to be rated as documents, so you must define the suffixes of such text files. For example, pageview suffixes are often '.shtml', '.text' and '.htm'. The suffix '.html' is pre-defined already. If you use no text files with suffixes other than '.html', just hit RETURN at the following question. If you want to suppress pageviews ratings, enter 'suppress' here. HERE pageview=`prompt "Additional pageview suffixes" -` if [ -z "$pageview" ]; then pageview="#PageView .text" elif [ "$pageview" = "none" ]; then pageview="#PageView .text" suppress="Pageviews" else pageview="PageView $pageview" fi cat <<-HERE >>$TMPFILE # Alternate suffixes for text files other than ".html" # for calculating pageviews. Must start with a dot. $pageview HERE cat <<-\HERE For accounting user sessions, the analyzer will count all accesses from the same host as one session only during a certain time-window. In previous versions, the session value did correspond to "sites" and used a time-window of one day. To keep this default, use '1 Day' as the time-window. Examples: 30 Minutes, 4 Hours, 2 Days. HERE usession=`prompt "User session time-window" "1 Day"` if [ -z "$usession" ]; then usession="#Session 1 Day" else usession="Session $usession" fi cat <<-HERE >>$TMPFILE # Time-window for accounting user sessions (default: 24 hours). # Use [t]icks, [s]econds, [h]ours or [d]ays after the number # as a scaling unit. $usession # The name of a file containing all valid domains. # You may add top-level domains with up to 6 characters # in length. See the included file TLD for an example. #TLDFile /usr/local/lib/http-analyze/TLD # # If TLDFile is set to \`none', no country list is produced in the summary. #TLDFile none # The name of the VRML prolog file for yearly models. # For use on graphic workstations only! #VRMLProlog /home/netadm/3Dprolog.wrl # The title to display in the statistics reports. # This string will be concatenated with ServerName. #ReportTitle Access statistics for # Font sizes for text and headers. #HeadSize 3 #FontSize 2 # The Prefix to output after the header section (if defined, it must # include the
tag). If the string starts with a slash, it is # taken as the name of a file containing the HTML code. #HTMLPrefix /usr2/netstore/httpd/ha-header # The Trailer to output at the end of a page, immediately before the # copyright note. If the string starts with a slash, it is taken as # the name of a file containing the HTML code. #HTMLTrailer /usr2/netstore/httpd/ha-trailer # Suppress certain parts of the summary. #Suppress AVLoad,URLs,URLList,Code404,Sites,RSites,SiteList #Suppress Agents,AgentList,Referrer,ReferList,Country #Suppress Pageviews,Graphics,Hotlinks,Interpol $suppress HERE cat <<-\HERE >>$TMPFILE # The number of URLs, sites and agents in the "top ten" lists. If set # to zero, the appropriate parts of the summary will be supressed. #TopURLs 30 #LastURLs 10 #TopSites 30 #TopAgents 30 #TopRefers 30 #TopDays 5 # The size of the navigation frame in pixels. #NavigFrame 120 # The type of the 3D window: # extern (new window) or intern (inside frame). #3DWindow extern # The size of the 3D window in pixels (width x height). #3DWinSize 520x420 # The size of the navigation window in pixels (width x height). #NavWinSize 420x190 # # List of sites and URLs to ignore or hide. # Format: # HideURL