#!/bin/ksh93 # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License") # (see http://www.opensource.org/licenses/CDDL-1.0). # # Copyright (c) 2011-2012 Jens Elkner. All rights reserved. # Use is subject to license terms. . /lib/svc/share/smf_include.sh if [[ -z $SMF_FMRI ]]; then print -u2 "WARNING: Invoked outside SMF - Using default values, which might not be what you want." SMF_FMRI=application/glassfish/javadb fi getproparg() { val=`svcprop -p $1 $SMF_FMRI` [[ -n $val ]] && print $val } AS_HOME=${ getproparg config/ashome; } GFBASE=${AS_HOME}/glassfish/config if [[ ! -r $GFBASE/asenv.conf ]]; then print -u2 "$GFBASE/asenv.conf - use \"svccfg -s glassfish/javadb 'setprop config/ashome = glassfish_install_directory'; svccfg -s glassfish/javadb refresh\" to update the service property." exit $SMF_EXIT_ERR_CONFIG fi . $GFBASE/asenv.conf JAVA=${ whence java; } if [[ -r $GFBASE/$AS_DERBY_INSTALL/lib/derbynet.jar ]]; then derbylib=$( cd $GFBASE/$AS_DERBY_INSTALL; print $PWD )/lib/derbynet.jar else print -u2 "$GFBASE/$AS_DERBY_INSTALL contains no derbynet.jar" exit $SMF_EXIT_ERR_CONFIG fi if [[ -x $AS_JAVA/bin/java ]]; then java=$AS_JAVA/bin/java elif [[ -z $java || ! -x $java ]]; then print -u2 "No java found - adjust AS_JAVA in $GFBASE/asenv.conf" exit $SMF_EXIT_ERR_FATAL fi datadir=${ getproparg config/datadir; } if [[ -z $datadir ]]; then print -u2 "config/datadir property not set" exit $SMF_EXIT_ERR_CONFIG fi if (( $( cd $datadir; print $? ) )); then print -u2 "config/datadir directory ($datadir) does not exist" exit $SMF_EXIT_ERR_CONFIG fi jvmargs=${ getproparg config/jvmargs; } start_args=${ getproparg config/start_args; } shutdown_args=${ getproparg config/shutdown_args; } case "$1" in start) exec "$java" $jvmargs -Dderby.system.home="$datadir" -jar "$derbylib" \ start $start_args ;; stop) exec "$java" -Dderby.system.home="$datadir" -jar "$derbylib" \ shutdown $shutdown_args ;; *) print "Usage: $0 {start|stop}" exit 1 ;; esac exit $SMF_EXIT_OK