Good Afternoon,

I am posting this script in hopes that others may find it useful. I
have copy/pasted it straight out of my own project, so don't expect
this to work as-is. I would welcome any feedback or improvements.  I
had originally included H2 as an embedded database, but later found
that multi-user concurrency was a problem, so I run it as a TCP Server
now. To save time, I put this script together to allow me to start,
stop, access the webadmin, and take backups of my db. This script was
NOT intended to be placed into /etc/init.d since it was not written
for any specific Linux/Unix distro. If for some reason the formatting
is wrong here, the source is available on my project's code
repository.

Cheers,
Chris Tusa
www.telegard.org


#!/bin/bash
#---[ File
Info ]-------------------------------------------------------------
#
# Source File: /h2.init.sh
#     Version: 1.00
#   Author(s): Chris Tusa <chris.t...@telegard.org>
# Description: Generic Shell script to start/stop H2 database
#
#-----------------------------------------------------------------------------


TELEGARD_HOME=/opt/telegard/bbs
H2_HOME=$TELEGARD_HOME/class
echo Using Embedded Database Engine in $TELEGARD_HOME
case $1 in
  start)
    cd $H2_HOME
    echo "Starting H2 Database Server"
    java -cp $H2_HOME/h2.jar org.h2.tools.Server -tcp -baseDir
$TELEGARD_HOME/db &
  ;;
  stop)
    echo "Shutting down H2 Database Server"
    java -cp $H2_HOME/h2.jar org.h2.tools.Server -tcpShutdown "tcp://
localhost"
  ;;
  web)
    echo "Starting H2 Web Server Admin Tool :: [CTRL-C] to
terminate..."
    java -cp $H2_HOME/h2.jar org.h2.tools.Server -web
    #echo "NOTE: The webserver administration tool must be"
    #echo "      shutdown from either the browser interface"
    #echo "      or by killing the PID of the service."
  ;;
  webremote)
    echo "Starting H2 Web Server Admin Tool :: [CTRL-C] to
terminate..."
    echo "                    *** !!! WARNING !!!! ***"
    echo ""
    echo "THIS MODE PERMITS REMOTE ACCESS TO YOUR MASTER DATABASE FROM
THE INTERNET!"
    echo "DO NOT LEAVE THE ADMIN WEB SERVER RUNNING!!          YOU
HAVE BEEN WARNED!"
    echo ""
    java -cp $H2_HOME/h2.jar org.h2.tools.Server -webAllowOthers
  ;;
  backup)
    echo "Taking backup of H2 Database (opentg)"
    java -cp $H2_HOME/h2.jar org.h2.tools.Backup -file "$TELEGARD_HOME/
db/backup.zip" -dir "$TELEGARD_HOME/db" -db "opentg"
  ;;
  sqldump)
    java -cp $H2_HOME/h2.jar org.h2.tools.Script -url jdbc:h2:tcp://
localhost/opentg -user '' -script $TELEGARD_HOME/sqldump.zip -options
compression zip
  ;;
  *)
    echo "Syntax is: h2 [start | stop | web | webremote | backup |
sqldump]"
  ;;
esac

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to h2-datab...@googlegroups.com.
To unsubscribe from this group, send email to 
h2-database+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to