1 | # It is important that the syntax this file is written in is compliant
|
---|
2 | # with /bin/sh syntax. By using this 'older' syntax, then this means
|
---|
3 | # it will operate with a range of newer default shell terminal windows,
|
---|
4 | # such as ash, bash, ksh, and zsh
|
---|
5 |
|
---|
6 | testSource() {
|
---|
7 |
|
---|
8 | if test "$0" != "`echo $0 | sed s/gs3-setup-cli\.sh//`" ; then
|
---|
9 | # if $0 contains "gs3-setup-cli.sh" we've been run... $0 is shellname if sourced.
|
---|
10 | # One exception is zsh has an option to set it temporarily to the script name
|
---|
11 | if test -z "$ZSH_NAME" ; then
|
---|
12 | # we aren't using zsh
|
---|
13 | gsdl_not_sourced=true
|
---|
14 | fi
|
---|
15 | fi
|
---|
16 |
|
---|
17 | if test -n "$gsdl_not_sourced" ; then
|
---|
18 | echo " Error: Make sure you source this script, not execute it. Eg:"
|
---|
19 | echo " $ . ./gs3-setup-cli.sh"
|
---|
20 | echo " or"
|
---|
21 | echo " $ source ./gs3-setup-cli.sh"
|
---|
22 | echo " not"
|
---|
23 | echo " $ ./gs3-setup-cli.sh"
|
---|
24 | unset gsdl_not_sourced
|
---|
25 | exit 1
|
---|
26 | fi
|
---|
27 |
|
---|
28 | if test ! -f gs3-setup-cli.sh ; then
|
---|
29 | echo "You must source the script from within the Greenstone home directory"
|
---|
30 | return 1
|
---|
31 | fi
|
---|
32 |
|
---|
33 | return 0
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | # Note: use return not exit from a sourced script otherwise it kills the shell
|
---|
38 | testSource
|
---|
39 | if [ "$?" = "1" ] ; then
|
---|
40 | return
|
---|
41 | fi
|
---|
42 |
|
---|
43 | export GSDL3_EXTCLI_HOME="$PWD/ext-cli"
|
---|
44 | echo "Set environment variable GSDL3_EXTCLI_HOME:"
|
---|
45 | echo " $GSDL3_EXTCLI_HOME"
|
---|
46 |
|
---|
47 | if test -e ext-cli ; then
|
---|
48 | for gsdl_ext in ext-cli/* ; do
|
---|
49 | if test -d $gsdl_ext ; then
|
---|
50 | echo $gsdl_ext
|
---|
51 | cd $gsdl_ext > /dev/null
|
---|
52 | if test -e SETUP.sh ; then
|
---|
53 | . ./SETUP.sh
|
---|
54 | fi
|
---|
55 | cd ../..
|
---|
56 | fi
|
---|
57 | done
|
---|
58 | fi
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|