Skip to content

Instantly share code, notes, and snippets.

@manishatGit
Forked from solidsnack/ln_libjvm.bash
Created February 20, 2016 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manishatGit/2b5ea63bb787343e7d42 to your computer and use it in GitHub Desktop.
Save manishatGit/2b5ea63bb787343e7d42 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -o errexit -o nounset -o pipefail
function -h {
cat <<USAGE
USAGE: ln_libjvm.bash
Symlink a likely libjvm.so into /usr/bin.
USAGE
}; function --help { -h ;}
export LC_ALL=en_US.UTF-8
function main {
ln_libjvm
}
function ln_libjvm {
# Expand glob to get likely SOs.
local libjvms=( /usr/lib/jvm/java-*-openjdk-*/jre/lib/*/server/libjvm.so )
if [[ -f ${libjvms[0]} ]]
then sudo ln -nsf "${libjvms[0]}" /usr/lib/libjvm.so
else err "Not a file: ${libjvms[0]}"
fi
}
function msg { out "$*" >&2 ;}
function err { local x=$? ; msg "$*" ; return $(( $x == 0 ? 1 : $x )) ;}
function out { printf '%s\n' "$*" ;}
if [[ ${1:-} ]] && declare -F | cut -d' ' -f3 | fgrep -qx -- "${1:-}"
then "$@"
else main "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment