-
Notifications
You must be signed in to change notification settings - Fork 1
/
pc-client-linux.sh
executable file
·148 lines (129 loc) · 3.62 KB
/
pc-client-linux.sh
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/sh
#
# (c) Copyright 1999-2015 PaperCut Software International Pty Ltd
#
# A simple shell script to launch the client software on a Linux/Unix
# system.
#
#
# Make sure our current working dir is set to the location of this script
#
cd `dirname $0`
JAVACMD=
#
# Try to find a known good system Java installation. We look for an Oracle, Sun
# or OpenJDK Java of version 1.8+. Distros typically package these with a
# proper font configuration (looks good, includes CJK characters). IBM Java on
# SuSE did not have a proper font configuration (as of 2012).
#
# Path to "java" binary is assigned to $JAVACMD if found.
#
find_preferred_system_java() {
find_any_system_java
if [ -z "${JAVACMD}" ]; then
return 1;
fi
system_java_cmd=${JAVACMD}
JAVACMD=""
# Have known system Java, check version is 1.8+.
java_version=`"${system_java_cmd}" -version 2>&1 | head -1 | cut -d '"' -f2`
if [ -z "${java_version}" ]; then
# Couldn't detect system Java version.
return 1
fi
java_version_major=`echo ${java_version} | cut -d '.' -f 1`
case "${java_version_major}" in
# couldn't detect major version
''|*[!0-9]*) return 1 ;;
esac
java_version_minor=`echo ${java_version} | cut -d '.' -f 2`
case "${java_version_minor}" in
# couldn't detect minor version
''|*[!0-9]*) return 1 ;;
esac
if [ ${java_version_major} -ge 1 ] && [ ${java_version_minor} -ge 8 ]; then
: # Have Java 1.8+, use it.
else
# Old/unknown Java, don't use it.
return 1
fi
JAVACMD=${system_java_cmd}
return 0
}
#
# Look for our bundled Java version, preferring 64-bit if available and
# supported by the architecture. This does not have a distro-specific font
# configuration, so we prefer a system Java install if available.
#
# Path to "java" binary is assigned to $JAVACMD if found.
#
find_bundled_java() {
system_arch=`uname -m 2>/dev/null`
if [ "${system_arch}" = "x86_64" -a -x runtime/linux-x64/jre/bin/java ]; then
JAVACMD=runtime/linux-x64/jre/bin/java
return 0
elif [ -x runtime/linux-i686/jre/bin/java ]; then
JAVACMD=runtime/linux-i686/jre/bin/java
return 0
else
return 1
fi
}
#
# Look for any available system Java installation (fallback option).
#
# Path to "java" binary is assigned to $JAVACMD if found.
#
find_any_system_java() {
system_java_cmd=`which java 2>/dev/null`
if [ ! -x "${system_java_cmd}" ]; then
system_java_cmd=
fi
if [ -z "${system_java_cmd}" -a -n "${JAVA_HOME}" ]; then
system_java_cmd="${JAVA_HOME}/bin/java"
if [ ! -x "${system_java_cmd}" ]; then
system_java_cmd=
fi
fi
if [ -z "${system_java_cmd}" ]; then
# Didn't find a system Java.
return 1
fi
JAVACMD=${system_java_cmd}
return 0
}
find_preferred_system_java
if [ -z "${JAVACMD}" ]; then
find_bundled_java
fi
if [ -z "${JAVACMD}" ]; then
echo "Warning: Could not find required version of java (1.8 / 8.0 or higher)"
echo "This will now try to find and use any installed version of java."
find_any_system_java
fi
if [ ! -x "${JAVACMD}" ]; then
echo "Error: Could not find Java." 1>&2
echo "Please ensure Java 1.8 / 8.0 or higher is installed and java is on the path" 1>&2
exit 1
fi
#
# Construct the classpath
#
if [ "X`echo -n`" = "X-n" ]; then
echo_n() { echo ${1+"$@"}"\c"; }
else
echo_n() { echo -n ${1+"$@"}; }
fi
#
# Construct our classpath. The zip file(s) are used for custom messages. We need to ensure
# these add to the classpath first so they take priority (if they exist).
#
classpath=`(ls lib-ext/client-custom-messages.zip 2>/dev/null; ls lib/*.jar) | while read line
do
echo_n "${line}:"
done`
#
# Run the program
#
exec "${JAVACMD}" -classpath "${classpath}" \
-Dclient.home=. biz.papercut.pcng.client.uit.UserClient "$@"