#!/bin/sh # # $Id: install,v 1.35 2001-12-20 17:11:34-05 kai Exp $ # # Unix install script for Texis and Webinator 4+. # Expects these files in current dir: # # license.upd License file # Read1st.txt Optional read-me-first file # [texis|webinator].tar[.Z|.gz] Contains usr/local/morph3 tree: # bin/ Executables # api/ Optional API files # texis/testdb/ Default database (or webinator/testdb) # texis/scripts/ Optional scripts # texis/timport/ Optional timport schemas # texis/text/ Optional text files # webinator/ Webinator files (optional if Texis) # conf/vhttpd.conf Sample web server config file # logs Default web server log dir (if Texis) # htdocs/index.html Default web server document tree # equivs Optional equivs file # Readme.txt Optional readme # [texis|webinator].sum Optional checksum # install.sum Optional checksum # # For Webinator install, texis.tar and texis.sum are replaced by # webinator.tar and webinator.sum. # # NOTE: This install script depends on rex in the tar file, # and sed, cmp being in $PATH. # WEBINATORINSTALL: y for Webinator install, n for Texis. # Defaults y if webinator.tar exists; setting here overrides that; # -webinator/-texis option overrides this: WEBINATORINSTALL= # WEBINATOR4: y for Webinator 4+, n for Webinator 2. # Defaults y if webinator.tar exists; setting here overrides that; # -version4/-version2 overrides this: WEBINATOR4=y # You don't want to change these: TX_VERSION=4.00 TX_DEFINSTALLDIR=/usr/local/morph3 TX_SUIDFILES="gw monitor rmlocks texisd" TX_PATCHFILES="bin/gw bin/monitor bin/rmlocks bin/texisd api/libtexis.a" TX_SAMPLESCRIPTS="tutorial patent" ############################ Util functions ################################## showprompt () { echo $EchoArg "$1$EchoSfx" } getdir () { # Prompts the user for a full-path directory or URL. Returns it in $dir. # Args: $1 prompt [$2 default [$3 create|url [$4 empty]]] prompt=$1 defdir=$2 create=$3 empty=$4 if [ ! -z "$defdir" ]; then prompt="$prompt [ENTER for $defdir]" fi while true; do showprompt "$prompt: " read dir if [ -z "$dir" ]; then dir=$defdir if [ -z "$dir" ]; then if [ "$empty" = "empty" ]; then break else continue fi fi fi x=`echo "$dir" | sed -n '/^[/]/p'` if [ "$x" = "" ]; then if [ "$create" = "url" ]; then x=`echo "$dir" | sed -n '/^http:[/][/][a-zA-Z_0-9-][.a-zA-Z_0-9-]*:*[0-9]*[/]/p'` if [ "$x" = "" ]; then echo "$dir is not a full path or http URL. Try again." else break fi else echo "$dir is not a full path. Try again." fi elif [ "$create" = "url" -o -d "$dir" ]; then break else echo "Directory $dir does not exist." if [ "$create" = "create" ]; then showprompt "Shall I create it? (y/n) [ENTER for y]: " read yn if [ "$yn" = "" -o "$yn" = "y" -o "$yn" = "yes" -o "$yn" = "Y" -o "$yn" = "YES" -o "$yn" = "Yes" ]; then if mkdir -p $dir; then echo "Directory $dir created." break else cat </dev/null | sed -n '/^l/p'`" != "" ] return $? } rdsymlink () { # Sets $sym to value of symbolic link $1, or empty if not a symbolic link sym="`ls -ald $1 2>/dev/null | sed -n '/ -> /s@^.* -> \(.*\)$@\1@p'`" } rcsvers () { # Prints NN part of 1.NN RCS id for file $1; optional RCS file $2 $TmpBinDir/rex -n -p -P '>>\x24Id: '"$2"'=!\space+\space+\digit+.\P=\digit+' $1 2>/dev/null } rcsinstall () { # Installs text file $1 as $2 or ${2}-new, comparing RCS revisions. # Sets $instfile to $2, ${2}-new or empty, whichever was installed. instfile= if [ -f $1 ]; then rm -f ${2}-new if [ -f $2 ]; then # Compare RCS revisions. Check for missing rev first to avoid -gt error: newvers=`rcsvers $1` oldvers=`rcsvers $2` if [ "$oldvers" = "" -o "$newvers" = "" ]; then instfile=${2}-new elif [ "$newvers" -gt "$oldvers" ]; then instfile=${2}-new fi else instfile=$2 fi fi if [ "$instfile" != "" ]; then cp $1 $instfile && RcsInstalls="$RcsInstalls $instfile" optchown $instfile chmod u=rw,go=r $instfile fi } mkhtaccess () { if [ "$2" = "allow" ];then limit="order allow,deny allow from all" else limit="order deny,allow deny from all allow from 127.0.0.1" fi cat >$1/.htaccess < $limit EOF chmod u=rw,go=r $1/.htaccess optchown $1/.htaccess } usage () { cat </dev/null`" rmso="`tput sgr0 2>/dev/null`" # some termcaps have broken rmso while [ "$1" != "" ]; do case "$1" in -webinator) WEBINATORINSTALL=y; WEBINATOR4=y ;; -texis) WEBINATORINSTALL=n; ;; -version4) WEBINATOR4=y; ;; -version2) WEBINATOR4=n; ;; -conf) shift if [ "$1" = "" ]; then usage; fi if [ -d $1 ]; then ApacheConfDir=$1; else echo "Directory $1 does not exist." exit 1 fi ;; -help|-h) usage; ;; *) echo "Unknown option $1"; exit 1; ;; esac shift done ############################### Initialization ############################### TmpLink= TmpFile=${TMP:-/tmp}/install-$$-1.tmp TmpFile2=${TMP:-/tmp}/install-$$-2.tmp trap quit 2 3 15 if [ "$WEBINATORINSTALL" = "" ]; then if [ -f webinator.tar -o -f webinator.tar.Z -o -f webinator.tar.gz -o -f WEBINATOR.TAR -o -f WEBINATOR.TAR.Z -o -f WEBINATOR.TAR.GZ ]; then WEBINATORINSTALL="y" if [ "$WEBINATOR4" = "" ]; then WEBINATOR4="y" fi else WEBINATORINSTALL="n" fi fi if [ "$WEBINATORINSTALL" = "y" ]; then Product=webinator ProductName="Webinator" else Product=texis ProductName="Texis" fi if [ "$WEBINATOR4" = "y" -a "$TX_VERSION" = "3.0" ]; then TX_VERSION=4.0 fi RcsInstalls= InstallLicense=y cat <$TmpFile 2>/dev/null if [ "`wc -c <$TmpFile | sed 's/ //g'`" != "3" ]; then echo 'abc\c' >$TmpFile 2>/dev/null if [ "`wc -c <$TmpFile | sed 's/ //g'`" = "3" ]; then EchoArg= EchoSfx='\c' else echo -e 'abc\c' >$TmpFile 2>/dev/null if [ "`wc -c <$TmpFile | sed 's/ //g'`" = "3" ]; then EchoArg=-e EchoSfx='\c' fi fi fi # Verify integrity of install script: if [ -s install.sum ]; then echo $EchoArg "Checking install script...$EchoSfx" chk=`sum <$0` exp=`cat install.sum` if [ "$chk" != "$exp" ]; then echo "*** Bad checksum ***" cat </dev/null | tr 'a-z' 'A-Z'` if [ -f ${upper}.TAR.Z ]; then tarballZ=${upper}.TAR.Z elif [ -f ${upper}.TAR.GZ ]; then tarballgz=${upper}.TAR.GZ elif [ -f ${upper}.TAR ]; then tarball=${upper}.TAR else cat </dev/null || uname -n 2>/dev/null` if [ ! -z "$FQDN" ]; then x=`echo $FQDN | sed -n '/[.]/p'` if [ "$x" = "" ]; then if [ -f /etc/hosts ]; then FQDN=`sed -n "/[ ]$FQDN[.]/s/.*[ ]\($FQDN[.][^ ]*\).*$/\1/p" /dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r|cut -d'-' -f1) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown case "${UNAME_SYSTEM}" in Linux) if [ "`echo ${UNAME_RELEASE} | sed -n '/^2\.0\./p'`" != "" ]; then yap=n cat </dev/null | sed -n '/ [/][^ ]*[/]httpd/s@^.* \([/][^ ]*\)[/]httpd.*@cg=\1;@p'`" if [ "$cg" = "" ]; then eval "`ps -auxwww 2>/dev/null | sed -n '/ [/][^ ]*[/]httpd/s@^.* \([/][^ ]*\)[/]httpd.*@cg=\1;@p'`" fi if [ "$cg" != "" ]; then cg="`echo $cg | sed 's@/bin$@@'`"/conf list="$cg $list" fi fi # Look for conf files and parse 'em: for dir in $list; do if [ -d $dir ]; then sed -n -e 's@[;"&$'"'"']@ @g' -e 's@^[ ]*ScriptAlias[ ][ ]*\([^ ]*\)[ ]*\([^ ]*\).*@CgiUrlDef="\1";CgiDirDef="\2";@p' -e 's@^[ ]*ServerRoot[ ][ ]*\([^ ]*\).*@ServerRootDef="\1";@p' -e 's@^[ ]*AddHandler[ ][ ]*cgi-script[ ][ ]*\([^ ]*\).*@CgiExtDef="\1";@p' -e 's@^[ ]*Port[ ][ ]*\([^ ]*\).*@PortDef="\1";@p' -e 's@^[ ]*User[ ][ ]*\([^ ]*\).*@UserDef="\1";@p' -e 's@^[ ]*DocumentRoot[ ][ ]*\([^ ]*\).*@DocumentRootDef="\1";@p' ${dir}/*conf >$TmpFile 2>/dev/null eval "`cat $TmpFile`" rm -f $TmpFile CgiUrlDef=`echo $CgiUrlDef | sed 's@[/\\]$@@'` CgiDirDef=`echo $CgiDirDef | sed 's@[/\\]$@@'` ServerRootDef=`echo $ServerRootDef | sed 's@[/\\]$@@'` # Make $CgiDirDef absolute: if [ "$ServerRootDef" != "" ]; then if [ "$CgiDirDef" != "" -a "`echo $CgiDirDef | sed -n '/^[/\\]/p'`" = "" ]; then CgiDirDef="$ServerRootDef/$CgiDirDef" fi if [ "$DocumentRootDef" != "" -a "`echo $DocumentRootDef | sed -n '/^[/\\]/p'`" = "" ]; then DocumentRootDef="$ServerRootDef/$DocumentRootDef" fi fi if [ "$DocumentRootDef" != "" ]; then if [ ! -d "$DocumentRootDef" ]; then DocumentRootDef=""; fi fi if [ -d "$CgiDirDef" ]; then break else # If the dir doesn't exist, then also ignore CgiUrlDef. # Could be non-dir ScriptAlias, eg. ScriptAlias /texis cgi-bin/texis: CgiUrlDef= CgiDirDef= fi fi done # If that fails, look for some common dirs: if [ "$CgiDirDef" = "" -a "$ApacheConfDir" = "" ]; then if [ "$CgiExtDef" = "" ]; then for dir in $ServerRootDef/cgi-bin /usr/local/httpd/cgi-bin /usr/local/httpd/cgi /usr/local/etc/httpd/cgi-bin /usr/local/apache/cgi-bin /usr/local/etc/httpd/cgi /home/httpd/cgi-bin; do if [ -d $dir ]; then CgiDirDef=$dir break fi done elif [ "$DocumentRootDef" != "" -a -d "$DocumentRootDef" ]; then for d in $DocumentRootDef/*; do if [ -d $d ]; then CgiDirDef=$d break fi done fi fi if [ "$PortDef" = "80" ]; then PortDef= fi userid=`id 2>/dev/null | sed -n -e 's/(.*//' -e 's/^uid=//' -e '/^[0-9]/p'` user=`id 2>/dev/null | sed -n '/^uid=[^(]*(/s@^uid=[^(]*(\([^)]*\).*@\1@p'` group=`id 2>/dev/null| sed -n '/ gid=[0-9]*(/s@^.* gid=[^(]*(\([^)]*\).*@\1@p'` if [ "$yap" = "y" ]; then echo "done"; fi ############################################################################## # Possibly ask for user/group to chown to: chownuser= chgrpgroup= chownstatus= chmodstatus= cat </dev/null; then break else echo "The user '$chownuser' does not appear to exist. Try again." fi done rm -f $TmpFile # Set group based on this user: if [ "$chownuser" != "" ]; then g=`id "$chownuser" 2>/dev/null` x=`id 2>/dev/null` if [ "$g" = "$x" ]; then g=`su -c id "$chownuser" 2>/dev/null` fi chgrpgroup=`echo $g|sed -n '/ gid=[0-9]*(/s@^.*gid=[^(]*(\([^)]*\).*@\1@p'` fi fi ############################################################################## # Ask for the install directory and check it: cat </dev/null` if [ "$txt" = "" ]; then rm -rf $d; fi fi done done # Don't allow Webinator to be installed on top of Texis: if [ "$WEBINATORINSTALL" = "y" ]; then if [ -f $BinDir/ltest -o -f $ApiDir/libtexis.a ]; then cat </dev/null 2>&1 mkdir $TmpInstallRoot || bail if [ "$tarballZ" != "" ]; then if uncompress -c <$tarballZ | (cd $TmpInstallRoot && tar xf -); then echo "Ok" else echo "*** Failed ***" echo "Could not extract $tarballZ to $TmpInstallRoot" bail fi elif [ "$tarballgz" != "" ]; then if gunzip -c <$tarballgz | (cd $TmpInstallRoot && tar xf -); then echo "Ok" else echo "*** Failed ***" echo "Could not extract $tarballgz to $TmpInstallRoot" bail fi else if (cd $TmpInstallRoot && tar xf -) <$tarball; then echo "Ok" else echo "*** Failed ***" echo "Could not extract $tarball to $TmpInstallRoot" bail fi fi cp /dev/null $TmpBinDir/.tmpdir >/dev/null 2>&1 cp /dev/null $TmpApiDir/.tmpdir >/dev/null 2>&1 cp /dev/null $TmpInstallDir/webinator/.tmpdir >/dev/null 2>&1 cp /dev/null $TmpInstallDir/texis/testdb/.tmpdir >/dev/null 2>&1 cp /dev/null $TmpInstallDir/webinator/testdb/.tmpdir >/dev/null 2>&1 ############################################################################## # rcsvers/rcsinstall depends on rex: if [ ! -x $TmpBinDir/rex ]; then echo "$TmpBinDir/rex is missing" bail fi if [ ! -x $TmpBinDir/monitor ]; then echo "$TmpBinDir/monitor is missing" bail fi ############################################################################## # Check for version conflicts: do not install Webinator on top of Texis: if [ "$WEBINATORINSTALL" = "y" ]; then yap=y echo $EchoArg "Checking for existing version...$EchoSfx" ifs="$IFS" IFS=":" set - $PATH IFS="$ifs" otexisbin= for d in $BinDir $TX_DEFINSTALLDIR/bin $*; do # make sure monitor running if present so there's a license seg echo $EchoArg ".$EchoSfx" if [ -x $d/monitor ]; then if [ "$userid" = "0" -a "$chownuser" != "" ]; then su "$chownuser" -c "$d/monitor" /dev/null 2>/dev/null else $d/monitor >/dev/null 2>/dev/null fi otexisbin=$d break fi done if [ "$userid" = "0" -a "$chownuser" != "" ]; then txt=`su "$chownuser" -c "$TmpBinDir/monitor -T; echo "'$?' &1` rc=`echo $txt | sed 's@.*\([0-9][0-9]*\)$@\1@'` txt=`echo $txt | sed 's@ *[0-9][0-9]*$@@'` else txt=`$TmpBinDir/monitor -T 2>&1` rc=$? fi if [ $rc -ne 0 ]; then cat </dev/null 2>&1 # vhttpd must be a separate file from monitor: monitor is setuid web-user, # but vhttpd starts as root: rm -f $TmpBinDir/vhttpd >/dev/null 2>&1 if [ "$WEBINATORINSTALL" != "y" ]; then cp $TmpBinDir/monitor $TmpBinDir/vhttpd || bail fi # chown/chgrp ALL files if needed: if [ "$chgrpgroup" != "" ]; then # symlinks too, if possible (Alpha/OSF1): chgrp -h $chgrpgroup $TmpBinDir/* >/dev/null 2>&1 chgrp -R $chgrpgroup $TmpInstallDir fi if [ "$chownuser" != "" ]; then # symlinks too, if possible (Alpha/OSF1): chown -h $chownuser $TmpBinDir/* >/dev/null 2>&1 if chown -R $chownuser $TmpInstallDir; then chownstatus=y else chownstatus=n fi fi # setuid files, if not root or chown was successful: if [ "$userid" != "0" -o "$chownstatus" = "y" ]; then failed= for file in $TX_SUIDFILES; do if [ -f $TmpBinDir/$file ]; then if chmod u+s $TmpBinDir/$file; then : ; else failed=y; fi fi done if [ "$failed" = "y" ]; then chmodstatus=n else chmodstatus=y fi fi # Make the bin dir live: if [ -d $BinDir ]; then mv $BinDir ${BinDir}-old || bail echo "Existing bin dir backed up to ${BinDir}-old" fi mv $TmpBinDir $BinDir || bail ############################################################################## # Install API, if present: if [ "$WEBINATORINSTALL" != "y" -a -d $TmpApiDir ]; then if [ -d $ApiDir ]; then mv $ApiDir ${ApiDir}-old || bail echo "Existing API dir backed up to ${ApiDir}-old" fi mv $TmpApiDir $ApiDir || bail mk=$ApiDir/makefile sed "s@^ *MORPHDIR *=.*@MORPHDIR=$InstallDir@" <$mk >${mk}-tmp rm -f $mk mv -f ${mk}-tmp $mk optchown $mk elif [ -d $ApiDir ]; then cat </dev/null 2>&1 fi if [ ! -d $txdir ]; then echo "Can't create $txdir" bail fi if [ ! -f $txdir/monitor.log ]; then cp /dev/null $txdir/monitor.log >/dev/null 2>&1 optchown $txdir/monitor.log chmod ugo+rw $txdir/monitor.log >/dev/null 2>&1 fi if [ ! -f $txdir/vortex.log ]; then cp /dev/null $txdir/vortex.log >/dev/null 2>&1 optchown $txdir/vortex.log chmod ugo+rw $txdir/vortex.log >/dev/null 2>&1 fi ############################################################################## # Install texis/{scripts|timport}. Ok to overwrite existing files: if [ "$WEBINATORINSTALL" != "y" ]; then if [ ! -d $InstallDir/texis/scripts ];then mkdir -p $InstallDir/texis/scripts fi if [ ! -d $InstallDir/texis/timport ];then mkdir -p $InstallDir/texis/timport fi if [ ! -d $InstallDir/texis/scripts -o ! -d $InstallDir/texis/timport ]; then echo "Can't create $InstallDir/texis/scripts or $InstallDir/texis/timport" bail fi optchown $InstallDir/texis $InstallDir/texis/scripts $InstallDir/texis/timport chmod u=rwx,go=rx $InstallDir/texis $InstallDir/texis/scripts $InstallDir/texis/timport mv -f $TmpInstallDir/texis/scripts/* $InstallDir/texis/scripts mv -f $TmpInstallDir/texis/timport/* $InstallDir/texis/timport fi ############################################################################## # Install testdb, but don't overwrite: if [ "$WEBINATORINSTALL" = "y" ]; then TmpTestDb=$TmpInstallDir/webinator/testdb else TmpTestDb=$TmpInstallDir/texis/testdb fi rm -f $TmpTestDb/SYSLOCKS >/dev/null 2>&1 TestDbIndexInst= if [ -f $InstallDir/texis/testdb/SYSTABLES.tbl ]; then echo "Existing default database $InstallDir/texis/testdb preserved." rcsinstall $TmpTestDb/index $InstallDir/texis/testdb/index TestDbIndexInst=$instfile if [ "`basename $TestDbIndexInst`" = "index" ]; then mv -f $TmpTestDb/index.vtx $InstallDir/texis/testdb/ optchown $TmpTestDb/index.vtx fi else mv $TmpTestDb $InstallDir/texis/ || bail optchown $InstallDir/texis/testdb $InstallDir/texis/testdb/* TestDbIndexInst=$InstallDir/texis/testdb/index fi chmod a+rwx $InstallDir/texis/testdb if chmod u=rw,go= $InstallDir/texis/testdb/*; then true else chmodstatus=n fi chmod ugo+r $InstallDir/texis/testdb/index $InstallDir/texis/testdb/index.vtx # remove webinator/testdb so it's not installed with webinator/ tree: rm -rf $TmpTestDb ############################################################################## # Copy license.upd, equivs, Readme.txt, web server dirs: if [ -f license.upd -a "$InstallLicense" = "y" ]; then if cmp $InstallDir/license.upd license.upd >/dev/null 2>&1; then rm -f $InstallDir/license.upd fi if [ -f $InstallDir/license.upd ]; then rm -f $InstallDir/license.upd-old >/dev/null 2>&1 mv $InstallDir/license.upd $InstallDir/license.upd-old >/dev/null 2>&1 fi cp license.upd $InstallDir/license.upd || bail optchown $InstallDir/license.upd chmod u+rw,go+r $InstallDir/license.upd if cmp $InstallDir/license.did license.upd >/dev/null 2>&1; then : else rm -f $InstallDir/license.did-old >/dev/null 2>&1 mv $InstallDir/license.did $InstallDir/license.did-old >/dev/null 2>&1 fi fi if [ -f $TmpInstallDir/equivs -a ! -f $InstallDir/equivs ]; then mv $TmpInstallDir/equivs $InstallDir/equivs fi if [ -f $TmpInstallDir/Readme.txt ]; then if cmp $InstallDir/Readme.txt $TmpInstallDir/Readme.txt >/dev/null 2>&1; then : else rm -f $InstallDir/Readme.old >/dev/null 2>&1 mv $InstallDir/Readme.txt $InstallDir/Readme.old >/dev/null 2>&1 mv $TmpInstallDir/Readme.txt $InstallDir/Readme.txt fi fi if [ ! -f $InstallDir/.htaccess ]; then mkhtaccess $InstallDir fi if [ "$WEBINATORINSTALL" != "y" ]; then # Install web server dirs (conf, logs, htdocs): conf=$InstallDir/conf instvconf= for dir in conf logs htdocs; do if [ -d $TmpInstallDir/$dir -a ! -d $InstallDir/$dir ]; then mv $TmpInstallDir/$dir $InstallDir/$dir if [ "$dir" = "conf" ]; then instvconf=$conf/vhttpd.conf fi elif [ "$dir" = "conf" ]; then # We didn't install conf dir; install its files: rcsinstall $TmpInstallDir/conf/vhttpd.conf $conf/vhttpd.conf instvconf=$instfile rcsinstall $TmpInstallDir/conf/mime.types $conf/mime.types rcsinstall $TmpInstallDir/conf/mime.encodings $conf/mime.encodings fi done # Set default ServerRoot, User, Group in vhttpd.conf: if [ "$instvconf" != "" -a -f "$instvconf" ]; then u= if [ "$chownuser" != "" ]; then u=$chownuser elif [ "$user" != "" -a "$userid" != "0" ]; then u=$user fi uexp="s@x@x@" if [ "$u" != "" ]; then uexp="s@^ *\(#*\) *User [a-zA-Z][a-zA-Z]* *\$@\1User $u@" fi g= if [ "$chgrpgroup" != "" ]; then g=$chgrpgroup elif [ "$group" != "" -a "$userid" != "0" ]; then g=$group fi gexp="s@x@x@" if [ "$g" != "" ]; then gexp="s@^ *\(#*\) *Group [a-zA-Z][a-zA-Z]* *\$@\1Group $g@" fi srexp="s@^ *ServerRoot .*@ServerRoot $InstallDir@" sed -e "$srexp" -e "$uexp" -e "$gexp" <$instvconf >${instvconf}.tmp rm -f $instvconf && mv -f ${instvconf}.tmp $instvconf optchown $instvconf fi fi # Install texis.cnf.sample, set install dir in it, make it live: newtc=$TmpInstallDir/texis.cnf.sample oldtc=$InstallDir/texis.cnf.sample livetc=$InstallDir/texis.cnf if [ -f $newtc ]; then rm -f $oldtc sed "s@$TX_DEFINSTALLDIR@$InstallDir@g" <$newtc >$oldtc optchown $oldtc if [ ! -f $livetc ]; then mv -f $oldtc $livetc optchown $livetc fi fi ############################################################################## # Install (partially) Webinator: if [ -d $TmpInstallDir/webinator ]; then havewebinator=y rm -rf $InstallDir/webinator mv $TmpInstallDir/webinator $InstallDir/webinator || bail fi ############################################################################## # Install text/ files (optional): if [ -d $TmpInstallDir/text ]; then if [ -d $InstallDir/text ]; then mv -f $TmpInstallDir/text/* $InstallDir/text >/dev/null 2>&1 else mv $TmpInstallDir/text $InstallDir fi fi ############################################################################## # Clean up some stuff before getting to nasty part of install: echo $EchoArg "Cleaning up temp files...$EchoSfx" rm -rf $TmpInstallRoot >/dev/null 2>&1 echo "done" if [ ! -x $BinDir/geturl ]; then echo "'$BinDir/geturl' missing" bail fi if [ "$WEBINATOR4" = "y" ]; then WebSearchSrc="search4" WebExtraSrc="dowalk webinatoradmin swdrmlog.gif" else WebSearchSrc="newsearch" WebExtraSrc="admin walk" fi ############################################################################## # Ask if they're using vhttpd: if [ "$WEBINATORINSTALL" = "y" ]; then servertype=1 else cat </dev/null 2>&1; then rm -f $tmplink; fi if [ "$WEBINATORINSTALL" = "y" -a -x $tmplink ]; then if [ "$userid" = "0" -a "$chownuser" != "" ]; then txt=`su "$chownuser" -c "$tmplink -version"/dev/null` else txt=`$tmplink -version 2>/dev/null` fi vers=`echo $txt | sed -e '/Webinator/d' -e '/Free Trial/d' -e '/Eval/d' -e '/Unknown/d'` if [ "$vers" != "" ]; then name="copy" if issymlink $tmplink; then name="link"; fi v=`echo $vers | sed 's@^.*Inc. *@@'` cat </dev/null 2>&1;; esac sleep 1 done $BinDir/rmlocks -f $InstallDir/texis/testdb >/dev/null 2>&1 echo "done" rm -f $InstallDir/texis/testdb/SYSLOCKS >/dev/null 2>&1 fi echo $EchoArg "Checking dir with a web fetch...$EchoSfx" if $BinDir/geturl -t35 "$tryurl" >$TmpFile 2>$TmpFile2; then break; fi # If the web fetch fails with "Can't connect", warn user and ask again: if [ "`sed -n '/Can.t.connect/p' <$TmpFile2`" != "" ]; then h=`echo $tryurl | sed -e 's@^http://@@' -e 's@/.*$@@' 2>/dev/null` echo "*** Failed ***" cat $TmpFile2 cat </dev/null` if [ "$x" != "" ]; then echo "The response from the web server was: $x" fi echo $EchoArg "Trying again with file...$EchoSfx" rm -f $TmpLink $TmpFile $TmpFile2 if cp $srctexis $tmplink 2>$TmpFile2; then TmpLink=$tmplink optchown $TmpLink else echo "*** Failed ***" echo "Can't copy to file $tmplink. Try again." rm -f $tmplink $TmpFile $TmpFile2 continue 2 fi if [ "$userid" != "0" -o "$chownstatus" = "y" ]; then chmod u+s $TmpLink fi if $BinDir/geturl -t35 "$tryurl" >$TmpFile 2>$TmpFile2; then break; fi echo "*** Failed ***" cat $TmpFile2 respline=`sed -n '/^HTTP/p' <$TmpFile 2>/dev/null` rm -f $TmpLink $TmpFile $TmpFile2 cat <@;@' -e 's@^[$]@@' -e '/^urlroot=/p' -e '/^pathroot=/p' -e '/^sourcepath=/p' <$TmpFile` SERVER_ROOT= eval `sed -n -e 's@
@;@' -e '/^SERVER_ROOT=/p' <$TmpFile` # Complete value of Server header: server=`sed -n -e 's/ //g' -e '/^Server: /s/^Server: //p' <$TmpFile` # Complete version string of Vortex: version=`sed -n -e 's/ *<[^>]*>//g' -e '/Version .* of /s@^.*Version @@p' <$TmpFile` # Version number of Vortex: versionnum=`echo $version | sed 's/^\([0-9.]*\).*/\1/'` if [ "`sed -n '/^Server: Thunderstone/p' <$TmpFile`" != "" ]; then # Version number of the server, if Texis: serverversionnum=`sed -n '/^Server: /s@^[^/]*/\([0-9.]*\).*@\1@p' <$TmpFile` fi installversion=`$BinDir/texis -dump | sed -n '/Version/s@^.*Version @@p'` # Look for monitor errors; usually caused by non-uniform user/permissions: moncode=`sed -n '/Monitor.*exit code/s@.* exit code \([0-9][0-9]*\).*@\1@p' <$TmpFile` if [ "$moncode" != "" ]; then cat <${vc}-tmp rm -f $vc mv -f ${vc}-tmp $vc optchown $vc if [ "$servertype" = vhttpd ]; then if [ "$userid" = 0 ]; then $BinDir/vhttpd -d $SERVER_ROOT else cat </dev/null 2>&1; then rm -f $dest fi if [ -f $dest ]; then rm -f ${dest}-old mv $dest ${dest}-old fi # Link the patent script back to the tutorial: if [ "$f" = "patent" -a "`sed -n '/tutorial/p' <$src`" = "" ]; then sed '/>=" "" $urlroot>\ Return to tutorial

