#!/bin/sh
##
##  h2.sh -- H2 startup wrapper script
##

tool="Shell"
if [ $# -ge 1 ]; then
    case "$1" in
        Backup|ChangeFileEncryption|Console|ConvertTraceFile|CreateCluster|DeleteDbFiles|Recover|Restore|RunScript|Script|Server|Shell )
            tool="$1"
            shift
            ;;
        *)
            echo "Invalid tool: $1" 1>&2
            exit 1
            ;;
    esac
fi
wrapper=""
if [ ".$tool" = .Shell ]; then
    if [ -x @l_prefix@/bin/rlwrap ]; then
        wrapper="@l_prefix@/bin/rlwrap --command-name=h2 --history-filename=$HOME/.h2.shell.history --remember"
    fi
fi
exec $wrapper @l_prefix@/bin/java \
   -Vsun-jdk \
   -cp @l_prefix@/lib/h2/h2.jar \
   "org.h2.tools.$tool" \
   ${1+"$@"}

