#!/bin/sh interactive=1 sourced=1 unset use_shell case $* in *--no-interactive*) unset interactive ;; esac fail() { echo $* >&2 exit 1 } # make sure we are sourced, and not run if test "`basename $0`" = "greenstone" ; then # if $0 is "greenstone" we've been run... $0 is shellname if sourced. # One exception is zsh has an option to set it temporarily to the script name if test -z "$ZSH_NAME" ; then # we aren't using zsh unset sourced fi fi if test -z "$sourced" ; then test -z "$interactive" && fail "Script must be sourced for non-interactive use" echo "Script was not sourced" >&2 echo -n "Use a new shell? (y/[n]) " >&2 read use_shell test "$use_shell" != "y" -a "$use_shell" != "Y" && fail "Script must either be sourced, or allowed to start an interactive shell" use_shell=1 fi GSDLHOME=/opt/greenstone/gs2build export GSDLHOME GSDLOS=linux export GSDLOS # Establish cpu architecture # 32-bit or 64-bit? UNAME_HW_MACH=`uname -m` # Following test came from VirtualBox's Guest Additions autostart.sh # (adapted for use in Greenstone) case "$UNAME_HW_MACH" in i[3456789]86|x86|i86pc) GSDLARCH='32' ;; x86_64|amd64|AMD64) GSDLARCH='64' ;; *) echo "Unknown architecture: $UNAME_HW_MACH" >&2 ;; esac # Only want non-trival GSDLARCH value set if there is evidence of # the installed bin (lib, ...) directories using linux32, linux64 # (otherwise probably looking at an SVN compiled up version for single OS) if test ! -d "$GSDLHOME/bin/$GSDLOS$GSDLARCH" ; then GSDLARCH="" fi export GSDLARCH # Workaround for perl >= 5.18 PERL_PERTURB_KEYS=0 export PERL_PERTURB_KEYS PATH="$GSDLHOME/bin/script:$GSDLHOME/bin/$GSDLOS$GSDLARCH:$PATH" export PATH LD_LIBRARY_PATH="$GSDLHOME/gs2build/lib/$GSDLOS$GSDLARCH:$GSDLHOME/lib/$GSDLOS$GSDLARCH:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH if test -n "$interactive" -a -z "$GSDL3HOME" ; then echo "Where are the collections? [/srv/gsdl/]" >&2 echo -n " > " >&2 read GSDL3HOME fi if test -z "$GSDL3HOME" ; then echo "Setting collections location to the default" >&2 GSDL3HOME=/srv/gsdl fi export GSDL3HOME test -d "$GSDL3HOME/sites/localsite/collect" || mkdir -p "$GSDL3HOME/sites/localsite/collect" if test -n "$interactive" -a -n "$use_shell" ; then test -z $SHELL && SHELL=sh echo "Starting an interactive shell for GSDL management" >&2 $SHELL fi