' <$src >$dest else cp $src $dest fi chmod u+rw,go=r $dest >/dev/null 2>&1 optchown $dest echo $EchoArg ".$EchoSfx" done optchown $SampleDir echo "done" fi ############################################################################## # Install Webinator, if present: WebinatorDir=$DocDir/webinator WebBin=$WebinatorDir/bin WebDirIsInstallWeb= if [ "$havewebinator" = "y" ]; then WebDirIsInstallWeb=n if [ $WebinatorDir = $InstallDir/webinator ]; then WebDirIsInstallWeb=y else x=`date '+%Y%m%d%H%M%S'`$$ echo $x >$InstallDir/webinator/.test 2>/dev/null y=`cat $WebinatorDir/.test 2>/dev/null` rm -f $InstallDir/webinator/.test if [ "$x" = "$y" ]; then WebDirIsInstallWeb=y fi fi echo "Installing Webinator" if [ ! -d $WebBin ]; then mkdir -p $WebBin || bail fi optchown $WebinatorDir $WebBin chmod u+rwx,go+rx $WebinatorDir $WebBin >/dev/null 2>&1 if [ ! -d $WebBin ]; then echo "Can't create directory $WebBin" bail fi # Fix CGI dir, document root in some files: cgiurlpath=`echo $CgiUrl | sed 's@^http://[^/]*@@'` for file in newindex.html newsearch; do src=$InstallDir/webinator/$file if [ -f $src ]; then sed -e "s@/cgi-bin/texis@$cgiurlpath/texis$CgiTmpExt$CgiExt@g" -e "s@/usr2/pub/httpd/htdocs@$DocDir@g" <$src >${src}-tmp rm -f $src mv -f ${src}-tmp $src optchown $src chmod u+rw,go+r $src fi done # Back up or remove some existing files: if [ "$WebDirIsInstallWeb" != "y" ]; then for file in geturl gw texis $WebExtraSrc; do if issymlink $WebBin/$file; then rm -f $WebBin/$file elif cmp $WebBin/$file $BinDir/$file >/dev/null 2>&1; then rm -f $WebBin/$file fi if [ -f $WebBin/$file ]; then rm -f $WebBin/${file}-old >/dev/null 2>&1 mv -f $WebBin/$file $WebBin/${file}-old >/dev/null 2>&1 fi done fi # Allow access to $WebinatorDir, in case $InstallDir/.htaccess prevents it: mkhtaccess $WebinatorDir allow # Prevent access to $WebBin: mkhtaccess $WebBin # Install most files (see also dowalk patch below): dowalkloc=$InstallDir/webinator/dowalk if [ "$WebDirIsInstallWeb" != "y" ]; then ln -s $BinDir/gw $WebBin/gw for file in bar0.gif bar1.gif button0.gif button1.gif tstonebut.gif newindex.html $WebExtraSrc; do if [ "$WEBINATOR4" = "y" ]; then cp $InstallDir/webinator/$file $WebinatorDir/$file || bail optchown $WebinatorDir/$file elif [ -f $InstallDir/webinator/$file ]; then cp $InstallDir/webinator/$file $WebinatorDir/$file optchown $WebinatorDir/$file fi done f=$InstallDir/webinator/webinator4man.pdf if [ -f $f ]; then cp $f $WebinatorDir/webinator4man.pdf fi dowalkloc=$WebinatorDir/dowalk fi optchown $WebBin chmod u+rwx,go+rx $WebinatorDir $WebBin >/dev/null 2>&1 chmod u+rw,go+r $WebinatorDir/* $WebBin/* >/dev/null 2>&1 $BinDir/gwpatch -d$WebinatorDir/db $BinDir/gw || bail # re-suid because gwpatch touched it: if [ "$userid" != "0" -o "$chownstatus" = "y" ]; then if chmod u+s $BinDir/gw; then : ; else chmodstatus=n; fi fi # update for find -newer: cp /dev/null $BinDir/.tmpdir >/dev/null 2>&1 # patch texis.cnf[.sample] for dowalk location: if [ "$WEBINATOR4" = "y" ]; then tc=$InstallDir/texis.cnf for file in $tc ${tc}.sample; do if [ -f $file ]; then sed '/dowalk *=/s@^.*$@'"dowalk = $dowalkloc@" <$file >${file}.tmp mv -f ${file}.tmp $file optchown $file fi done # make sure there's a live texis.cnf, and it has [Webinator] dowalk: if [ ! -f $tc ]; then mv -f ${tc}.sample $tc || bail fi if [ "`sed -n '/^ *dowalk *=/p' <$tc`" = "" ]; then echo '[Webinator]' >>$tc echo "dowalk = $dowalkloc" >>$tc fi optchown $tc fi # Determine what to name search script, possibly prompting user. # Try "search" first, then newsearch or search4: src=$InstallDir/webinator/$WebSearchSrc if [ ! -f $src ]; then echo "$src is missing" bail fi WebSearchInstall=search dest=$WebinatorDir/$WebSearchInstall WebSearchAlreadyInst=n if cmp $dest $src >/dev/null 2>&1; then if [ "$WebDirIsInstallWeb" = "y" ]; then WebSearchAlreadyInst=y else rm -f $dest fi fi if [ "$WebSearchAlreadyInst" != "y" -a -f $dest ]; then WebSearchInstall=$WebSearchSrc dest=$WebinatorDir/$WebSearchInstall if cmp $dest $src >/dev/null 2>&1; then rm -f $dest; fi if [ -f $dest ]; then cat < reads: <\$searchscript = "$WebSearchInstall"> EOF fi WebSearchInstall= ack break ;; esac echo "Please answer y or n." done fi fi # Install the search script, and patch dowalk to reflect installed search: if [ "$WebSearchInstall" != "" ]; then if [ "$WEBINATOR4" = "y" ]; then dsrc=$InstallDir/webinator/dowalk sed 's@<.searchscript *=[^>]*>@<$searchscript = "'$WebSearchInstall'">@' <$dsrc >${dsrc}-tmp rm -f $dsrc mv -f ${dsrc}-tmp $dsrc optchown $dsrc chmod u+rw,go+r $dsrc >/dev/null 2>&1 if [ "$WebDirIsInstallWeb" != "y" ]; then d=$WebinatorDir/dowalk rm -f $d cp $dsrc $d || bail optchown $d chmod u+rw,go+r $d >/dev/null 2>&1 fi fi if [ "$WebSearchAlreadyInst" != "y" ]; then rm -f $dest cp $src $dest || bail fi optchown $dest chmod u+rw,go+r $dest >/dev/null 2>&1 # Patch testdb/index now that we know the installed search script: comptestdb= if [ "$TestDbIndexInst" != "" ]; then sed 's@/webinator/search@/webinator/'$WebSearchInstall'@g' <$TestDbIndexInst >${TestDbIndexInst}-tmp rm -f $TestDbIndexInst mv -f ${TestDbIndexInst}-tmp $TestDbIndexInst optchown $TestDbIndexInst chmod u+rw,go+r $TestDbIndexInst comptestdb=y fi # Also patch webinator/[new]index.html, for search and admin scripts: file=$InstallDir/webinator/newindex.html if [ -f $file ]; then if [ "$WEBINATOR4" = "y" ]; then # Remove link to search 'face: user finds it from admin 'face # so they'll do a walk first. Also fix link to admin 'face (dowalk): sed -e "/newsearch/d" -e '/documentation/s@/webinator@/site/webinator4man@' -e 's@".*dowalk/"@"'"$cgiurlpath/texis$CgiTmpExt$CgiExt/webinator/dowalk/"'"@' <$file >${file}-tmp else sed "s@/newsearch@/$WebSearchInstall@g" <$file >${file}-tmp fi rm -f $file mv -f ${file}-tmp $file if [ "$WebDirIsInstallWeb" != "y" ]; then rm -f $WebinatorDir/newindex.html cp $file $WebinatorDir/newindex.html fi optchown $file $WebinatorDir/newindex.html chmod u=rw,go+r $file $WebinatorDir/newindex.html fi fi # Possibly make newindex.html live: if [ -f $WebinatorDir/newindex.html ]; then if [ -f $WebinatorDir/index.html ]; then echo "Existing $WebinatorDir/index.html preserved." if cmp $WebinatorDir/newindex.html $WebinatorDir/index.html >/dev/null 2>&1; then rm -f $WebinatorDir/newindex.html WebIndex=index.html else echo "New sample in $WebinatorDir/newindex.html." WebIndex=newindex.html fi else mv $WebinatorDir/newindex.html $WebinatorDir/index.html if [ "$WebDirIsInstallWeb" != "y" ]; then mv $InstallDir/webinator/newindex.html $InstallDir/webinator/index.html fi WebIndex=index.html fi fi if [ -f $CgiDir/webinator ]; then cat < line in dowalk to complete the installation. \$searchscript should be the file you copied $WebSearchSrc to. EOF fi cat <