Advertisement
Guest User

soft1

a guest
Nov 19th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.58 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Uncomment the following line to override the JVM search sequence
  4. # INSTALL4J_JAVA_HOME_OVERRIDE=
  5. # Uncomment the following line to add additional VM parameters
  6. # INSTALL4J_ADD_VM_PARAMS=
  7.  
  8. read_db_entry() {
  9. if [ -n "$INSTALL4J_NO_DB" ]; then
  10. return 1
  11. fi
  12. db_file=$HOME/.install4j
  13. if [ ! -f "$db_file" ]; then
  14. return 1
  15. fi
  16. if [ ! -x "$java_exc" ]; then
  17. return 1
  18. fi
  19. found=1
  20. exec 7< $db_file
  21. while read r_type r_dir r_ver_major r_ver_minor r_ver_micro r_ver_patch r_ver_vendor<&7; do
  22. if [ "$r_type" = "JRE_VERSION" ]; then
  23. if [ "$r_dir" = "$test_dir" ]; then
  24. ver_major=$r_ver_major
  25. ver_minor=$r_ver_minor
  26. ver_micro=$r_ver_micro
  27. ver_patch=$r_ver_patch
  28. fi
  29. elif [ "$r_type" = "JRE_INFO" ]; then
  30. if [ "$r_dir" = "$test_dir" ]; then
  31. is_openjdk=$r_ver_major
  32. found=0
  33. break
  34. fi
  35. fi
  36. done
  37. exec 7<&-
  38.  
  39. return $found
  40. }
  41.  
  42. create_db_entry() {
  43. tested_jvm=true
  44. echo testing JVM in $test_dir ...
  45. version_output=`"$bin_dir/java" $1 -version 2>&1`
  46. is_gcj=`expr "$version_output" : '.*gcj'`
  47. is_openjdk=`expr "$version_output" : '.*OpenJDK'`
  48. if [ "$is_gcj" = "0" ]; then
  49. java_version=`expr "$version_output" : '.*"\(.*\)".*'`
  50. ver_major=`expr "$java_version" : '\([0-9][0-9]*\)\..*'`
  51. ver_minor=`expr "$java_version" : '[0-9][0-9]*\.\([0-9][0-9]*\)\..*'`
  52. ver_micro=`expr "$java_version" : '[0-9][0-9]*\.[0-9][0-9]*\.\([0-9][0-9]*\).*'`
  53. ver_patch=`expr "$java_version" : '.*_\(.*\)'`
  54. fi
  55. if [ "$ver_patch" = "" ]; then
  56. ver_patch=0
  57. fi
  58. if [ -n "$INSTALL4J_NO_DB" ]; then
  59. return
  60. fi
  61. db_new_file=${db_file}_new
  62. if [ -f "$db_file" ]; then
  63. awk '$1 != "'"$test_dir"'" {print $0}' $db_file > $db_new_file
  64. rm $db_file
  65. mv $db_new_file $db_file
  66. fi
  67. dir_escaped=`echo "$test_dir" | sed -e 's/ /\\\\ /g'`
  68. echo "JRE_VERSION $dir_escaped $ver_major $ver_minor $ver_micro $ver_patch" >> $db_file
  69. echo "JRE_INFO $dir_escaped $is_openjdk" >> $db_file
  70. }
  71.  
  72. test_jvm() {
  73. tested_jvm=na
  74. test_dir=$1
  75. bin_dir=$test_dir/bin
  76. java_exc=$bin_dir/java
  77. if [ -z "$test_dir" ] || [ ! -d "$bin_dir" ] || [ ! -f "$java_exc" ] || [ ! -x "$java_exc" ]; then
  78. return
  79. fi
  80.  
  81. tested_jvm=false
  82. read_db_entry || create_db_entry $2
  83.  
  84. if [ "$ver_major" = "" ]; then
  85. return;
  86. fi
  87. if [ "$ver_major" -lt "1" ]; then
  88. return;
  89. elif [ "$ver_major" -eq "1" ]; then
  90. if [ "$ver_minor" -lt "5" ]; then
  91. return;
  92. fi
  93. fi
  94.  
  95. if [ "$ver_major" = "" ]; then
  96. return;
  97. fi
  98. app_java_home=$test_dir
  99. }
  100.  
  101. add_class_path() {
  102. if [ -n "$1" ] && [ `expr "$1" : '.*\*'` -eq "0" ]; then
  103. local_classpath="$local_classpath${local_classpath:+:}$1"
  104. fi
  105. }
  106.  
  107. compiz_workaround() {
  108. if [ "$is_openjdk" != "0" ]; then
  109. return;
  110. fi
  111. if [ "$ver_major" = "" ]; then
  112. return;
  113. fi
  114. if [ "$ver_major" -gt "1" ]; then
  115. return;
  116. elif [ "$ver_major" -eq "1" ]; then
  117. if [ "$ver_minor" -gt "6" ]; then
  118. return;
  119. elif [ "$ver_minor" -eq "6" ]; then
  120. if [ "$ver_micro" -gt "0" ]; then
  121. return;
  122. elif [ "$ver_micro" -eq "0" ]; then
  123. if [ "$ver_patch" -gt "09" ]; then
  124. return;
  125. fi
  126. fi
  127. fi
  128. fi
  129.  
  130.  
  131. osname=`uname -s`
  132. if [ "$osname" = "Linux" ]; then
  133. compiz=`ps -ef | grep -v grep | grep compiz`
  134. if [ -n "$compiz" ]; then
  135. export AWT_TOOLKIT=MToolkit
  136. fi
  137. fi
  138.  
  139. app_java_home=$test_dir
  140. }
  141.  
  142.  
  143. read_vmoptions() {
  144. vmoptions_file=`eval echo "$1"`
  145. if [ ! -r "$vmoptions_file" ]; then
  146. vmoptions_file="$prg_dir/$vmoptions_file"
  147. fi
  148. if [ -r "$vmoptions_file" ]; then
  149. exec 8< "$vmoptions_file"
  150. while read cur_option<&8; do
  151. is_comment=`expr "W$cur_option" : 'W *#.*'`
  152. if [ "$is_comment" = "0" ]; then
  153. vmo_classpath=`expr "W$cur_option" : 'W *-classpath \(.*\)'`
  154. vmo_classpath_a=`expr "W$cur_option" : 'W *-classpath/a \(.*\)'`
  155. vmo_classpath_p=`expr "W$cur_option" : 'W *-classpath/p \(.*\)'`
  156. vmo_include=`expr "W$cur_option" : 'W *-include-options \(.*\)'`
  157. if [ ! "$vmo_classpath" = "" ]; then
  158. local_classpath="$i4j_classpath:$vmo_classpath"
  159. elif [ ! "$vmo_classpath_a" = "" ]; then
  160. local_classpath="${local_classpath}:${vmo_classpath_a}"
  161. elif [ ! "$vmo_classpath_p" = "" ]; then
  162. local_classpath="${vmo_classpath_p}:${local_classpath}"
  163. elif [ "$vmo_include" = "" ]; then
  164. if [ "W$vmov_1" = "W" ]; then
  165. vmov_1="$cur_option"
  166. elif [ "W$vmov_2" = "W" ]; then
  167. vmov_2="$cur_option"
  168. elif [ "W$vmov_3" = "W" ]; then
  169. vmov_3="$cur_option"
  170. elif [ "W$vmov_4" = "W" ]; then
  171. vmov_4="$cur_option"
  172. elif [ "W$vmov_5" = "W" ]; then
  173. vmov_5="$cur_option"
  174. else
  175. vmoptions_val="$vmoptions_val $cur_option"
  176. fi
  177. fi
  178. fi
  179. done
  180. exec 8<&-
  181. if [ ! "$vmo_include" = "" ]; then
  182. read_vmoptions "$vmo_include"
  183. fi
  184. fi
  185. }
  186.  
  187.  
  188. run_unpack200() {
  189. if [ -f "$1/lib/rt.jar.pack" ]; then
  190. old_pwd200=`pwd`
  191. cd "$1"
  192. echo "Preparing JRE ..."
  193. jar_files="lib/rt.jar lib/charsets.jar lib/plugin.jar lib/deploy.jar lib/ext/localedata.jar lib/jsse.jar"
  194. for jar_file in $jar_files
  195. do
  196. if [ -f "${jar_file}.pack" ]; then
  197. bin/unpack200 -r ${jar_file}.pack $jar_file
  198.  
  199. if [ $? -ne 0 ]; then
  200. echo "Error unpacking jar files. The architecture or bitness (32/64)"
  201. echo "of the bundled JVM might not match your machine."
  202. echo "You might also need administrative privileges for this operation."
  203. exit 1
  204. fi
  205. fi
  206. done
  207. cd "$old_pwd200"
  208. fi
  209. }
  210.  
  211. old_pwd=`pwd`
  212.  
  213. progname=`basename "$0"`
  214. linkdir=`dirname "$0"`
  215.  
  216. cd "$linkdir"
  217. prg="$progname"
  218.  
  219. while [ -h "$prg" ] ; do
  220. ls=`ls -ld "$prg"`
  221. link=`expr "$ls" : '.*-> \(.*\)$'`
  222. if expr "$link" : '.*/.*' > /dev/null; then
  223. prg="$link"
  224. else
  225. prg="`dirname $prg`/$link"
  226. fi
  227. done
  228.  
  229. prg_dir=`dirname "$prg"`
  230. progname=`basename "$prg"`
  231. cd "$prg_dir"
  232. prg_dir=`pwd`
  233. app_home=.
  234. cd "$app_home"
  235. app_home=`pwd`
  236. bundled_jre_home="$app_home/jre"
  237.  
  238. if [ "__i4j_lang_restart" = "$1" ]; then
  239. cd "$old_pwd"
  240. else
  241. cd "$prg_dir"/.
  242.  
  243. fi
  244. if [ ! "__i4j_lang_restart" = "$1" ]; then
  245. run_unpack200 "$bundled_jre_home"
  246. run_unpack200 "$bundled_jre_home/jre"
  247. fi
  248. if [ -z "$app_java_home" ]; then
  249. test_jvm $INSTALL4J_JAVA_HOME_OVERRIDE
  250. fi
  251.  
  252. if [ -z "$app_java_home" ]; then
  253. if [ -f "$app_home/.install4j/pref_jre.cfg" ]; then
  254. read file_jvm_home < "$app_home/.install4j/pref_jre.cfg"
  255. test_jvm "$file_jvm_home"
  256. if [ -z "$app_java_home" ] && [ $tested_jvm = "false" ]; then
  257. rm $HOME/.install4j
  258. test_jvm "$file_jvm_home"
  259. fi
  260. fi
  261. fi
  262.  
  263. if [ -z "$app_java_home" ]; then
  264. path_java=`which java 2> /dev/null`
  265. path_java_home=`expr "$path_java" : '\(.*\)/bin/java$'`
  266. test_jvm $path_java_home
  267. fi
  268.  
  269.  
  270. if [ -z "$app_java_home" ]; then
  271. common_jvm_locations="/opt/i4j_jres/* /usr/local/i4j_jres/* $HOME/.i4j_jres/* /usr/bin/java* /usr/bin/jdk* /usr/bin/jre* /usr/bin/j2*re* /usr/bin/j2sdk* /usr/java* /usr/jdk* /usr/jre* /usr/j2*re* /usr/j2sdk* /usr/java/j2*re* /usr/java/j2sdk* /opt/java* /usr/java/jdk* /usr/java/jre* /usr/lib/java/jre /usr/local/java* /usr/local/jdk* /usr/local/jre* /usr/local/j2*re* /usr/local/j2sdk* /usr/jdk/java* /usr/jdk/jdk* /usr/jdk/jre* /usr/jdk/j2*re* /usr/jdk/j2sdk* /usr/lib/jvm/* /usr/lib/java* /usr/lib/jdk* /usr/lib/jre* /usr/lib/j2*re* /usr/lib/j2sdk*"
  272. for current_location in $common_jvm_locations
  273. do
  274. if [ -z "$app_java_home" ]; then
  275. test_jvm $current_location
  276. fi
  277.  
  278. done
  279. fi
  280.  
  281. if [ -z "$app_java_home" ]; then
  282. test_jvm $JAVA_HOME
  283. fi
  284.  
  285. if [ -z "$app_java_home" ]; then
  286. test_jvm $JDK_HOME
  287. fi
  288.  
  289. if [ -z "$app_java_home" ]; then
  290. test_jvm $INSTALL4J_JAVA_HOME
  291. fi
  292.  
  293. if [ -z "$app_java_home" ]; then
  294. if [ -f "$app_home/.install4j/inst_jre.cfg" ]; then
  295. read file_jvm_home < "$app_home/.install4j/inst_jre.cfg"
  296. test_jvm "$file_jvm_home"
  297. if [ -z "$app_java_home" ] && [ $tested_jvm = "false" ]; then
  298. rm $HOME/.install4j
  299. test_jvm "$file_jvm_home"
  300. fi
  301. fi
  302. fi
  303.  
  304. if [ -z "$app_java_home" ]; then
  305. echo No suitable Java Virtual Machine could be found on your system.
  306. echo The version of the JVM must be at least 1.5.
  307. echo Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
  308. echo You can also try to delete the JVM cache file $HOME/.install4j
  309. exit 83
  310. fi
  311.  
  312.  
  313. compiz_workaround
  314. i4j_classpath="$app_home/.install4j/i4jruntime.jar"
  315. local_classpath=""
  316. add_class_path "$i4j_classpath"
  317. add_class_path "$app_home/iSearchGurbani.jar"
  318.  
  319. vmoptions_val=""
  320. read_vmoptions "$prg_dir/$progname.vmoptions"
  321. INSTALL4J_ADD_VM_PARAMS="$INSTALL4J_ADD_VM_PARAMS $vmoptions_val"
  322.  
  323. if [ "W$vmov_1" = "W" ]; then
  324. vmov_1="-Di4j.vmov=true"
  325. fi
  326. if [ "W$vmov_2" = "W" ]; then
  327. vmov_2="-Di4j.vmov=true"
  328. fi
  329. if [ "W$vmov_3" = "W" ]; then
  330. vmov_3="-Di4j.vmov=true"
  331. fi
  332. if [ "W$vmov_4" = "W" ]; then
  333. vmov_4="-Di4j.vmov=true"
  334. fi
  335. if [ "W$vmov_5" = "W" ]; then
  336. vmov_5="-Di4j.vmov=true"
  337. fi
  338.  
  339. "$app_java_home/bin/java" -Dinstall4j.jvmDir="$app_java_home" -Dexe4j.moduleName="$prg_dir/$progname" "-" "Xmx256m" "$vmov_1" "$vmov_2" "$vmov_3" "$vmov_4" "$vmov_5" $INSTALL4J_ADD_VM_PARAMS -classpath "$local_classpath" com.install4j.runtime.Launcher launch isearchgurbani.SearchGurbaniApp true false "$prg_dir/error.log" "" true true false "" true true 0 0 "" 20 20 "Arial" "0,0,0" 8 500 "version 2.0" 20 40 "Arial" "0,0,0" 8 500 -1 "$@"
  340.  
  341.  
  342. exit $?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement