[vlma-devel] commit: Improvement of the startup script. (Adrien Grand )

git version control git at videolan.org
Sat Jul 19 11:27:53 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Fri Jul 18 23:32:07 2008 +0200| [1718c242ac6b972220fe89f4e1b38e6df58ccb74]

Improvement of the startup script.

 - verify that required folders exist,
 - if neither JAVA_HOME nor JRE_HOME is defined, search for the java executable on the PATH.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=1718c242ac6b972220fe89f4e1b38e6df58ccb74
---

 vlma-distribution/src/bin/vlmad |   45 +++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/vlma-distribution/src/bin/vlmad b/vlma-distribution/src/bin/vlmad
index ac59606..eb9c3d7 100644
--- a/vlma-distribution/src/bin/vlmad
+++ b/vlma-distribution/src/bin/vlmad
@@ -1,10 +1,9 @@
 #!/bin/sh
 
-set -e
-
 function usage() {
     echo "Usage: vlmad [start|stop|reload|help]"
 }
+
 # Parse command line
 COMMAND="$1"
 if [ "$COMMAND" = "start" ]
@@ -26,11 +25,18 @@ else
     exit 1
 fi
 
-# Detect JAVA installation
+# Find the JAVA executable
 if [ -z "$JAVA_HOME" -a -z "$JRE_HOME" ]
 then
-    echo "[ERROR] Neither JAVA_HOME nor JRE_HOME is defined."
-    exit 1
+    which java
+    if [ "x$?" = "x0" ]
+    then
+        JAVA=`which java`
+    else
+        echo "[ERROR] Cannot find the Java executable."
+        echo "Please ensure that Java Runtime Environment is installed and that the Java executable is on your PATH."
+        exit 1
+    fi
 fi
 if [ -z "$JRE_HOME" ]; then
     JRE_HOME="$JAVA_HOME"
@@ -46,22 +52,39 @@ fi
 PRG="$0"
 PRGDIR=`dirname $PRG`
 
-[ -z "$VLMA_HOME" ] && VLMA_HOME=`cd "$PRGDIR/.."; pwd`
+function check_dir() {
+    dir=$1
+    if [ ! -d "$dir" ]
+    then
+        echo "[ERROR] $dir does not exist."
+        echo "This directory is required for VLMa to run. Please create it before running VLMa again."
+        exit 1
+    fi
+
+}
+
+[ "$VLMA_HOME" != "" ] || VLMA_HOME=`cd "$PRGDIR/.."; pwd`
+check_dir $VLMA_HOME
 echo "[INFO] Using VLMA_HOME: $VLMA_HOME"
 
-[ -z "$VLMA_CONF" ] && VLMA_CONF="$VLMA_HOME/conf"
+[ "$VLMA_CONF" != "" ] || VLMA_CONF="$VLMA_HOME/conf"
+check_dir $VLMA_CONF
 echo "[INFO] Using VLMA_CONF: $VLMA_CONF"
 
-[ -z "$VLMA_DATA" ] && VLMA_DATA="$VLMA_HOME/data"
+[ "$VLMA_DATA" != "" ] || VLMA_DATA="$VLMA_HOME/data"
+check_dir $VLMA_DATA
 echo "[INFO] Using VLMA_DATA: $VLMA_DATA"
 
-[ -z "$VLMA_LIBS" ] && VLMA_LIBS="$VLMA_HOME/lib"
+[ "$VLMA_LIBS" != "" ] || VLMA_LIBS="$VLMA_HOME/lib"
+check_dir $VLMA_LIBS
 echo "[INFO] Using VLMA_LIBS: $VLMA_LIBS"
 
-[ -z "$VLMA_LOGS" ] && VLMA_LOGS="$VLMA_HOME/logs"
+[ "$VLMA_LOGS" != "" ] || VLMA_LOGS="$VLMA_HOME/logs"
+check_dir $VLMA_LOGS
 echo "[INFO] Using VLMA_LOGS: $VLMA_LOGS"
 
-[ -z "$VLMA_WORK" ] && VLMA_WORK="$VLMA_HOME/work"
+[ "$VLMA_WORK" != "" ] || VLMA_WORK="$VLMA_HOME/work"
+check_dir $VLMA_WORK
 echo "[INFO] Using VLMA_WORK: $VLMA_WORK"
 
 # Set classpath



More information about the vlma-devel mailing list