X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;ds=inline;f=scripts%2Fexamples%2Fcustom_overrides%2Ffred%2Fjava_profile.sh;fp=scripts%2Fexamples%2Fcustom_overrides%2Ffred%2Fjava_profile.sh;h=7186b4467fbd484d4067d2d44aada0beab1bd1a3;hb=a1f3c65741691541c269f9e74626ac764e27cc03;hp=0000000000000000000000000000000000000000;hpb=457b128b77b5b4a0b7dd3094de543de2ce1477ad;p=feisty_meow.git diff --git a/scripts/examples/custom_overrides/fred/java_profile.sh b/scripts/examples/custom_overrides/fred/java_profile.sh new file mode 100644 index 00000000..7186b446 --- /dev/null +++ b/scripts/examples/custom_overrides/fred/java_profile.sh @@ -0,0 +1,100 @@ +#!/bin/bash +# this script tries to intuit where java is installed on this machine. + +############################ + +function intuition_failure() +{ + missing="$1"; shift + echo "We cannot intuit your $missing variable for this host." + # remove the variable because its value is busted. + unset $missing +} + +############################ + +# set some fairly liberal limits for ant. +export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m" + +############################ + +# start guessing some settings... + +# this bin portion works for most javas... +export JAVA_BIN_PIECE=bin + +if [ ! -d "$JAVA_HOME" ]; then + # first try a recent linux version. + export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre +fi +if [ ! -d "$JAVA_HOME" ]; then + # try using a windows version. +#note: this logic is untested. +# probably will break due to space in path issues. + declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null) + if [ ${#any_there[*]} -gt 0 ]; then + (( last = ${#any_there[@]} - 1 )) + JAVA_HOME="${any_there[$last]}" + fi + if [ ! -d "$JAVA_HOME" ]; then + # if no jdk, try a jre. + declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null) + if [ ${#any_there[*]} -gt 0 ]; then + (( last = ${#any_there[@]} - 1 )) + JAVA_HOME="${any_there[$last]}" + fi + fi +fi +# this should go last, since it changes the bin dir. +if [ ! -d "$JAVA_HOME" ]; then + # if that didn't work, try the location for mac os x. + JAVA_HOME=/Library/Java/Home + JAVA_BIN_PIECE=Commands +fi +# last thing is to tell them we couldn't find it. +if [ ! -d "$JAVA_HOME" ]; then + intuition_failure JAVA_HOME + unset JAVA_BIN_PIECE +fi + +############################ + +# intuit where we have our local eclipse. +if [ ! -d "$ECLIPSE_DIR" ]; then + export ECLIPSE_DIR=/usr/local/eclipse_jee +fi +if [ ! -d "$ECLIPSE_DIR" ]; then + ECLIPSE_DIR=$HOME/eclipse +fi +if [ ! -d "$ECLIPSE_DIR" ]; then + ECLIPSE_DIR=$HOME/apps/eclipse +fi +if [ ! -d "$ECLIPSE_DIR" ]; then +#uhhh, default on winders? + ECLIPSE_DIR="/c/Program Files/eclipse" +fi +if [ ! -d "$ECLIPSE_DIR" ]; then + ECLIPSE_DIR="/c/tools/eclipse" +fi +if [ ! -d "$ECLIPSE_DIR" ]; then + ECLIPSE_DIR="/d/tools/eclipse" +fi +if [ ! -d "$ECLIPSE_DIR" ]; then + ECLIPSE_DIR="/e/tools/eclipse" +fi +# final option is to whine. +if [ ! -d "$ECLIPSE_DIR" ]; then intuition_failure ECLIPSE_DIR; fi + +############################ + +# use the variables we just set in our path, and try to make them override +# any other paths to different versions. + +if [ ! -z "$JAVA_HOME" ]; then + export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH +fi +if [ ! -z "$ECLIPSE_DIR" ]; then + export PATH=$ECLIPSE_DIR:$PATH +fi + +