#!/bin/sh ## Install.sh -- Install Greenstone cmd_cp="cp" cmd_cpr="cp -r" cmd_chmod="chmod" cmd_mkdir="mkdir -p" cmd_ln="ln -s" cmd_mv="mv" cmd_rm="rm -i" cmd_rmr="rm -r" thisdir=`pwd` cd .. cd_dir=`pwd` cd "$thisdir" # script must be run from within cdrom/unix directory if [ ! -f "${thisdir}/Install.sh" ]; then echo "Install.sh must be run from the directory in which it resides" echo "Greenstone was not installed" exit 1 fi # check that various important directories are on the cd if [ ! -d "${cd_dir}/gsdl" ]; then echo echo "ERROR: Could not locate ${cd_dir}/gsdl" echo "Greenstone was not installed" exit 1 fi if [ ! -d "${cd_dir}/Unix/bin/linux" ]; then echo echo "ERROR: Could not locate ${cd_dir}/Unix/bin/linux" echo "Greenstone was not installed" exit 1 fi # install to /usr/local by default if user is "root", otherwise # default to users home directory gsdlos=`uname | tr A-Z a-z` if [ "$gsdlos" = "linux" ]; then logname=`whoami` else logname="" fi if [ "$logname" = "" ]; then logname=`logname` fi gsdlhome="/home/${logname}" if [ "$logname" = "root" ]; then gsdlhome="/usr/local" fi # get gsdlhome echo echo "This script will install Greenstone on your system. Please read" echo "the Install.htm file that resides in the docs directory of this" echo "cd-rom before installing." echo echo "Note that when prompted for input, hitting \"enter\" will select" echo "the default (given in square brackets [] at the end of each question)." echo echo "Note also that Install.sh prints out information on any commands" echo "it runs on your system in the form \"--> Install.sh: [command]\"." echo echo "It is assumed throughout this installation procedure that you" echo "have a webserver installed on your system." echo echo "Continue? [y]" printf "%s" "> " read ans if [ "$ans" != "" ] && [ "$ans" != "y" ]; then echo "Greenstone was not installed" exit 0 fi echo echo "Enter directory to install Greenstone into. A gsdl directory" echo "will be created in this directory. [${gsdlhome}]" printf "%s" "> " read ans if [ "$ans" != "" ]; then gsdlhome="$ans" fi if [ ! -d "$gsdlhome" ]; then echo "Warning: The ${gsdlhome} directory does not exist." echo "Create it? [y]" printf "%s" "> " read ans if [ "$ans" = "" ]; then ans="y" fi if [ "$ans" = "y" ]; then echo "--> Install.sh: [$cmd_mkdir \"$gsdlhome\"]" $cmd_mkdir "$gsdlhome" if [ ! -d "$gsdlhome" ]; then echo "ERROR: failed to create $gsdlhome directory" echo "Greenstone was not installed" exit 1 fi else echo "Greenstone was not installed" exit 0 fi fi; # from now on $gsdlhome includes the "/gsdl" gsdlhome="${gsdlhome}/gsdl" echo "--> Install.sh: [$cmd_mkdir \"${gsdlhome}\"]" $cmd_mkdir "$gsdlhome" if [ ! -d "$gsdlhome" ]; then echo "ERROR: failed to create $gsdlhome directory" echo "Greenstone was not installed" exit 1 fi # create initial uninstall.sh cd "$gsdlhome" echo "#!/bin/sh" > uninstall.sh echo "" >> uninstall.sh echo "echo \"remove ${gsdlhome} directory? [y]\"" >> uninstall.sh echo "read ans" >> uninstall.sh echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> uninstall.sh echo " $cmd_rmr \"$gsdlhome\"" >> uninstall.sh echo "fi" >> uninstall.sh $cmd_chmod u+x uninstall.sh cd "$thisdir" echo echo "If this installation fails or is cancelled, run the uninstall" echo "script (${gsdlhome}/uninstall.sh) to clean up the partial" echo "installation." echo "Continue? [y]" printf "%s" "> " read ans if [ "$ans" != "" ] && [ "$ans" != "y" ]; then echo "Greenstone was not installed" exit 0 fi echo echo "Installing Greenstone directory structure to ${gsdlhome}" # copy gsdl directory across echo "--> Install.sh: [$cmd_cpr \"${cd_dir}/gsdl/\"* \"$gsdlhome\"]" $cmd_cpr "${cd_dir}/gsdl/"* "$gsdlhome" # copy setup shell scripts across too echo "--> Install.sh: [$cmd_cp \"${cd_dir}/src/Unix/setup.\"* \"$gsdlhome\"]" $cmd_cp "${cd_dir}/src/Unix/setup."* "$gsdlhome" # create the tmp directory echo "--> Install.sh: [$cmd_mkdir \"$gsdlhome/tmp\"]" $cmd_mkdir "$gsdlhome/tmp" # which collections do we want cd "${cd_dir}/collect" files=* first="yes" for file in $files do if [ "$first" = "yes" ]; then echo echo "The Greenstone demonstration collection has been installed. Would you" echo "like to install any other collections from the installation cd-rom? [y]" read ans if [ "$ans" != "" ] && [ "$ans" != "y" ]; then break fi first="no" fi echo echo "Install the $file collection? [y]" printf "%s" "> " read ans if [ "$ans" = "" ] || [ "$ans" = "y" ]; then echo "--> Install.sh: [$cmd_cpr \"${cd_dir}/collect/$file\" \"${gsdlhome}/collect\"]" $cmd_cpr "${cd_dir}/collect/$file" "${gsdlhome}/collect" fi done # set permissions echo echo "Setting permissions ..." echo "--> Install.sh: [$cmd_chmod -R u+rw \"$gsdlhome\"]" $cmd_chmod -R u+rw "$gsdlhome" # gsdl/etc needs to be globally writable echo "--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/etc\"]" $cmd_chmod a+w "$gsdlhome/etc" # should gsdl/collect and gsdl/tmp be globally writable? echo echo "In order for end-user collection building to be enabled the" echo "Greenstone cgi program must be able to write to the" echo "${gsdlhome}/collect and ${gsdlhome}/tmp directories." echo "On most systems this means they must be globally writable." echo "Make these directories globally writable? [y]" printf "%s" "> " read ans if [ "$ans" = "" ] || [ "$ans" = "y" ]; then echo "--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/collect\"]" $cmd_chmod a+w "$gsdlhome/collect" echo "--> Install.sh: [$cmd_chmod a+w \"$gsdlhome/tmp\"]" $cmd_chmod a+w "$gsdlhome/tmp" fi # binaries or source code? compile="yes" if [ "$gsdlos" = "linux" ]; then echo echo "You may either install pre-compiled, statically linked linux [b]inaries" echo "or install and [c]ompile the Greenstone source code" found=no while [ "$found" = "no" ]; do echo "Enter \"[b]\" or \"c\"" printf "%s" "> " read ans if [ "$ans" = "" ]; then ans="b" fi if [ "$ans" = "b" ]; then compile="no" # install binaries echo echo "Installing linux binaries" echo "--> Install.sh: [$cmd_cpr \"${cd_dir}/Unix/bin/linux\" \"${gsdlhome}/bin\" ]" $cmd_cpr "${cd_dir}/Unix/bin/linux" "${gsdlhome}/bin" echo "--> Install.sh: [$cmd_chmod a+x \"${gsdlhome}/bin/linux/\"*]" $cmd_chmod a+x "${gsdlhome}/bin/linux/"* echo "--> Install.sh: [$cmd_chmod -R u+rw \"${gsdlhome}/bin/linux\"]" $cmd_chmod -R u+rw "${gsdlhome}/bin/linux" # move library executable to cgi-bin echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/bin/linux/library\" \"${gsdlhome}/cgi-bin\"]" $cmd_mv "${gsdlhome}/bin/linux/library" "${gsdlhome}/cgi-bin" found="yes" elif [ "$ans" = "c" ]; then found="yes" fi done fi if [ "$compile" = "yes" ]; then # install source echo echo "Installing source code" echo "--> Install.sh [$cmd_cpr \"${cd_dir}/src/lib\" \"$gsdlhome\"]" $cmd_cpr "${cd_dir}/src/lib" "$gsdlhome" echo "--> Install.sh [$cmd_cpr \"${cd_dir}/src/packages\" \"$gsdlhome\"]" $cmd_cpr "${cd_dir}/src/packages" "$gsdlhome" echo "--> Install.sh [$cmd_cpr \"${cd_dir}/src/src\" \"$gsdlhome\"]" $cmd_cpr "${cd_dir}/src/src" "$gsdlhome" echo "--> Install.sh [$cmd_cpr \"${cd_dir}/src/Unix/\"* \"$gsdlhome\"]" $cmd_cpr "${cd_dir}/src/Unix/"* "$gsdlhome" # compile it echo "--> Install.sh: [cd $gsdlhome]" cd "$gsdlhome" echo "configuring ..." echo echo "--> Install.sh: [./configure]" ./configure echo "compiling ..." echo echo "--> Install.sh: [make]" make echo "installing ..." echo echo "--> Install.sh: [make install]" make install echo "--> Install.sh: [cd $thisdir]" cd "$thisdir" # check that things compiled ok if [ ! -f "${gsdlhome}/cgi-bin/library" ]; then echo echo "ERROR: Compilation failed" echo "Greenstone was not installed successfully" echo "Run the uninstall script (${gsdlhome}/uninstall.sh)" echo "to clean up the partial installation." exit 1 fi fi # try to find out hostname if [ "$gsdlos" = "linux" ]; then hostname=`hostname -f` if [ "$hostname" = "" ]; then hostname=`hostname -i` fi fi if [ "$hostname" = "" ]; then hostname=`hostname` fi if [ "$hostname" = "" ]; then hostname="your-computer-name" fi # get cgi-bin directory echo echo echo "Greenstone needs a valid cgi executable directory (normally called" echo "cgi-bin on unix systems) from which to run." echo "This may be either:" echo " 1. The default Greenstone cgi-bin directory (${gsdlhome}/cgi-bin)." echo " If you use the Greenstone default you will need to configure" echo " your webserver to treat this directory as a cgi executable" echo " directory. For the Apache webserver you use the ScriptAlias" echo " directive to do this." if [ "$logname" != "root" ]; then echo " Note that you will probably need help from your system" echo " administrator to reconfigure your webserver." fi echo " 2. An existing cgi-bin directory. Normally a cgi-bin directory" echo " is created when your webserver is installed. Typically, this" echo " might be /home/httpd/cgi-bin, or /usr/local/apache/cgi-bin, or" echo " /var/lib/apache/cgi-bin." if [ "$logname" != "root" ]; then echo " Many systems also allow individual users to have their own" echo " cgi-bin in /home/username/public_html/cgi-bin." fi echo echo "Enter cgi executable directory [${gsdlhome}/cgi-bin]" printf "%s" "> " read ans if [ "$ans" = "" ]; then cgi_bin="${gsdlhome}/cgi-bin" else cgi_bin="$ans" fi remind_cgi="no" remind_cgi_nomove="no" if [ "$cgi_bin" = "${gsdlhome}/cgi-bin" ]; then # default gsdl cgi-bin, do nothing echo echo "You have chosen to use the default Greenstone cgi-bin directory." echo "Don't forget to configure your webserver to treat $cgi_bin" echo "as a cgi executable directory." remind_cgi="yes" else # external cgi-bin if [ ! -d "$cgi_bin" ]; then echo "Warning: The ${cgi_bin} directory does not exist." echo "Create it? [y]" printf "%s" "> " read ans if [ "$ans" = "" ] || [ "$ans" = "y" ]; then echo "--> Install.sh: [$cmd_mkdir \"$cgi_bin\"]" $cmd_mkdir "$cgi_bin" if [ -d "$cgi_bin" ]; then echo "Don't forget to configure your webserver to treat $cgi_bin" echo "as a cgi executable directory." remind_cgi="yes" else echo "ERROR: failed to create $cgi_bin directory" echo "Greenstone installation failed." echo "Run the uninstall script (${gsdlhome}/uninstall.sh)" echo "to clean up the partial installation." exit 1 fi fi fi if [ ! -w "$cgi_bin" ]; then echo echo "Unable to write to $cgi_bin directory. You will need" echo "to copy the contents of ${gsdlhome}/cgi-bin" echo "to $cgi_bin after this installation is completed." remind_cgi_nomove="yes" else # install cgi-bin stuff (update the uninstall script first) cd "$gsdlhome" echo "#!/bin/sh" > uninstall.sh echo "" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/GSDLHOME.pm\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/gsdlsite.cfg\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/library\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_buildcol.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_buildstatus.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_delcol.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_editcol.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_mkcol.pl\"" >> uninstall.sh echo "echo \"remove ${gsdlhome} directory? [y]\"" >> uninstall.sh echo "read ans" >> uninstall.sh echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> uninstall.sh echo " $cmd_rmr \"$gsdlhome\"" >> uninstall.sh echo "fi" >> uninstall.sh $cmd_chmod u+x uninstall.sh cd "$thisdir" echo echo "Installing Greenstone cgi programs in $cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/GSDLHOME.pm\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/GSDLHOME.pm" "$cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/gsdlsite.cfg\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/gsdlsite.cfg" "$cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/library\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/library" "$cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/webpage_buildcol.pl\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/webpage_buildcol.pl" "$cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/webpage_buildstatus.pl\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/webpage_buildstatus.pl" "$cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/webpage_delcol.pl\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/webpage_delcol.pl" "$cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/webpage_editcol.pl\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/webpage_editcol.pl" "$cgi_bin" echo "--> Install.sh: [$cmd_mv \"${gsdlhome}/cgi-bin/webpage_mkcol.pl\" \"$cgi_bin\"]" $cmd_mv "${gsdlhome}/cgi-bin/webpage_mkcol.pl" "$cgi_bin" fi fi # web address of cgi-bin web_cgi="http://${hostname}/cgi-bin" echo echo "Please enter the web address of the $cgi_bin" echo "directory. Typically this might be http://localhost/cgi-bin," echo "or http://127.0.0.1/cgi-bin, or http://your-computer-name/cgi-bin," echo "or http://nnn.nnn.nnn.nn/cgi-bin. [http://${hostname}/cgi-bin]" printf "%s" "> " read ans if [ "$ans" != "" ]; then web_cgi="$ans" fi # get public_html directory echo echo echo "In order for Greenstone to run, the $gsdlhome" echo "directory and all it contains must be accessible from the web." echo "To make this happen you may either:" echo " 1. Configure your webserver so that $gsdlhome" echo " is itself accessible from the web." if [ "$logname" != "root" ]; then echo " Note that you will probably need help from your system" echo " administrator to reconfigure your webserver." fi echo " 2. Provide an existing web accessible directory from which" echo " a symbolic link will be made to $gsdlhome." echo " When your server was installed a web accessible directory" echo " will have been created (the Apache webserver uses the" echo " DocumentRoot directive to define this directory). Typically" echo " this directory might be /home/httpd/html, or /usr/local/apache/html," echo " or /var/lib/apache/html." if [ "$logname" != "root" ]; then echo " Many systems also allow individual users to have their own" echo " web accessible directory in /home/username/public_html." fi echo " Note that your web server will need to be configured to allow" echo " symbolic links from within this directory. For the Apache" echo " server that means this directory must be configured with" echo " the SymLinksIfOwnerMatch or FollowSymLinks option (most Apache" echo " installations are configured this way by default)." echo echo "Enter web accessible directory [${gsdlhome}]" printf "%s" "> " read ans if [ "$ans" = "" ]; then public_html="$gsdlhome" else public_html="$ans" fi remind_ph="no" remind_ph_nolink="no" if [ "$public_html" = "$gsdlhome" ]; then # no link echo echo "You have chosen to make the main Greenstone directory accessible" echo "from the web. Don't forget to configure your webserver to make" echo "$gsdlhome accessible after the completion of this" echo "installation." remind_ph="yes" else # external public_html # create link to gsdl (and update uninstall.sh) if [ -w "$public_html" ]; then cd "$gsdlhome" echo "#!/bin/sh" > uninstall.sh echo "" >> uninstall.sh echo "$cmd_rm \"$public_html/gsdl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/GSDLHOME.pm\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/gsdlsite.cfg\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/library\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_buildcol.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_buildstatus.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_delcol.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_editcol.pl\"" >> uninstall.sh echo "$cmd_rm \"${cgi_bin}/webpage_mkcol.pl\"" >> uninstall.sh echo "echo \"remove ${gsdlhome} directory? [y]\"" >> uninstall.sh echo "read ans" >> uninstall.sh echo "if [ \"\$ans\" = \"\" ] || [ \"\$ans\" = \"y\" ]; then" >> uninstall.sh echo " $cmd_rmr \"$gsdlhome\"" >> uninstall.sh echo "fi" >> uninstall.sh $cmd_chmod u+x uninstall.sh cd "$thisdir" echo "--> Install.sh: [cd \"$public_html\"]" cd "$public_html" echo "--> Install.sh: [$cmd_ln \"$gsdlhome\" gsdl]" $cmd_ln "$gsdlhome" gsdl echo "--> Install.sh: [cd \"$thisdir\"]" cd "$thisdir" else echo echo "Unable to write to $public_html directory. You will need" echo "to create a link called gsdl from $public_html to" echo "$gsdlhome after this installation is completed." old_ph=$public_html remind_ph_nolink="yes" fi public_html="${public_html}/gsdl" fi # get httpprefix echo echo "Enter the web address of the $public_html directory." echo "This may be a relative url (e.g. \"/gsdl\") or a" echo "complete url (e.g. \"http://${hostname}/gsdl\") [/gsdl]" printf "%s" ">" httpprefix="/gsdl" read ans if [ "$ans" != "" ]; then httpprefix="$ans" fi # edit gsdlsite.cfg cd "$cgi_bin" sed "s|\(gsdlhome *\)[^ ]*|\1${gsdlhome}|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg sed "s|#*\(httpprefix *\)[^ ]*|\1${httpprefix}|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg sed "s|\(httpimg *\)[^ ]*|\1${httpprefix}/images|" gsdlsite.cfg > tmp123.txt && $cmd_mv tmp123.txt gsdlsite.cfg echo echo echo "Greenstone installation completed successfully." if [ "$remind_cgi" = "yes" ]; then echo " * Don't forget to configure your webserver to treat" echo " $cgi_bin as a cgi executable directory." fi if [ "$remind_cgi_nomove" = "yes" ]; then echo " * Don't forget to move the contents of ${gsdlhome}/cgi-bin" echo " to $cgi_bin" fi if [ "$remind_ph" = "yes" ]; then echo " * Don't forget to configure your webserver to treat" echo " $gsdlhome as a web accessible directory." fi if [ "$remind_ph_nolink" = "yes" ]; then echo " * Don't forget to create a link called gsdl from $old_ph" echo " to ${gsdlhome}." fi echo "You may remove Greenstone from your system at any time by running" echo "the ${gsdlhome}/uninstall.sh script." echo "Access Greenstone by pointing a web browser at" echo " ${web_cgi}/library" echo "Access administration pages by pointing a web browser at" echo " ${web_cgi}/library?a=status" echo "Access end-user collection building by pointing a web browser at" echo " ${web_cgi}/library?a=collector" echo exit 0