• Michael A. Goulet's avatar
    Add warning for out-of-date NanoDB package · 155cf487
    Michael A. Goulet authored
    If the last-modified date for any of the sources is higher than the
    last-modified date of the JAR produced by maven, then a warning will be
    emitted to make sure the user is aware that her/his changes may not be
    in effect.
    
    This modification also fails silently, e.g. if `find` is missing, or if
    the user doesn't have the right version of `stat` to support the printf
    flag.
    155cf487
ndbc 1.28 KB
#!/bin/bash

# Look for the NanoDB server JAR file in the target directory
NANODB_SERVER_JAR=`ls target/nanodb-server-*.jar 2>/dev/null`
if [ -z "$NANODB_SERVER_JAR" ]
then
    echo "ERROR: Can't find NanoDB server JAR file.  Run 'mvn package' to build the project."
    exit 1
fi

# Check if the sources are out of date and warn the user to rerun 'mvn package'.
{
  SOURCE_LAST_MODIFIED="$(find src -type f -exec stat \{\} --printf='%Y\n' \; | sort -n -r | head -n 1)"
  JAR_LAST_MODIFIED="$(stat $NANODB_SERVER_JAR --printf '%Y\n')"

  if [ -n "$SOURCE_LAST_MODIFIED" -a "$SOURCE_LAST_MODIFIED" -gt "$JAR_LAST_MODIFIED" ]; then
    echo "WARNING: Your jar file is out of date. Please  re-run 'mvn package' to rebuild the project."
  fi
} 2>/dev/null

# To set the page-size to use, add "-Dnanodb.pagesize=2048" to JAVA_OPTS.
# To enable transaction processing, add "-Dnanodb.txns=on" to JAVA_OPTS.
JAVA_OPTS="-Dlog4j.configurationFile=log4j2.properties"

# See if we have the rlwrap utility; if so, it makes using NanoDB
# from the command-line sooo much nicer...
testrl=$(which rlwrap)
if [ -z "$testrl" ]
then
    java $JAVA_OPTS -cp $NANODB_SERVER_JAR edu.caltech.nanodb.client.SharedServerClient
else
    rlwrap java $JAVA_OPTS -cp $NANODB_SERVER_JAR edu.caltech.nanodb.client.SharedServerClient
fi