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
|
---|
18 | if test "`basename $0`" = "greenstone" ; then
|
---|
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 |
|
---|
36 | GSDLHOME=%GREENSTONE_HOME%/gs2build
|
---|
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
|
---|
77 | LD_LIBRARY_PATH="$GSDLHOME/lib/$GSDLOS$GSDLARCH:$LD_LIBRARY_PATH"
|
---|
78 | export LD_LIBRARY_PATH
|
---|
79 |
|
---|
80 | if test -n "$interactive" -a -z "$GSDL3HOME" ; then
|
---|
81 | echo "Where are the collections? [%WEB%]" >&2
|
---|
82 | echo -n " > " >&2
|
---|
83 | read GSDL3HOME
|
---|
84 | fi
|
---|
85 | if test -z "$GSDL3HOME" ; then
|
---|
86 | echo "Setting collections location to the default" >&2
|
---|
87 | GSDL3HOME=%WEB%
|
---|
88 | fi
|
---|
89 | export GSDL3HOME
|
---|
90 | default_url='http://localhost:8080/greenstone3/library'
|
---|
91 | if test -n "$interactive" -a -z "$GSDL_LIBRARY_URL" ; then
|
---|
92 | echo "What URL can the greenstone library be found at?" >&2
|
---|
93 | echo "[$default_url]" >&2
|
---|
94 | echo -n " > " >&2
|
---|
95 | read GSDL_LIBRARY_URL
|
---|
96 | fi
|
---|
97 | if test -z "$GSDL_LIBRARY_URL" ; then
|
---|
98 | echo "Setting library url to the default" >&2
|
---|
99 | GSDL_LIBRARY_URL="$default_url"
|
---|
100 | fi
|
---|
101 | export GSDL_LIBRARY_URL
|
---|
102 |
|
---|
103 | test -d "$GSDL3HOME/sites/localsite/collect" || mkdir -p "$GSDL3HOME/sites/localsite/collect"
|
---|
104 |
|
---|
105 | if test -n "$interactive" -a -n "$use_shell" ; then
|
---|
106 | test -z $SHELL && SHELL=sh
|
---|
107 | echo "Starting an interactive shell for GSDL management" >&2
|
---|
108 | $SHELL
|
---|
109 | fi
|
---|