#!/bin/bash BINDIR="`dirname "$0"`" cd "$BINDIR/.." BASEDIR="`pwd`" # Debugging with a msg box. Need double quotes around msg for $var expansion #osascript -e "tell app \"System Events\" to display alert \"bindir is: $BINDIR\" as warning giving up after 10" ## But this doesn't work: # http://stackoverflow.com/questions/23923017/osascript-using-bash-variable-with-a-space #osascript -e "display notification \"$BINDIR\"" #osascript -e 'display notification "'"$BINDIR"'"' # extract the JRE into /tmp and use its java to run the GS jar installer # the /tmp/jre folder will be moved into GS3/packages by the GS3 installer if [[ -e "$BASEDIR/Resources/Java/jre_bin" ]]; then cp "$BASEDIR/Resources/Java/jre_bin" /tmp/. && chmod +x "/tmp/jre_bin" && "/tmp/jre_bin" -o"/tmp" #&& rm "/tmp/jre_bin" if [[ -e "/tmp/jre.tar" ]]; then rm /tmp/jre_bin # 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) cd "$BASEDIR/Resources/Java/" gs_installer=`ls Greenstone-*-MacOS-intel.jar` tar -xvf /tmp/jre.tar -C /tmp && rm /tmp/jre.tar && "/tmp/jre/bin/java" -jar -Xdock:icon="$BASEDIR/Resources/icon.icns" "$gs_installer" # if after running the installer, the user cancelled installation, then the jre would still be in tmp, remove it to if [[ -e "/tmp/jre" ]]; then rm -rf /tmp/jre fi else # Issues extracting the jre.tar into /tmp (maybe we couldn't even copy it there) - display error message # see: https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW11 osascript -e "tell app \"System Events\" to display alert \"Unable to unpack jre into /tmp folder\" as warning giving up after 10" # exit fi fi