[29460] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 | interactive=1
|
---|
| 4 | sourced=1
|
---|
| 5 | unset use_shell
|
---|
| 6 | case $* in
|
---|
| 7 | *--no-interactive*)
|
---|
| 8 | unset interactive
|
---|
| 9 | ;;
|
---|
| 10 | esac
|
---|
| 11 |
|
---|
| 12 | fail() {
|
---|
| 13 | echo $* >&2
|
---|
| 14 | exit 1
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | # make sure we are sourced, and not run
|
---|
[29474] | 18 | if test "`basename $0`" = "greenstone" ; then
|
---|
[29460] | 19 | # if $0 is "greenstone" we've been run... $0 is shellname if sourced.
|
---|
| 20 | # One exception is zsh has an option to set it temporarily to the script name
|
---|
| 21 | if test -z "$ZSH_NAME" ; then
|
---|
| 22 | # we aren't using zsh
|
---|
| 23 | unset sourced
|
---|
| 24 | fi
|
---|
| 25 | fi
|
---|
| 26 |
|
---|
| 27 | if test -z "$sourced" ; then
|
---|
| 28 | test -z "$interactive" && fail "Script must be sourced for non-interactive use"
|
---|
| 29 | echo "Script was not sourced" >&2
|
---|
| 30 | echo -n "Use a new shell? (y/[n]) " >&2
|
---|
| 31 | read use_shell
|
---|
| 32 | test "$use_shell" != "y" -a "$use_shell" != "Y" && fail "Script must either be sourced, or allowed to start an interactive shell"
|
---|
| 33 | use_shell=1
|
---|
| 34 | fi
|
---|
| 35 |
|
---|
[29577] | 36 | GSDLHOME=%GREENSTONE_HOME%/gs2build
|
---|
[29460] | 37 | export GSDLHOME
|
---|
| 38 |
|
---|
| 39 | GSDLOS=linux
|
---|
| 40 | export GSDLOS
|
---|
| 41 |
|
---|
| 42 | # Establish cpu architecture
|
---|
| 43 | # 32-bit or 64-bit?
|
---|
| 44 | UNAME_HW_MACH=`uname -m`
|
---|
| 45 |
|
---|
| 46 | # Following test came from VirtualBox's Guest Additions autostart.sh
|
---|
| 47 | # (adapted for use in Greenstone)
|
---|
| 48 | case "$UNAME_HW_MACH" in
|
---|
| 49 | i[3456789]86|x86|i86pc)
|
---|
| 50 | GSDLARCH='32'
|
---|
| 51 | ;;
|
---|
| 52 | x86_64|amd64|AMD64)
|
---|
| 53 | GSDLARCH='64'
|
---|
| 54 | ;;
|
---|
| 55 | *)
|
---|
| 56 | echo "Unknown architecture: $UNAME_HW_MACH" >&2
|
---|
| 57 | ;;
|
---|
| 58 | esac
|
---|
| 59 |
|
---|
| 60 | # Only want non-trival GSDLARCH value set if there is evidence of
|
---|
| 61 | # the installed bin (lib, ...) directories using linux32, linux64
|
---|
| 62 | # (otherwise probably looking at an SVN compiled up version for single OS)
|
---|
| 63 | if test ! -d "$GSDLHOME/bin/$GSDLOS$GSDLARCH" ;
|
---|
| 64 | then
|
---|
| 65 | GSDLARCH=""
|
---|
| 66 | fi
|
---|
| 67 |
|
---|
| 68 | export GSDLARCH
|
---|
| 69 |
|
---|
| 70 | # Workaround for perl >= 5.18
|
---|
| 71 | PERL_PERTURB_KEYS=0
|
---|
| 72 | export PERL_PERTURB_KEYS
|
---|
| 73 |
|
---|
| 74 |
|
---|
| 75 | PATH="$GSDLHOME/bin/script:$GSDLHOME/bin/$GSDLOS$GSDLARCH:$PATH"
|
---|
| 76 | export PATH
|
---|
[29577] | 77 | LD_LIBRARY_PATH="$GSDLHOME/lib/$GSDLOS$GSDLARCH:$LD_LIBRARY_PATH"
|
---|
[29460] | 78 | export LD_LIBRARY_PATH
|
---|
| 79 |
|
---|
| 80 | if test -n "$interactive" -a -z "$GSDL3HOME" ; then
|
---|
[29577] | 81 | echo "Where are the collections? [%WEB%]" >&2
|
---|
[29460] | 82 | echo -n " > " >&2
|
---|
| 83 | read GSDL3HOME
|
---|
| 84 | fi
|
---|
| 85 | if test -z "$GSDL3HOME" ; then
|
---|
| 86 | echo "Setting collections location to the default" >&2
|
---|
[29577] | 87 | GSDL3HOME=%WEB%
|
---|
[29460] | 88 | fi
|
---|
| 89 | export GSDL3HOME
|
---|
| 90 |
|
---|
| 91 | test -d "$GSDL3HOME/sites/localsite/collect" || mkdir -p "$GSDL3HOME/sites/localsite/collect"
|
---|
| 92 |
|
---|
| 93 | if test -n "$interactive" -a -n "$use_shell" ; then
|
---|
| 94 | test -z $SHELL && SHELL=sh
|
---|
| 95 | echo "Starting an interactive shell for GSDL management" >&2
|
---|
| 96 | $SHELL
|
---|
| 97 | fi
|
---|