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