#!/bin/bash
#!/usr/bin/ksh #Try this or some other first line if above doesn\'t work
#Copyright Olaf Kayser 2006- (Open Source/GNU Affero General Public License)
#20060425: Major overhaul
#TO DO:
# Check that export X=something works (or change to: X=something ; export X)
function warning() {
echo '!!' $* '!!'
}
function errorexit() {
echo $*
echo Installation aborted.
exit 1
}
echo Current directory: $PWD
echo
echo '-------'
echo Checking python is available/executable and above 1.5.2
python > tempfile <
import sys
version = sys.version
if version[0] >= '2' :
print version
?
if [ "$?" -ne 0 ]
then
errorexit "Not able to execute python"
fi
if [ ! -s tempfile ]
then
warning "Too old version of python. Must be Python2.? or higher.\n\n\n"
fi
echo
echo '-------'
echo Checking availability of either sed or ed
export SED=`which sed` # Using sed if available
if [ ! -x "$SED" ]
then
export ED=`which ed`
if [ ! -x "$ED" ]
then
errorexit "Neither sed nor ed available. Installation aborted."
fi
# ed available, we'll try using it:
SED=''
fi
echo
echo '-------'
echo Checking path and name of current directory
echo Current directory: $PWD
python <
import os, sys, re
re_installdir = re.compile( r'.*/quizcomposerinstall.d/20[0-9]+$' )
pwd = os.getcwd()
if re_installdir.match( pwd ) :
print "In right dir"
sys.exit( 0 )
else :
print "Not in right dir"
sys.exit( 1 )
?
status=$?
echo Status for checking path and name of current directory: $status
if [ $status -ne 0 ]
then
echo Current directory is not ?/quizcomposerinstall.d/20??
qci=$HOME/quizcomposerinstall.d
echo qci: $qci \(value of \$HOME/quizcomposerinstall.d\)
if [ ! -d $qci ]
then
echo directory $HOME/quizcomposerinstall.d does not exist
echo Attempting to create directory $qci
mkdir $qci
if [ $? -ne 0 ]
then
warning "Not able to create $qci. Staying in current directory $PWD"
qci=
else
echo Created directory $cgi \(cgi\)
fi
fi
if [ -n "$qci" ]
then # creating an install directory under $qci,
# copying this program and install.var* there,
# moving there,
# and executing this this program there.
today=`date +'%Y%m%d'`
echo Creating an install directory $today under $qci
INSTALLD=$qci/$today
if [ -d $INSTALLD ]
then
echo This program \($0\) prefers to be executed in $INSTALLD
else
echo This program \($0\) prefers to be executed in $INSTALLD \
which will be created now
mkdir $INSTALLD
if [ $? -ne 0 ]
then
errorexit "Not able to create $INSTALLD"
else
echo Created directory $INSTALLD \(INSTALLD\)
fi
fi
thisprog=`basename $0`
if [ -f install.var.txt ]
then
cp install.var.txt $INSTALLD
echo You should consider deleting install.var.txt from $PWD
else
echo File install.var.txt does not exist
fi
for j in $thisprog install.var install.tgz
do
if [ -f $j ]
then
echo Copying $j to $INSTALLD
cp $j $INSTALLD
if [ $? -ne 0 ]
then
warning "Not able to copy $j to $INSTALLD"
bailing_out=1
fi
echo You should consider deleting $j from $PWD
else
warning "File $j is missing. It is undispensable for successful installation"
fi
done
if [ "$bailing_out" ]
then
errorexit "Not able to copy intstall files to $INSTALLD"
fi
cd $INSTALLD
echo Starting this program \($0\) in directory $PWD
. $thisprog
exit 0
fi
echo Continuing execution of this program \($0\) in directory $PWD
fi
echo
echo '-------'
echo Attempting to read install variables
echo Current directory: $PWD
if [ -f install.var ]
then
echo Setting the following install variables from install.var:
cat install.var
. ./install.var
else
echo File install.var not esistent
if [ -f install.var.txt ]
then
echo Setting the following install variables from install.var.txt:
echo Copying file install.var.txt to file install.var
cp install.var.txt install.var
cat install.var
. ./install.var
else
echo File install.var, and install.var.txt, missing.
echo Attempting to set install variables.
> install.var
if [ $? -ne 0 ]
then
errorexit "Current directory $PWD has no permission to write file"
fi
fi
fi
echo creating extract \(install.var.xtr\) of install.var with definitions only
grep '^ *export' install.var > install.var.xtr
echo
echo '-------'
echo Checking important install variables have been defined in file install.var.
echo Otherwise attemting to define them
echo Current directory: $PWD
function addToInstallvar() {
echo Setting $1
edit_install_var=1
if [ ! -f 0install.var ]
then
cp install.var 0install.var
echo >> install.var
echo \# Added `date '+%Y%m%d'` by $0: >> install.var
fi
echo Adding export $1 in file install.var
echo export $1 >> install.var
}
if [ -n "$PYTHON" ]
then
if [ ${PYTHON:0:1} != '/' ]
then
errorexit $PYTHON ' is not an absolute path and name (must start with /)'
fi
echo Variable PYTHON was defined: $PYTHON
else
export PYTHON=`which python`
if [ ! "$PYTHON" ]
then
echo "Not able to set install variable PYTHON to a useful value"
errorexit "Current search PATH=$PATH"
fi
addToInstallvar "PYTHON=$PYTHON"
fi
if [ -n "$MAIL" ]
then
echo Variable MAIL was defined: $MAIL
else
echo Attempting to set a value for MAIL
export MAIL=`which mail`
if [ ! "$MAIL" ]
then
export MAIL=`which xmail`
fi
if [ ! "$MAIL" ]
then
warning "Not able to set install variable MAIL to a useful value"
fi
addToInstallvar "MAIL=$MAIL"
fi
if [ -n "$ADMINPASSWORD" ]
then
echo ADMINPASSWORD was defined: $ADMINPASSWORD
else
echo Attempting to set a value for ADMINPASSWORD
# python > tempfile <
$PYTHON > tempfile <
import whrandom
x = whrandom.random() * 1000000000
print '%8X' % (int(x))
?
export ADMINPASSWORD=`cat tempfile`
rm tempfile
addToInstallvar "ADMINPASSWORD=$ADMINPASSWORD"
fi
if [ -n "$TESTPASSWORD" ]
then
echo Variable TESTPASSWORD was defined: $TESTPASSWORD
else
echo Attempting to set a value for TESTPASSWORD
export TESTPASSWORD=$ADMINPASSWORD
addToInstallvar "TESTPASSWORD=$TESTPASSWORD"
fi
if [ -n "$QUIZCOMPOSERNAME" ]
then
echo Variable QUIZCOMPOSERNAME was defined: $QUIZCOMPOSERNAME
else
echo Attempting to set a value for QUIZCOMPOSERNAME
export QUIZCOMPOSERNAME=quizcomposer
addToInstallvar "QUIZCOMPOSERNAME=$QUIZCOMPOSERNAME"
fi
if [ -n "$QUIZCOMPOSERPARENT" ]
then
echo Variable QUIZCOMPOSERPARENT was defined: $QUIZCOMPOSERPARENT
else
echo Attempting to set a value for QUIZCOMPOSERPARENT
for j in $HOME $PWD $HOME/tmp /tmp
do
if [ -d "$j" ]
then
echo Attempting to set QUIZCOMPOSERPARENT to $j
if [ -d $j/$QUIZCOMPOSERNAME ]
then
echo $j/$QUIZCOMPOSERNAME exists
export QUIZCOMPOSERPARENT=$j
break
else
echo $j/$QUIZCOMPOSERNAME does not exist
echo Attempting to create $j/$QUIZCOMPOSERNAME
mkdir $j/$QUIZCOMPOSERNAME
if [ $? -eq 0 ]
then
echo Able to create $j/$QUIZCOMPOSERNAME # use this $j
export QUIZCOMPOSERPARENT=$j
break
fi
fi
fi
done
if [ -z "$QUIZCOMPOSERPARENT" ]
then
errorexit "Not able to set install variable QUIZCOMPOSERPARENT to a useful value"
fi
addToInstallvar "QUIZCOMPOSERPARENT=$QUIZCOMPOSERPARENT"
fi
if [ -n "$USER" ]
then
echo Your identity is assumed to be $USER
else
echo Attempting to set a value for USER
USER=`id -nu`
echo Attempt 1: USER=$USER
if [ $? -ne 0 ]
then
USER=`whoami`
fi
echo Attempt 2: USER=$USER
if [ "$USER" ]
then
echo Your identity \(USER\) is assumed to be $USER
else
warning "Not able to determine your identity \(USER\)"
fi
fi
# TODO: check following useful on SUN server:
echo Current directory: $PWD
echo Examining \$DOMAIN: $DOMAIN
echo and \$HTMLDIR: $HTMLDIR
echo and \$CGIBINDIR: $CGIBINDIR
echo and \$CGINAME: $CGINAME
if [ ! \( "$DOMAIN" -a "$HTMLDIR" -a "$CGIBINDIR" -a "$CGINAME" \) ]
then
echo One of the variables above had empty value
echo Attempting to set a value for conf
for j in common\*httpd\*.conf httpd\*.conf
do
echo Searching for web server configuration file $j in /etc
conf=`find /etc -name $j -type f 2>/dev/null`
if [ "$conf" ]
then
more_than_one=`echo $conf | grep ' '`
if [ ! "$more_than_one" ]
then
echo File $conf assumed to be server configuration file
break
fi
fi
done
fi
echo Examining conf: $conf
if [ -z "$conf" ]
then
echo Not able to find a server configuration file
else
echo Searching for User at start of a line in $conf
userline=`grep '^User' $conf`
if [ -n "$userline" ]
then
serveruser=`echo $userline | cut -d' ' -f2`
else
echo No User at start of a line in $conf
fi
if [ "$USER" = "$serveruser" ]
then
serverowner=1
echo According to the configuration file you \($USER\) are the serveruser \($serveruser\)
else
echo WARNING: According to the configuration file you \($USER\) are NOT the serveruser \($serveruser\)
echo Possibly, you are the owner of a virtual host
echo See server configuration file $conf
notserverowner=1
fi
fi
echo Examining \$DOMAIN: $DOMAIN
if [ -n "$DOMAIN" ]
then
echo Variable DOMAIN was defined: $DOMAIN
domain_stated=1
else
echo Attempting to set a value for DOMAIN
if [ ! "$HOSTNAME" ]
then
HOSTNAME=`hostname`
if [ $? -ne 0 ]
then
echo 'Executing HOSTNAME=`cat /etc/hostname`'
HOSTNAME=`cat /etc/hostname`
else
echo 'Command `hostname` gave empty result'
fi
fi
if [ -z "$HOSTNAME" ]
then
errorexit "Not able to determine name \(HOSTNAME\) of this host"
fi
if [ "$HOSTNAME" -a "$serverowner" ]
then
echo Executing export DOMAIN=$HOSTNAME
export DOMAIN=$HOSTNAME
fi
if [ -z "$DOMAIN" ]
then
errorexit "Not able to set install variable DOMAIN"
fi
warning "Variable DOMAIN may have been set wrongly to $DOMAIN"
addToInstallvar "DOMAIN=$DOMAIN"
fi
echo Examining ADMINMAILADDRESS: $ADMINMAILADDRESS
if [ -n "$ADMINMAILADDRESS" ]
then
echo Variable ADMINMAILADDRESS was defined: $ADMINMAILADDRESS
else
echo Attempting to set a value for ADMINMAILADDRESS
if [ -n "$DOMAIN" ]
then
export ADMINMAILADDRESS=$USER@$DOMAIN
addToInstallvar "ADMINMAILADDRESS=$ADMINMAILADDRESS"
else
errorexit "Not able to set install variable ADMINMAILADDRESS"
fi
fi
echo Examining \$TESTMAILADDRESS: $TESTMAILADDRESS
if [ -n "$TESTMAILADDRESS" ]
then
echo Variable TESTMAILADDRESS was defined: $TESTMAILADDRESS
else
echo Attempting to set a value for TESTMAILADDRESS
if [ "$DOMAIN" ]
then
export TESTMAILADDRESS=xxxxxx@$DOMAIN
else
errorexit "Not able to set install variable TESTMAILADDRESS to a useful value"
fi
addToInstallvar "TESTMAILADDRESS=$TESTMAILADDRESS"
fi
echo Examining HTMLDIR: $HTMLDIR
if [ -n "$HTMLDIR" ]
then
echo Variable HTMLDIR was defined: $HTMLDIR
else
echo Attempting to set a value for \$HTMLDIR
if [ "$serverowner" ]
then
echo Searching for DocumentRoot at start of a line in $conf
documentrootline=`grep '^DocumentRoot' $conf`
if [ "$documentrootline" ]
then
export HTMLDIR=`echo $documentrootline | cut -d' ' -f2`
fi
else # not serverowner, probably ordinary user
if [ -d /home ]
then
echo Searching for directory html, htdocs, public_html, www or web in /home
for j in html htdocs public_html www web
do
echo 'Executing export HTMLDIR=`find /home -name $j`'
export HTMLDIR=`find /home -name $j`
if [ -n "$HTMLDIR" ]
then
if [ -d "$HTMLDIR" ]
then
break
fi
else
echo Variable HTMLDIR got value $HTMLDIR
fi
done
else # maybe owner of virtual host
if [ "$domain_stated" -a "$conf" ]
then
virtualdomain=`grep "ServerName *${DOMAIN}" $conf`
if [ "$virtualdomain" ]
then
echo $DOMAIN presumably defined virtual in $conf
$PYTHON > tempfile <
searched = '$DOMAIN'
file = '$conf'
# set htmldir
import string
domain = htmldir = ''
f = open( file )
while 1 :
line = f.readline()
if not line :
break
if string.find( line, '= 0 :
domain = htmldir = ''
while 1 :
line = f.readline()
if string.find( line, 'ServerName' ) >= 0 :
domain = string.strip( string.replace( line, 'ServerName', '' ) )
elif string.find( line, 'DocumentRoot' ) >= 0 :
htmldir = string.strip( string.replace( line, 'DocumentRoot', '' ) )
elif string.find( line, '= 0 :
break
if domain == searched :
break
# TODO: consider possible use of UserDir and VirtualDocumentRoot
f.close()
if domain != searched :
htmldir = ''
print htmldir,
?
echo 'Executing export HTMLDIR=`cat tempfile`'
export HTMLDIR=`cat tempfile`
echo Removing tempfile
rm tempfile
fi
fi
fi
fi
if [ -z "$HTMLDIR" ]
then
warning "Not able to set install variable HTMLDIR. Try doing it manually."
fi
addToInstallvar "HTMLDIR=$HTMLDIR"
fi
# TODO: check the following:
echo Examining CGIBINDIR: $CGIBINDIR
if [ -z "$CGIBINDIR" ]
then
echo Attempting to set a value for CGIBINDIR
edit_install_var=1
if [ -n "$serverowner" ]
then
echo Variable serverowner has value $serverowner
echo Searching for ScriptAlias at start of a line in $conf
echo 'Executing scriptaliasline=`grep '^ScriptAlias' $conf`'
scriptaliasline=`grep '^ScriptAlias' $conf`
if [ -n "$scriptaliasline" ]
then
echo scriptaliasline has value $scriptaliasline
export CGINAME=`echo -n $scriptaliasline | cut -d' ' -f2`
export CGIBINDIR=`echo -n $scriptaliasline | cut -d' ' -f3`
else
echo scriptaliasline was empty
fi
else # not serverowner, probably ordinary user
echo Installer does not appear to be serverowner, probably ordinary user
echo Looking into /home
if [ -d /home ]
then
echo Searching for directory cgi-bin or cgi in /home
echo Search may take a while
for j in cgi-bin cgi
do
echo j: $j
echo 'Executing export CGIBINDIR=`find /home -name $j`'
export CGIBINDIR=`find /home -name $j`
if [ -n "$CGIBINDIR" ]
then
echo CGIBINDIR: $CGIBINDIR
if [ -d "$CGIBINDIR" ]
then
echo CGIBINDIR is a directory
break
fi
fi
done
else # maybe owner of virtual host
echo Considering installer maybe owner of virtual host
if [ "$domain_stated" -a "$conf" ]
then
echo 'Executing virtualdomain=`grep "ServerName *$DOMAIN" $conf`'
virtualdomain=`grep "ServerName *$DOMAIN" $conf`
if [ -n "$virtualdomain" ]
then
echo virtualdomain: $virtualdomain
echo $DOMAIN presumably defined virtual in $conf
$PYTHON > tempfile <
searched = '$DOMAIN'
file = '$conf'
# set cginame_cgibindir
import string
domain = cgi_cgibin = ''
f = open( file )
while 1 :
line = f.readline()
if not line :
break
if string.find( line, '= 0 :
domain = htmldir = ''
while 1 :
line = f.readline()
if string.find( line, 'ServerName' ) >= 0 :
domain = string.strip( string.replace( line, 'ServerName', '' ) )
elif string.find( line, 'ScriptAlias' ) >= 0 :
cginame_cgibindir = string.strip( string.replace( line, 'ScriptAlias', '' ) )
elif string.find( line, '= 0 :
break
if domain == searched :
break
# TODO: consider possible use of ScriptAliasMatch
f.close()
if domain != searched :
cginame_cgibindir = ''
print cginame_cgibindir,
?
echo 'Executing cginame_cgibindir=`cat tempfile`'
cginame_cgibindir=`cat tempfile`
echo cginame_cgibindir: $cginame_cgibindir
echo CGINAME: $CGINAME
echo CGIBINDIR: $CGIBINDIR
echo "Executing export CGINAME=`echo -n $cginame_cgibindir | cut -d' ' -f2`"
export CGINAME=`echo -n $cginame_cgibindir | cut -d' ' -f2`
echo "Executing export CGIBINDIR=`echo -n $cginame_cgibindir | cut -d' ' -f3`"
export CGIBINDIR=`echo -n $cginame_cgibindir | cut -d' ' -f3`
echo Removing tempfile
rm tempfile
fi
fi
fi
fi
if [ -z "$CGIBINDIR" ]
then
errorexit "Not able to set install variable CGIBINDIR. Try doing it manually."
fi
addToInstallvar "CGIBINDIR=$CGIBINDIR"
if [ -z "$CGINAME" ]
then
errorexit "Not able to set install variable CGINAME. Try doing it manually."
fi
addToInstallvar "CGINAME=$CGINAME"
fi
echo Examining \$LEVEL: $LEVEL
if [ -z "$LEVEL" ]
then
export LEVEL='min'
addToInstallvar "LEVEL=$LEVEL"
else
if [ \( "$LEVEL" != 'max' \) -a \( "$LEVEL" != 'min' \) ]
then
warning 'Bad value for variable LEVEL:' $LEVEL
export LEVEL='min'
addToInstallvar "LEVEL=$LEVEL"
fi
fi
echo Examining HTACCESS: $HTACCESS
if [ -z "$HTACCESS" ]
then
echo Executing export HTACCESS=''
export HTACCESS=''
else
if [ "$HTACCESS" -eq '1' ]
then
echo Executing HTACCESS='Options -Indexes'
HTACCESS='Options -Indexes'
fi
fi
echo Examining edit_install_var: $edit_install_var
if [ "$edit_install_var" ]
then
echo File install.var has been augmented with new definitions.
echo "You can either go to directory $PWD and edit file install.var or"
echo "alter the definitions in the install.htm file (assuming you are"
echo "installing using that file and install.py via the WEB)."
echo "The new definitions/values can be seen above."
exit 1
fi
export INSTALLD=`pwd` # process in install directory
echo INSTALLD set to: $INSTALLD
export MODE700=700
export MODE755=755
export MODE600=600
export MODE644=644
echo Examining GROUPPERM: $GROUPPERM
if [ -n "$GROUPPERM" ]
then
MODE700=770
MODE755=775
MODE600=660
MODE644=664
fi
echo MODE700 set to: $MODE700
echo MODE775 set to: $MODE775
echo MODE660 set to: $MODE660
echo MODE664 set to: $MODE664
echo Setting access rights $MODE700 for current directory: $PWD \($INSTALLD\)
chmod $MODE700 .
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE700 .'
echo Could not chmod $MODE700 .
echo ls -ld . results in:
ls -ld .
echo Installation aborted.
errorexit
fi
echo Executing export QUIZCOMPOSER=$QUIZCOMPOSERPARENT/$QUIZCOMPOSERNAME
export QUIZCOMPOSER=$QUIZCOMPOSERPARENT/$QUIZCOMPOSERNAME
echo Examining \$QUIZCOMPOSER: $QUIZCOMPOSER
if [ -d $QUIZCOMPOSER ]
then
echo Directory $QUIZCOMPOSER exists
else
echo Directory $QUIZCOMPOSER non-existent. Attempting to create it.
mkdir $QUIZCOMPOSER
if [ $? -ne 0 ]
then
errorexit "Could not create $QUIZCOMPOSER"
else
echo Created $QUIZCOMPOSER
fi
echo Executing chmod $MODE755 $QUIZCOMPOSER
chmod $MODE755 $QUIZCOMPOSER
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE755 $QUIZCOMPOSER'
echo 'Could not chmod $MODE755 $QUIZCOMPOSER'
echo ls -ld $QUIZCOMPOSER results in:
ls -ld $QUIZCOMPOSER
errorexit
else
echo Mode $MODE755 set for $QUIZCOMPOSER
fi
fi
echo Examining HTMLDIR: $HTMLDIR
if [ -d $HTMLDIR ]
then
echo Directory $HTMLDIR exists
else
echo $HTMLDIR non-existent. Attempting to create it.
mkdir $HTMLDIR
if [ $? -ne 0 ]
then
errorexit "Could not create $HTMLDIR"
fi
fi
echo Examining CGIBINDIR: $CGIBINDIR
if [ -d $CGIBINDIR ]
then
echo Directory $CGIBINDIR exists
else
mkdir $CGIBINDIR
if [ $? -ne 0 ]
then
errorexit "Could not create $CGIBINDIR"
fi
fi
echo Examining \$INSTALLD/install.tgz: $INSTALLD/install.tgz
if [ -f $INSTALLD/install.tgz ]
then
echo Renaming $INSTALLD/install.tgz to $INSTALLD/install.tar.gz
mv $INSTALLD/install.tgz $INSTALLD/install.tar.gz
if [ $? -ne 0 ]
then
errorexit "Could not rename $INSTALLD/install.tgz to $INSTALLD/install.tar.gz"
fi
else
echo File $INSTALLD/install.tgz non-existant. Looking for $INSTALLD/install.tar.gz
fi
echo Examining \$INSTALLD/install.tar.gz: $INSTALLD/install.tar.gz
if [ -f $INSTALLD/install.tar.gz ]
then
echo Removing $INSTALLD/install.tar before unzipping $INSTALLD/install.tar.gz
rm -f $INSTALLD/install.tar
if [ $? -ne 0 ]
then
errorexit "Could not remove $INSTALLD/install.tar"
fi
gunzip $INSTALLD/install.tar.gz
if [ $? -ne 0 ]
then
errorexit "Could not unzip $INSTALLD/install.tar.gz"
fi
else
echo File $INSTALLD/install.tar.gz non-existant. Looking for $INSTALLD/install.tar
fi
echo Examining \$INSTALLD/install.tar: $INSTALLD/install.tar
if [ ! -f $INSTALLD/install.tar ]
then
errorexit "File $INSTALLD/install.tar missing"
else
echo File $INSTALLD/install.tar exists
fi
echo '-------'
echo 'Saving information about $HTMLDIR by executing: ls -l $HTMLDIR > ls-l_HTMLDIR'
ls -l $HTMLDIR > ls-l_HTMLDIR
if [ $? -eq 0 ]
then
echo Completed
else
warning "Error while executing ls -l $HTMLDIR > ls-l_HTMLDIR"
fi
echo
echo '-------'
echo HTMLDIR is $HTMLDIR
echo CGIBINDIR is $CGIBINDIR
echo QUIZCOMPOSER is $QUIZCOMPOSER
echo Current directory is $PWD
echo Examining saved.tgz exists and is a file
if [ -f saved.tgz ]
then
echo File saved.tgz exists.
ls -ld saved.tgz
else
if [ -n "$SAVE_CURRENT" ]
then
#TODO: rewrite to directly save contents of author and course directories:
echo 'File saved.tgz non-existant'
echo Saving current \(accessible\) contents of
echo $HTMLDIR $CGIBINDIR $QUIZCOMPOSER in saved.tgz:
echo Executing tar -cf - $HTMLDIR $CGIBINDIR $QUIZCOMPOSER ...
tar -cf - $HTMLDIR $CGIBINDIR $QUIZCOMPOSER 2>/dev/null | gzip > saved.tgz
echo Executing chmod $MODE600 saved.tgz
chmod $MODE600 saved.tgz
echo Current directory: $PWD
ls -ld saved.tgz
fi
fi
if [ $DOMAIN = 'www.quizcomposer.dk' ]
then
echo "Saving files $QUIZCOMPOSER/html.d/examples_*.htm"
cp $QUIZCOMPOSER/html.d/examples*.htm $INSTALLD
fi
echo '-------'
cd $QUIZCOMPOSER
echo Current directory: $PWD
echo Cleaning $QUIZCOMPOSER \(leaving author directories intact\)
echo 'Executing rm -rf mod_* phrase_* [b-z]*.d [a-z]*.py *.sh'
rm -rf mod_* phrase_* [b-z]*.d [a-z]*.py *.sh
if [ $? -eq 0 ]
then
echo Completed
else
errorexit 'Error while executing rm -rf mod_* phrase_* [b-z]*.d [a-z]*.py *.sh'
fi
echo Executing rm -rf cornerlogo.txt domaindependent.txt phrase_dk.txt phrase_en.txt
rm -rf cornerlogo.txt domaindependent.txt phrase_dk.txt phrase_en.txt
if [ $? -eq 0 ]
then
echo Completed
else
errorexit 'Error while executing rm -rf cornerlogo.txt domaindependent.txt phrase_dk.txt phrase_en.txt'
fi
echo 'Executing rm -rf mkmod* mkpag* mkcgibin.sh'
rm -rf mkmod* mkpag* mkcgibin.sh
if [ $? -eq 0 ]
then
echo Completed
else
errorexit 'Error while executing rm -rf mkmod* mkpag* mkcgibin.sh'
fi
echo Only left in $QUIZCOMPOSER: \(executing ls -al in current directory $PWD\)
ls -al
echo '-------'
cd $QUIZCOMPOSER
echo Generating new contents in current directory $QUIZCOMPOSER
echo Executing tar xpf $INSTALLD/install.tar
tar xpf $INSTALLD/install.tar
if [ $? -eq 0 ]
then
echo Completed
else
errorexit "Error while executing tar xpf $INSTALLD/install.tar"
fi
echo
echo '-------'
echo \(Re\)creating $INSTALLD/install.tgz \(excuting gzip $INSTALLD/install.tar\)
gzip $INSTALLD/install.tar
if [ $? -eq 0 ]
then
echo Completed
else
errorexit "Error while executing gzip $INSTALLD/install.tar"
fi
echo Executing mv $INSTALLD/install.tar.gz $INSTALLD/install.tgz
mv $INSTALLD/install.tar.gz $INSTALLD/install.tgz
echo
echo '-------'
cd $QUIZCOMPOSER
echo Executing rm -f '*.py' in order to avoid any rogue file '*.py'
rm -f '*.py'
echo Setting full path to Python interpreter in 1st line of Python-programs
for prog in *.py *.d/*.py
do
echo prog: $prog
if [ "$SED" ]
then
sed "1s+.*+\#!$PYTHON+" $prog > fil
mv fil $prog
else
ed -s $prog > /dev/null <
1s+.*+\#!$PYTHON+
w
q
?
fi
done
echo
echo '-------'
cd $QUIZCOMPOSER
echo Computing relative path from $HTMLDIR to $QUIZCOMPOSER
HTMLDIR2QUIZCOMPOSER=`$PYTHON rqstinst.d/relpath.py $HTMLDIR $QUIZCOMPOSER`
echo HTMLDIR2QUIZCOMPOSER: $HTMLDIR2QUIZCOMPOSER
echo Computing relative path from $CGIBINDIR to $QUIZCOMPOSER
CGIBINDIR2QUIZCOMPOSER=`$PYTHON rqstinst.d/relpath.py $CGIBINDIR $QUIZCOMPOSER`
echo CGIBINDIR2QUIZCOMPOSER: $CGIBINDIR2QUIZCOMPOSER
echo Computing relative path from $CGIBINDIR to $HTMLDIR
CGIBINDIR2HTMLDIR=`$PYTHON rqstinst.d/relpath.py $CGIBINDIR $HTMLDIR`
echo CGIBINDIR2HTMLDIR: $CGIBINDIR2HTMLDIR
echo
echo '-------'
cd $QUIZCOMPOSER
echo Current directory: $PWD
echo Adjusting $QUIZCOMPOSER/domaindependent.txt
if [ -n "$SED" ]
then
sed -e "/^admin=/s+=.*+=$ADMINMAILADDRESS+
s+@@+@+
s+\.$++
/^quizhome=/s+=.*+=$QUIZCOMPOSER+
/^cgibin2quizhome=/s+=.*+=$CGIBINDIR2QUIZCOMPOSER+
/^htdocs2quizhome=/s+=.*+=$HTMLDIR2QUIZCOMPOSER+
/^domain=/s+=.*+=$DOMAIN+
/^mail=/s+=.*+=$MAIL+
/^cgibin2htdocs=/s+=.*+=$CGIBINDIR2HTMLDIR+
/^cgibin=/s+=.*+=$CGINAME+
/^mode700=/s+=.*+=$MODE700+
/^mode755=/s+=.*+=$MODE755+
/^mode600=/s+=.*+=$MODE600+
/^mode644=/s+=.*+=$MODE644+
/^htaccess=/s+=.*+=$HTACCESS+" domaindependent.txt > fil
mv fil domaindependent.txt
else
ed -s domaindependent.txt >> /dev/null <
/admin
s+=.*+=$ADMINMAILADDRESS+
s+@@+@+
s+\.$++
/quizhome
s+=.*+=$QUIZCOMPOSER+
/cgibin2quizhome
s+=.*+=$CGIBINDIR2QUIZCOMPOSER+
/htdocs2quizhome
s+=.*+=$HTMLDIR2QUIZCOMPOSER+
/domain
s+=.*+=$DOMAIN+
/mail
s+=.*+=$MAIL+
/cgibin2htdocs
s+=.*+=$CGIBINDIR2HTMLDIR+
/cgibin
s+=.*+=$CGINAME+
/mode700
s+=.*+=$MODE700+
/mode755
s+=.*+=$MODE755+
/mode600
s+=.*+=$MODE600+
/mode644
s+=.*+=$MODE644+
/htaccess
s+=.*+=$HTACCESS+
w
q
?
fi
echo Executing chmod $MODE600 domaindependent.txt
chmod $MODE600 domaindependent.txt
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE600 domaindependent.txt'
echo Could not chmod $MODE600 domaindependent.txt
echo ls -ld . results in:
ls -ld .
errorexit
fi
echo Creation of domaindependent.pkl in $QUIZCOMPOSER
echo Executing $PYTHON mkdomainpkl.py
$PYTHON mkdomainpkl.py
echo Executing ls -ld $QUIZCOMPOSER/domaindependent.pkl
ls -ld $QUIZCOMPOSER/domaindependent.pkl
echo Creating link from $QUIZCOMPOSER/rqstadmin.d to domaindependent.pkl in $QUIZCOMPOSER
echo Executing ln domaindependent.pkl rqstadmin.d/domaindependent.pkl
ln domaindependent.pkl rqstadmin.d/domaindependent.pkl
if [ $? -eq 0 ]
then
echo Completed
else
errorexit 'Error while executing ln domaindependent.pkl rqstadmin.d/domaindependent.pkl'
fi
echo Executing ls -ld rqstadmin.d/domaindependent.pkl
ls -ld rqstadmin.d/domaindependent.pkl
echo
cd $QUIZCOMPOSER
echo Examining existence of file $QUIZCOMPOSER/Permits.txt
if [ -f Permits.txt ]
then
echo File Permits.txt exists
else
echo '-------'
echo Permits.txt does not exist in \$PWD: $PWD
echo Creating Permits.txt
cat > Permits.txt <
admin $ADMINMAILADDRESS
test $TESTMAILADDRESS
?
echo Executing chmod $MODE600 Permits.txt
chmod $MODE600 Permits.txt
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE600 Permits.txt'
echo Could not chmod $MODE600 Permits.txt
echo ls -ld Permits.txt results in:
ls -ld Permits.txt
errorexit
fi
echo Executing ls -ld Permits.txt
ls -ld Permits.txt
echo Executing test ! -d ./test && mkdir $TESTMAILADDRESS ./test
test ! -d ./test && mkdir $TESTMAILADDRESS ./test
echo Storing $TESTPASSWORD in test/password
echo -n $TESTPASSWORD > test/password
echo Executing chmod $MODE755 $TESTMAILADDRESS
chmod $MODE755 $TESTMAILADDRESS
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE755 $TESTMAILADDRESS'
echo Could not chmod $MODE755 $TESTMAILADDRESS
echo ls -ld $TESTMAILADDRESS results in:
ls -ld $TESTMAILADDRESS
errorexit
fi
echo Executing chmod $MODE700 test
chmod $MODE700 test
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE700 test'
echo Could not chmod $MODE700 test
echo ls -ld test results in:
ls -ld test
errorexit
fi
echo Executing chmod $MODE600 test/\*
chmod $MODE600 test/*
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE600 test/*'
echo 'Could not chmod $MODE600 test/*'
echo 'ls -ld test/* results in:'
ls -ld test/*
errorexit
fi
fi
echo Contents of Permits.txt:
cat Permits.txt
echo Creating Permits.pkl \(executing $PYTHON mkpermitspkl.py\)
echo Executing $PYTHON mkpermitspkl.py
$PYTHON mkpermitspkl.py
if [ $? -eq 0 ]
then
echo Completed
else
errorexit "Error while executing $PYTHON mkpermitspkl.py"
fi
echo Executing ls -ld Permits.pkl
ls -ld Permits.pkl
echo
cd $QUIZCOMPOSER
echo Examining existence of directory admin in current directory $PWD
if [ -d admin ]
then
echo Directory admin already exists in $PWD
else
echo '-------'
echo Creating directories for admin
adminmailaddress=$ADMINMAILADDRESS
echo adminmailaddress: $adminmailaddress
echo Executing mkdir $ADMINMAILADDRESS admin
mkdir $ADMINMAILADDRESS admin
chmod $MODE700 $ADMINMAILADDRESS
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE700 $ADMINMAILADDRESS'
echo Could not chmod $MODE700 $ADMINMAILADDRESS
echo ls -ld $ADMINMAILADDRESS results in:
ls -ld $ADMINMAILADDRESS
errorexit
fi
adminpassword=$ADMINPASSWORD
echo Storing value of ADMINPASSWORD in admin/password
echo -n $ADMINPASSWORD > admin/password # REINSTALL SYSTEM WHEN PASSWORD LOST
chmod $MODE700 admin
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE700 admin'
echo Could not chmod $MODE700 admin
echo ls -ld admin results in:
ls -ld admin
errorexit
fi
chmod $MODE600 admin/*
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE600 admin/*'
echo 'Could not chmod $MODE600 admin/*'
echo 'ls -ld admin/* results in:'
ls -ld admin/*
errorexit
fi
if [ -x "$HTMLDIR/admin" ]
then
warning "User admin exists already as a file or symbolic link"
errorexit "It is not being changed. Check it."
else
cd $HTMLDIR
echo Current directory: $PWD \($HTMLDIR\)
echo Creating symbolic link admin to $HTMLDIR2QUIZCOMPOSER$ADMINMAILADDRESS by
echo executing ln -s $HTMLDIR2QUIZCOMPOSER$ADMINMAILADDRESS admin
ln -s $HTMLDIR2QUIZCOMPOSER$ADMINMAILADDRESS admin
cd $QUIZCOMPOSER
echo
fi
fi
cd $QUIZCOMPOSER
echo '-------'
echo Current directory: $PWD
echo Please consider checking access rights for installed directories:
echo Executing ls -ld test
ls -ld test
echo Executing ls -ld test/\*
ls -ld test/*
echo Executing ls -ld $TESTMAILADDRESS/\* if non-empty
if [ "`echo $TESTMAILADDRESS/*`" != $TESTMAILADDRESS'/*' ]
then
ls -ld $TESTMAILADDRESS/*
fi
echo '-------'
cd $QUIZCOMPOSER
echo Current directory: $PWD
echo Modifying mkmod.py to contain cgi-bin for this domain/server
if [ "$SED" ]
then
sed -e "/cgibin =/s+=.*+= \"$CGIBINDIR/\"+" mkmod.py > fil
mv fil mkmod.py
else
ed -s mkmod.py 2>/dev/null <
/cgibin =
s+=.*+= "$CGIBINDIR/"+
w
q
?
fi
echo
if [ ! -d $QUIZCOMPOSER/tmp ]
then
mkdir $QUIZCOMPOSER/tmp
fi
echo Examining XCHK: $XCHK
if [ -z "$XCHK" ]
then
echo 'Variable XCHK empty'
else # Handle external programs
echo '-------'
echo "Handling external programs $XCHK"
cd $QUIZCOMPOSER
number=0
for i in `echo $XCHK | tr ',' ' '`
do
if [ ! -f "$INSTALLD/${i}.py" ]
then # look into $INSTALLD/.. (quizcomposerinstall.d)
if [ -f "$INSTALLD/../${i}.py" ]
then
echo Copying $INSTALLD/../${i}.py to $INSTALLD/${i}.py
cp "$INSTALLD/../${i}.py" $INSTALLD/${i}.py
else
errorexit "External program ${i}.py missing in $INSTALLD and $INSTALLD/.."
fi
fi
rm -f ${i}.py
cp $INSTALLD/${i}.py ${i}.py
if [ $? -ne 0 ]
then
errorexit "Could not make temporary copy $QUIZCOMPOSER/${i}.py of $INSTALLD/${i}.py"
fi
$PYTHON ./mkmod.py ${i}.py # Create Python module in $CGIBINDIR
rm -f ${i}.py
echo "Modifying $QUIZCOMPOSER/mod_chkanswer.py for $i"
echo "Creating/modifying xchklist statement"
if [ "$number" == 0 ]
then
xchklist="xchklist = [ '${i}"
else
xchklist=${xchklist}"','"${i}
fi
calllist=$calllist" if nr_xchk == ${number} : return ${i}.check( corrval, answ, report, language, nr, corr2 )\\
"
number=$(($number + 1))
done
echo "Finalizing xchklist statement"
xchklist=${xchklist}"' ]"
importlist="import $XCHK"
echo Inserting import $XCHK in $QUIZCOMPOSER/mod_chkanswer.py
if [ "$SED" ]
then
sed -e "/^import/a\\
$importlist
/^xchklist =/c\\
$xchklist
/nr_xchk = /a\\
$calllist
" mod_chkanswer.py > fil
mv fil mod_chkanswer.py
else # TODO: check
ed -s mod_chkanswer.py 2> /dev/null <
/^import/a
$importlist
.
/^xchklist =/c
$xchklist
.
w
q
?
fi
echo
fi
echo '-------'
cd $CGIBINDIR
echo "Current directory: $PWD \(CGIBINDIR\)"
echo Placing itex.tgz in \$CGIBINDIR if itex2MML missing in \$CGIBINDIR
if [ ! -f itex2MML ]
then
echo 'Executable file itex2MML (LaTeX->MathML) missing; itex.tgz copied in'
# before $QUIZCOMPOSER/rqstinst.d is removed, see later
cp $QUIZCOMPOSER/rqstinst.d/itex.tgz .
echo Current directory: $PWD contains
ls -ld itex.tgz
if [ -f itex.tgz ]
then
rm -rf itex
tar zxf itex.tgz
chmod u+x itex
cd itex
make
echo 'pwd:'
pwd
echo ls -lrt
ls -lrt
chmod 750 itex2MML
cp itex2MML $CGIBINDIR
cd $CGIBINDIR
echo ls -ld itex2MML
ls -ld itex2MML
echo 'pwd:'
pwd
echo 'rm -rf itex itex.t*'
rm -rf itex itex.t*
chmod 750 $CGIBINDIR/itex2MML
echo itex2MML now in $CGIBINDIR:
ls -ld $CGIBINDIR/itex2MML
else
warning 'LaTeX->MathML compiler itex2MML NOT installed'
fi
else
echo itex2MML was already in $CGIBINDIR:
chmod ug+x $CGIBINDIR/itex2MML
ls -ld $CGIBINDIR/itex2MML
fi
echo
echo '-------'
echo Examining \$GUEST_IPNOCHK: $GUEST_IPNOCHK
if [ -n "$GUEST_IPNOCHK" ]
then
cd $QUIZCOMPOSER/rqstguest.d
echo Current directory: $PWD
if [ "$SED" ]
then
sed -e "/CHECK REMOTEADDR/s+for m in acntlst : \# CHECK+if 0 : \# NO CHECK+" mod_rqstguest.py > fil
mv fil mod_rqstguest.py
else
ed -s mod_rqstguest.py 2>/dev/null <
/CHECK REMOTEADDR/s+for m in acntlst : \# CHECK+if 0 : \# NO CHECK+
w
q
?
fi
else
echo Variable GUEST_IPNOCHK empty
fi
echo
echo '-------'
cd $QUIZCOMPOSER
echo Creating modules in $QUIZCOMPOSER and sub-directories by executing ./mkmods.sh
./mkmods.sh
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ./mkmods.sh'
fi
echo
echo '-------'
cd $QUIZCOMPOSER
echo Creating links required for generation of pages and examples by executing ./mklinks.sh
./mklinks.sh
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ./mklinks.sh'
fi
echo
echo '-------'
cd $QUIZCOMPOSER
echo Creating links from $CGIBINDIR to $QUIZCOMPOSER
echo Executing ./mkcgibin.sh $CGIBINDIR $CGIBINDIR2QUIZCOMPOSER
./mkcgibin.sh $CGIBINDIR $CGIBINDIR2QUIZCOMPOSER
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ./mkcgibin.sh $CGIBINDIR $CGIBINDIR2QUIZCOMPOSER'
fi
echo
echo Examining \$CGIBINGROUP: $CGIBINGROUP
if [ -n "$CGIBINGROUP" ]
then
echo Executing chgrp $CGIBINGROUP $CGIBINDIR/\*
chgrp $CGIBINGROUP $CGIBINDIR/*
if [ $? -ne 0 ]
then
echo 'Error at statement: chgrp $CGIBINGROUP $CGIBINDIR/*'
echo 'Could not chgrp $CGIBINGROUP $CGIBINDIR/*'
echo ls -ld $CGIBINDIR results in:
ls -ld $CGIBINDIR
errorexit
fi
else
echo Examining \$SERVERGROUP: $SERVERGROUP
if [ -n "$SERVERGROUP" ]
then
echo Executing chgrp $SERVERGROUP $CGIBINDIR/\*
chgrp $SERVERGROUP $CGIBINDIR/*
if [ $? -ne 0 ]
then
echo 'Error at statement: chgrp $SERVERGROUP $CGIBINDIR/*'
echo Could not chgrp $SERVERGROUP $CGIBINDIR/\*
echo ls -ld $CGIBINDIR results in:
ls -ld $CGIBINDIR
errorexit
fi
fi
fi
echo
echo '-------'
echo Setting access modes for contents of $CGIBINDIR
cd $CGIBINDIR
echo Current directory: $PWD \(CGIBINDIR\)
echo Executing chmod $MODE700 \*.py\* itex2MML
chmod $MODE700 *.py* itex2MML
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE700 *.py* itex2MML'
echo ls -ld . results in:
ls -ld .
errorexit
fi
echo Executing chmod $MODE600 \*.mat \*.txt \*.htm mod_\*.py\*
chmod $MODE600 *.mat *.txt *.htm mod_*.py*
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE600 *.mat *.txt *.htm mod_*.py'
echo ls -ld . results in:
ls -ld .
errorexit
fi
echo Current contents of $CGIBINDIR:
ls -l
echo Completed
echo
echo '-------'
echo Examining $GUEST_HOURSOPEN: $GUEST_HOURSOPEN
if [ -n "$GUEST_HOURSOPEN" ]
then
echo GUEST_HOURSOPEN: $GUEST_HOURSOPEN
echo GUEST_MAXCOUNT: $GUEST_MAXCOUNT
echo Setting hours open for guest accounts # before creating access pages
cd $QUIZCOMPOSER/rqstguest.d
echo Current directory: $PWD
if [ "$SED" ]
then
cat > cmdfile <
/name=\"maxcount\"/s+value=\".*\"+value=\"$GUEST_MAXCOUNT\"+
/name=\"hoursopen\"/s+value=\".*\"+value=\"$GUEST_HOURSOPEN\"+
?
sed -f cmdfile reqstdiv.txt > fil
mv fil reqstdiv.txt
else
ed -s reqstdiv.txt 2>/dev/null <
/name="maxcount"/s+value=\".*\"+value=\"$GUEST_MAXCOUNT\"+
/name="hoursopen"/s+value=\".*\"+value=\"$GUEST_HOURSOPEN\"+
w
q
?
fi
else
echo Variable GUEST_HOURSOPEN empty
fi
echo
echo '-------'
cd $QUIZCOMPOSER
echo Generating forms \(.htm-pages\) in $QUIZCOMPOSER/html.d
echo Executing ./mkpages.sh
./mkpages.sh
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ./mkpages.sh'
fi
echo
echo '-------'
cd $QUIZCOMPOSER
echo Setting access mode for html.d in $QUIZCOMPOSER
echo Executing chmod $MODE755 html.d
chmod $MODE755 html.d
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Could not chmod $MODE755 html.d'
echo ls -ld html.d results in:
ls -ld html.d
errorexit
fi
echo Setting access mode for contents of html.d
echo Executing chmod $MODE644 html.d/\*
chmod $MODE644 html.d/*
if [ $? -ne 0 ]
then
echo Current directory: $PWD
echo 'Error at statement: chmod $MODE644 html.d/*'
echo 'Could not chmod $MODE644 html.d/*'
echo 'ls -ld html.d html.d/* results in:'
ls -ld html.d html.d/*
errorexit
else
echo Completed
fi
echo
echo '-------'
cd $QUIZCOMPOSER
echo Compiling phrase files
echo Executing $PYTHON ./mkphrasepkl.py dk
$PYTHON ./mkphrasepkl.py dk
if [ $? -eq 0 ]
then
echo Completed
else
warning "Error while executing $PYTHON ./mkphrasepkl.py dk"
fi
echo Executing $PYTHON ./mkphrasepkl.py en
$PYTHON ./mkphrasepkl.py en
if [ $? -eq 0 ]
then
echo Completed
else
warning "Error while executing $PYTHON ./mkphrasepkl.py en"
fi
echo
echo '-------'
cd $CGIBINDIR
echo Current directory: $PWD
echo 'Adjusting ../html.d/rqlstqz_??.htm to list quiz authors and courses'
echo Executing $PYTHON ./rqstadmin.py $QUIZCOMPOSER/rqstadmin.d/installrqstlstqz.data
$PYTHON ./rqstadmin.py $QUIZCOMPOSER/rqstadmin.d/installrqstlstqz.data
if [ $? -eq 0 ]
then
echo Completed
else
warning "Error while executing $PYTHON ./rqstadmin.py $QUIZCOMPOSER/rqstadmin.d/installrqstlstqz.data"
fi
echo Executing $PYTHON ./rqstadmcrs.py $QUIZCOMPOSER/rqstadmcrs.d/installrqstlstcrs.data
$PYTHON ./rqstadmcrs.py $QUIZCOMPOSER/rqstadmcrs.d/installrqstlstcrs.data
if [ $? -eq 0 ]
then
echo Completed
else
warning "Error while executing $PYTHON ./rqstadmcrs.py $QUIZCOMPOSER/rqstadmcrs.d/installrqstlstcrs.data"
fi
echo
cd $QUIZCOMPOSER
echo Current directory $PWD
echo '-------'
if [ $DOMAIN = 'www.quizcomposer.dk' ]
then
echo "Restoring files $QUIZCOMPOSER/html.d/examples_*.htm"
cp $INSTALLD/examples*.htm $QUIZCOMPOSER/html.d
ls -ld $QUIZCOMPOSER/html.d/examples_*.htm
fi
echo
echo '-------'
cd $HTMLDIR
echo Current directory: $PWD
echo Generating symbolic links in $HTMLDIR to $QUIZCOMPOSER
echo Executing rm -f html.d rqstinst.d index.html errormsg.htm
rm -f html.d rqstinst.d index.html errormsg.htm
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing rm -f html.d rqstinst.d index.html errormsg.htm'
fi
echo Executing ln -s ${HTMLDIR2QUIZCOMPOSER}html.d html.d and more
ln -s ${HTMLDIR2QUIZCOMPOSER}html.d html.d
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ln -s ${HTMLDIR2QUIZCOMPOSER}html.d html.d'
fi
ln -s ${HTMLDIR2QUIZCOMPOSER}rqstinst.d rqstinst.d
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ln -s ${HTMLDIR2QUIZCOMPOSER}rqstinst.d rqstinst.d'
fi
ln -s ${HTMLDIR2QUIZCOMPOSER}html.d/index.html index.html
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ln -s ${HTMLDIR2QUIZCOMPOSER}html.d/index.html index.html'
fi
ln -s ${HTMLDIR2QUIZCOMPOSER}html.d/errormsg.htm errormsg.htm
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ln -s ${HTMLDIR2QUIZCOMPOSER}html.d/errormsg.htm errormsg.htm'
fi
echo
if [ -x "test" ]
then
else
echo Executing rm -f test
rm -f test
echo Executing ln -s ${HTMLDIR2QUIZCOMPOSER}$TESTMAILADDRESS ./test
ln -s ${HTMLDIR2QUIZCOMPOSER}$TESTMAILADDRESS ./test
if [ $? -eq 0 ]
then
echo Completed
else
warning 'Error while executing ln -s ${HTMLDIR2QUIZCOMPOSER}$TESTMAILADDRESS ./test'
fi
fi
echo '-------'
cd $QUIZCOMPOSER/html.d
echo Current directory: $PWD
echo Examining INDEX_HTML_PREFIX1: $INDEX_HTML_PREFIX1
if [ -n "$INDEX_HTML_PREFIX1" ] # TODO: make similar to SOURCEFORGE_LOGO below
then
echo Modifying index.html \(QuizComposer home page\):
if [ "$SED" ]
then
sed -e "s+html.d+${INDEX_HTML_PREFIX1}html.d+" index.html > fil
mv fil index.html
else # TODO: check
ed -s index.html 2>/dev/null <
1,$s+html.d+${INDEX_HTML_PREFIX1}html.d+
w
q
?
fi
else
echo Variable INDEX_HTML_PREFIX1 empty
fi
echo SOURCEFORGE_LOGO: "$SOURCEFORGE_LOGO"
if [ -n "$SOURCEFORGE_LOGO" ]
then
echo Adding sourceforge logo to index.html
if [ "$SED" ]
then
sed -e '/SOURCEFORGE_LOGO START/s+$+ -->+
/SOURCEFORGE_LOGO END/s+^ ++
/SOURCEFORGE_LOGO END/s+^ ++
/ALLOWGUEST END/s+^ ++
/ALLOWGUEST END/s+^ ++
/ALLOWGUEST END/s+^ ++
/ALLOWGUEST END/s+^ ++
/QUIZCENTER END/s+^ ++
/QUIZCENTER END/s+^ +