summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-06-07 19:25:33 +0100
committerdavidovski <david@davidovski.xyz>2022-06-07 19:25:33 +0100
commitca865c4de063c5b86c5d46a95b5a0ab415235c9e (patch)
tree76aae2178d3136e018363c557b4cf6881f2c7803
parente6a5137690fb94f6379499f76a4a07811922a379 (diff)
added default jvm scriptv1.6
-rwxr-xr-xMakefile5
-rwxr-xr-xsrc/default-jvm.sh49
2 files changed, 54 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index f616fc6..6838547 100755
--- a/Makefile
+++ b/Makefile
@@ -66,3 +66,8 @@ install-chroot: src/xichroot.sh
install -Dm755 src/xichroot.sh ${DESTDIR}${PREFIX}/bin/xichroot
+# default-jvm
+#
+install-chroot: src/default-jvm.sh
+ install -Dm755 src/default-jvm.sh ${DESTDIR}${PREFIX}/bin/default-jvm
+
diff --git a/src/default-jvm.sh b/src/default-jvm.sh
new file mode 100755
index 0000000..96f4f68
--- /dev/null
+++ b/src/default-jvm.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+JVM_DIR=/usr/lib/jvm
+JAVA_BIN=/bin/java
+
+usage () {
+ cat << EOF
+xilinux-java
+ Print the name of the currently linked jvm
+ non-zero exit code if none is linked
+
+xilinux-java [name]
+ create symlinks to /usr/lib/jvm/[name]/bin to /bin
+
+xilinux-java [-l]
+ list installed JVMs
+EOF
+}
+
+get () {
+ [ -h "$JAVA_BIN" ] && {
+ path=$(readlink "$JAVA_BIN")
+ path=${path%%/bin/java}
+ path=${path##*/}
+ echo $path
+ }
+}
+
+link () {
+ [ -d "$1" ] && for bin in $1/bin/*; do
+ ln -sf $bin /bin/${bin##*/}
+ done
+}
+
+
+[ "$#" = "0" ] && {
+ get || return 1
+} || {
+ case "$1" in
+ "-l"|"--list")
+ ls -1 $JVM_DIR
+ ;;
+ *)
+ link $1 \
+ || link $JVM_DIR/$1 \
+ || get
+ ;;
+ esac
+}
+