Ubuntu init.d startup script

#! /bin/sh
### BEGIN INIT INFO
# Provides:          geoserver
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: GeoServer WMS/WFS server
# Description:       Java based application for serving OGC compliant web services.
### END INIT INFO

# Author: Amos Hayes <ahayes@gcrc.carleton.ca>

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/usr/sbin:/usr/bin:/sbin:/bin
DESC="Description of the service"
NAME=geoserver
SCRIPTNAME=/etc/init.d/$NAME

## Replace these with the values for your installation
GEOSERVER_USER=geoserver
GEOSERVER_DATA_DIR=/home/geoserver/data_dir
JAVA_HOME=/usr/lib/jvm/java-6-sun
GEOSERVER_HOME=/home/geoserver/geoserver-1.6.4b


# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"

	echo `date` >> $GEOSERVER_DATA_DIR/serverlog
	cd "$GEOSERVER_HOME"
	su "$GEOSERVER_USER" -c "$JAVA_HOME/bin/java -DGEOSERVER_DATA_DIR=$GEOSERVER_DATA_DIR -Djava.awt.headless=true -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar start.jar >> $GEOSERVER_DATA_DIR/serverlog 2>&1 &"
	
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"

	echo `date` >> $GEOSERVER_DATA_DIR/serverlog
	cd "$GEOSERVER_HOME"
	su "$GEOSERVER_USER" -c "$JAVA_HOME/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar start.jar --stop >> $GEOSERVER_DATA_DIR/serverlog 2>&1"

	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop}" >&2
	exit 3
	;;
esac

:
Added by Amos Hayes, last edited by Amos Hayes on Jun 04, 2008
View Attachments (0) Info