Last active
August 29, 2015 14:21
-
-
Save chrisisbeef/faee1c8258ca35a9d0c7 to your computer and use it in GitHub Desktop.
Install4J - Allow override of a bundled JRE in Unix Installer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Allow override of Bundled JRE | |
# Override can be set either via the INSTALL4J_JAVA_HOME_OVERRIDE environment variable or | |
# by passing -manual <path> to the installer. The -manual arg will override the environment | |
# variable if both are set. INSTALL4j_JAVA_HOME_OVERRIDE is provided if a savvy user looks | |
# up the Install4J documentation. | |
# | |
# Instructions: | |
# In your Unix Installer Media, select the "Installer Options" -> "Installer Custom Script" | |
# option in the left pane. Select direct entry and copy/paste this script into the provided | |
# editor. | |
# | |
# Author: chrisisbeef | |
# Version: 0.0.1 | |
# Set this to the supported version of Java for your application | |
SUPPORTED_JRE_VERSION="1.7" | |
[ "$1" = "-manual" ] && shift && INSTALL4J_JAVA_HOME_OVERRIDE=$1 | |
if [ ! -z "$INSTALL4J_JAVA_HOME_OVERRIDE" ]; then | |
echo "Testing Override JRE at $INSTALL4J_JAVA_HOME_OVERRIDE" | |
[ ! -f "$INSTALL4J_JAVA_HOME_OVERRIDE/bin/java" ] && echo "[!] No java found at $INSTALL4J_JAVA_HOME_OVERRIDE/bin" && INVALID_JAVA=true | |
JAVA_VERSION_TMP=$($INSTALL4J_JAVA_HOME_OVERRIDE/bin/java -version 2>&1 | grep "java version" | cut -d"\"" -f2) | |
[ -z $(echo $JAVA_VERSION_TMP | grep -q $SUPPORTED_JRE_VERSION && echo $?) ] && echo "[!] Invalid Java Version found: $JAVA_VERSION_TMP" && INVALID_JAVA=true | |
if [ ! -z "$INVALID_JAVA" ]; then | |
while true | |
do | |
read -p "Override JRE is not valid. Would you like to continue with the bundled JRE [Y/n]" USE_BUNDLED_JRE | |
case $USE_BUNDLED_JRE in | |
[Nn]) | |
echo "[!] No Valid JRE Available - Exiting" | |
exit 1 | |
;; | |
*) | |
break | |
;; | |
esac | |
done | |
else | |
echo "Using Override JRE ($JAVA_VERSION_TMP) at $INSTALL4J_JAVA_HOME_OVERRIDE" | |
app_java_home=$INSTALL4J_JAVA_HOME_OVERRIDE | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment