40 lines
626 B
Bash
Executable File
40 lines
626 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Adds an entry to /etc/profile.d for setting $JAVA_HOME.
|
|
#
|
|
# Arguments: $ACTION = [run/targets]
|
|
# $TARGET = [post-install/pre-remove]
|
|
# $PKGNAME
|
|
# $VERSION
|
|
# $UPDATE = [yes/no]
|
|
#
|
|
ACTION="$1"
|
|
TARGET="$2"
|
|
PKGNAME="$3"
|
|
VERSION="$4"
|
|
UPDATE="$5"
|
|
|
|
jdkprofile=etc/profile.d/openjdk.sh
|
|
|
|
case "$ACTION" in
|
|
targets)
|
|
echo "post-install"
|
|
;;
|
|
run)
|
|
[ -f "$jdkprofile" ] && exit 0
|
|
|
|
cat > "$jdkprofile" <<'EOF'
|
|
if _java_bin=$(readlink -e /usr/bin/java); then
|
|
_java_bin="${_java_bin%/bin/java}"
|
|
[ -d "${_java_bin}" ] && export JAVA_HOME="${JAVA_HOME:=${_java_bin}}"
|
|
fi
|
|
unset _java_bin
|
|
EOF
|
|
;;
|
|
*)
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0
|