summaryrefslogtreecommitdiff
path: root/src/tools/default-jvm.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-06-27 01:14:42 +0100
committerdavidovski <david@davidovski.xyz>2022-06-27 01:14:42 +0100
commit7bba6cd7612293796e905885f9ed3072877798ab (patch)
treedd01942dbdd474a4df62ecf74479f5e78d83f1c8 /src/tools/default-jvm.sh
parent79fb6f41104cd0d88891598ddfc3c30d1bb0352d (diff)
added shmk, building all with shmk
Diffstat (limited to 'src/tools/default-jvm.sh')
-rwxr-xr-xsrc/tools/default-jvm.sh52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tools/default-jvm.sh b/src/tools/default-jvm.sh
new file mode 100755
index 0000000..56c427c
--- /dev/null
+++ b/src/tools/default-jvm.sh
@@ -0,0 +1,52 @@
+#!/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
+ ;;
+ "-h"|"--help")
+ usage
+ ;;
+ *)
+ link $1 \
+ || link $JVM_DIR/$1 \
+ || get
+ ;;
+ esac
+}
+