| author | Guillaume Alaux
<guillaume@archlinux.org> 2014-08-03 18:46:57 UTC |
| committer | Guillaume Alaux
<guillaume@archlinux.org> 2014-08-03 18:46:57 UTC |
| parent | c8b49893832059df6f02a1b5293faaf653b95881 |
| bin_archlinux-java | +16 | -5 |
diff --git a/bin_archlinux-java b/bin_archlinux-java index 73a896d..eb859c0 100755 --- a/bin_archlinux-java +++ b/bin_archlinux-java @@ -21,6 +21,17 @@ check_root() { fi } +check_java_home() { + if [ "x${JAVA_HOME}" != "x${DEFAULT_PATH}" ]; then + echo "JAVA_HOME is not set to '${DEFAULT_PATH}'," + echo 'which means this script may not provide the expected result.' + echo 'To fix this, please ensure '/etc/profile.d/jre.sh' sets JAVA_HOME' + echo 'accordingly and that no other profile script interfer.' + echo 'You may also need to relogin in order for this variable to be set.' + exit 1 + fi +} + # $1: parameter count given to this script for this option # $2: expected parameter count for this option check_param_count() { @@ -174,11 +185,11 @@ usage() { ## Main case $1 in - 'status') do_status;; - 'get') do_get;; - 'set') check_root; check_param_count $# 2; do_set $2;; - 'unset') check_root; do_unset;; - 'fix') check_root; do_fix;; + 'status') check_java_home; do_status;; + 'get') check_java_home; do_get;; + 'set') check_java_home; check_root; check_param_count $# 2; do_set $2;; + 'unset') check_java_home; check_root; do_unset;; + 'fix') check_java_home; check_root; do_fix;; 'help' | '--help' | '-h' | '') usage;; *) echo "$(basename $0): unknown option '$@'"; exit 1;; esac