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