summaryrefslogtreecommitdiff
path: root/setup_native/scripts/javaloader.sh
blob: 46172239d2692e2471509c40383b3772a421dcbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh

jarfilename="JavaSetup.jar"
java_runtime="java"
java_runtime_set="no"
java_runtime_found="no"

# the user might want to specify java runtime on the commandline
USAGE="Usage: $0 [ -j <java_runtime> ]"
while getopts hj: opt; do
    case $opt in
        j)  java_runtime_set="yes";
            java_runtime="${OPTARG}"
            if [ ! -f "$java_runtime" ]; then
                echo "Invalid java runtime $java_runtime, file does not exist"
                exit 1
            fi
            if [ ! -x "$java_runtime" ]; then
                echo "Invalid java runtime $java_runtime, not an executable file"
                exit 1
            fi
            ;;
        h)  echo ${USAGE}
            exit 1
            ;;
        \?) echo ${USAGE}
            exit 1
            ;;
    esac
done

# Search for Java, if not specified on command line

if [ "$java_runtime_set" != "yes" ]; then
    # searching for java runtime in path
    for i in `echo $PATH | sed -e 's/^:/.:/g' -e 's/:$/:./g' -e 's/::/:.:/g' -e 's/:/ /g'`; do
        if [ -x "$i/$java_runtime" -a ! -d "$i/$java_runtime" ]; then
            java_runtime="$i/$java_runtime"
            java_runtime_found="yes"
            break;
        fi
    done

    if [ "$java_runtime_found" != "yes" ]; then
        echo "No Java runtime environment found. Please install Java runtime before starting $0."
        exit 1
    fi
fi

# check Java version (not required yet) -> every Java has to work without problems

# Determining current platform
# platform=`uname -s`

# verify that we are running on the right platform -> has to be done in Java program.

umask 022

echo "Using $java_runtime"
echo `$java_runtime -version`
echo "Running installer"

# looking for environment variables

home=""
if [ "x" != "x$HOME" ]; then
    home=-DHOME=$HOME
fi

log_module_states=""
if [ "x" != "x$LOG_MODULE_STATES" ]; then
    log_module_states=-DLOG_MODULE_STATES=$LOG_MODULE_STATES
fi

getuid_path=""
if [ "x" != "x$GETUID_PATH" ]; then
    getuid_path=-DGETUID_PATH=$GETUID_PATH
fi

# changing into setup directory
cd "`dirname "$0"`"

# run the installer class file
echo $java_runtime $home $log_module_states $setup_root_path $package_root_path -jar $jarfilename
$java_runtime $home $log_module_states $getuid_path -jar $jarfilename

exit 0