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