source: main/trunk/release-kits/shared/mac/Wrapper.app/Contents/MacOS/greenstone@ 30129

Last change on this file since 30129 was 30129, checked in by ak19, 9 years ago

Adding code to handle 32 bit MacOS case where there is no bundled jre: use the system java (which came with 32 bit Mac OS) to launch the gs installer.

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1#!/bin/bash
2
3BINDIR="`dirname "$0"`"
4cd "$BINDIR/.."
5BASEDIR="`pwd`"
6
7# Debugging with a msg box. Need double quotes around msg for $var expansion
8#osascript -e "tell app \"System Events\" to display alert \"bindir is: $BINDIR\" as warning giving up after 10"
9
10## But this doesn't work:
11# http://stackoverflow.com/questions/23923017/osascript-using-bash-variable-with-a-space
12#osascript -e "display notification \"$BINDIR\""
13#osascript -e 'display notification "'"$BINDIR"'"'
14
15# extract the JRE into /tmp and use its java to run the GS jar installer
16# the /tmp/jre folder will be moved into GS3/packages by the GS3 installer
17
18if [[ -e "$BASEDIR/Resources/Java/jre_bin" ]]; then
19 cp "$BASEDIR/Resources/Java/jre_bin" /tmp/. && chmod +x "/tmp/jre_bin" && "/tmp/jre_bin" -o"/tmp" #&& rm "/tmp/jre_bin"
20
21 if [[ -e "/tmp/jre.tar" ]]; then
22 rm /tmp/jre_bin
23 # get the GS jar installer's name and run it with a dock icon (http://stackoverflow.com/questions/6006173/how-do-you-change-the-dock-icon-of-a-java-program)
24 cd "$BASEDIR/Resources/Java/"
25 gs_installer=`ls Greenstone-*-MacOS-intel.jar`
26 tar -xvf /tmp/jre.tar -C /tmp && rm /tmp/jre.tar && "/tmp/jre/bin/java" -jar -Xdock:icon="$BASEDIR/Resources/icon.icns" "$gs_installer"
27
28 # if after running the installer, the user cancelled installation, then the jre would still be in tmp, remove it to
29 if [[ -e "/tmp/jre" ]]; then
30 rm -rf /tmp/jre
31 fi
32
33 else
34 # Issues extracting the jre.tar into /tmp (maybe we couldn't even copy it there) - display error message
35 # see: https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW11
36 osascript -e "tell app \"System Events\" to display alert \"Unable to unpack jre into /tmp folder\" as warning giving up after 10"
37 # exit
38 fi
39else
40 # try using a system java to run the installer, as there is no bundled jre_bin for 32 bit Mac OS since these already came with java installed
41
42 # get the GS jar installer's name and run it with a dock icon (http://stackoverflow.com/questions/6006173/how-do-you-change-the-dock-icon-of-a-java-program)
43 cd "$BASEDIR/Resources/Java/"
44 gs_installer=`ls Greenstone-*-MacOS-intel.jar`
45
46 # on a mac, the system java is returned by running /usr/libexec/java_home
47 # use this to run the greenstone installer
48 `/usr/libexec/java_home`/bin/java -jar -Xdock:icon="$BASEDIR/Resources/icon.icns" "$gs_installer"
49fi
Note: See TracBrowser for help on using the repository browser.