derby revision 1172
340N/A#!/bin/sh
340N/A# Startup script for Apache Derby
340N/A#
340N/A# Software License Agreement (BSD License)
340N/A#
340N/A# Copyright (c) 2011, Trond Norbye
340N/A# All rights reserved.
340N/A#
340N/A# Redistribution and use in source and binary forms, with or without
340N/A# modification, are permitted provided that the following conditions are
340N/A# met:
340N/A#
340N/A# * Redistributions of source code must retain the above copyright
340N/A# notice, this list of conditions and the following disclaimer.
340N/A#
340N/A# * Redistributions in binary form must reproduce the above
340N/A# copyright notice, this list of conditions and the following disclaimer
340N/A# in the documentation and/or other materials provided with the
340N/A# distribution.
340N/A#
340N/A# * The names of the contributors may be used to endorse or promote
340N/A# products derived from this software without specific prior written
340N/A# permission.
340N/A#
340N/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
340N/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
340N/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
340N/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
340N/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
340N/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
340N/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
340N/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
340N/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
340N/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
340N/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
340N/A
340N/A### BEGIN INIT INFO
340N/A# Provides: derby
340N/A# Required-Start: $network $local_fs
340N/A# Required-Stop: $network $local_fs
340N/A# Default-Start: 2 3 4 5
340N/A# Default-Stop: 0 1 6
340N/A# Short-Description: start Apache Derby
340N/A### END INIT INFO
340N/A
340N/A#
340N/A# You may install the links by installing the file in /etc/init.d and
340N/A# execute:
340N/A# update-rc.d derby default
340N/A#
340N/A
340N/A# Defaults
340N/ADERBY_USER=opengrok
340N/ADERBY_GROUP=opengrok
340N/ADERBY_JVM_OPTIONS=
340N/ADERBY_DATA_DIR=/var/opengrok/derby
340N/ADERBY_JAR_DIR=/usr/lib/jvm/java-6-sun/db/lib
340N/ADERBY_JAR=${DERBY_JAR_DIR}/derbynet.jar
340N/A
340N/A# Reads config file (will override defaults above)
340N/A[ -r /etc/default/derby ] && . /etc/default/derby
340N/A
340N/APIDFILE=/var/run/derby.pid
340N/A
340N/A. /lib/lsb/init-functions
340N/A
340N/Acase "$1" in
340N/A start)
340N/A log_daemon_msg "Starting Derby"
340N/A # exit unless we've got the jar file
340N/A test -f ${DERBY_JAR}
340N/A if [ $? -ne 0 ]
340N/A then
340N/A log_failure_msg "Missing file: ${DERBY_JAR}"
340N/A exit 1
340N/A fi
340N/A
340N/A start-stop-daemon \
340N/A --start \
340N/A --chuid ${DERBY_USER}:${DERBY_GROUP} \
340N/A --background \
340N/A --make-pidfile \
340N/A --pidfile $PIDFILE \
340N/A --quiet \
340N/A --exec /usr/bin/java \
340N/A -- \
340N/A ${DERBY_JVM_OPTIONS} \
340N/A -Dderby.system.home=${DERBY_DATA_DIR} \
340N/A -jar ${DERBY_JAR_DIR}/derbynet.jar \
340N/A start
368N/A
368N/A if [ $? -ne 0 ]
368N/A then
368N/A log_end_msg 1
368N/A exit 1
340N/A fi
340N/A
340N/A log_end_msg 0
340N/A ;;
340N/A
340N/A stop)
340N/A log_daemon_msg "Stopping Derby"
340N/A start-stop-daemon --stop --quiet --pidfile $PIDFILE
340N/A log_end_msg 0
340N/A ;;
340N/A
340N/A restart)
340N/A $0 stop
340N/A if [ $? -eq 0 ]
340N/A then
340N/A sleep 1
340N/A $0 start
340N/A fi
340N/A ;;
340N/A
340N/A try-restart)
340N/A status_of_proc -p $PIDFILE /usr/bin/java Derby > /dev/null 2>&1
340N/A if [ $? -eq 0 ]
340N/A then
340N/A $0 restart
340N/A fi
340N/A ;;
340N/A
340N/A reload|force-reload)
340N/A ;;
340N/A
340N/A status)
340N/A status_of_proc -p $PIDFILE /usr/bin/java Derby
340N/A exit $?
340N/A ;;
340N/A *)
340N/A echo "Usage: /etc/init.d/derby {start|stop|restart|try-restart|reload|force-reload|status}"
340N/A exit 1
340N/A ;;
340N/Aesac
340N/A
340N/Aexit 0
340N/A