#!/bin/sh
# 
# $FreeBSD: graphics/geoserver/files/geoserver.in 300896 2012-07-14 13:54:48Z beat $
#
# PROVIDE: geoserver
# REQUIRE: NETWORKING
#
# Add the following line to /etc/rc.conf[.local] to enable geoserver
#
# geoserver_enable (bool):	Set to "NO" by default.
#				Set it to "YES" to enable geoserver.


. /etc/rc.subr

name="geoserver"
rcvar=geoserver_enable

load_rc_config ${name}

: ${geoserver_enable="NO"}
: ${geoserver_stdout_log="/var/log/geoserver_output.log"}
: ${geoserver_stderr_log="/var/log/geoserver_error.log"}
: ${geoserver_user="root"}
: ${geoserver_chdir="/usr/local/geoserver"}
: ${geoserver_pidfile="/var/run/geoserver.pid"}

java_args="-DGEOSERVER_DATA_DIR=/usr/local/geoserver/data_dir -Djava.awt.headless=true \
		-DSTOP.PORT=8079 -DSTOP.KEY=geoserver -jar start.jar"
log_args=">> ${geoserver_stdout_log} 2>> ${geoserver_stderr_log}"

pidfile=${geoserver_pidfile}
command="/usr/sbin/daemon"
command_args="-p ${pidfile} /usr/local/openjdk6/bin/java ${java_args} ${geoserver_flags} ${log_args}"
procname="/usr/local/openjdk6/bin/java"

start_precmd=logs_touch

logs_touch()
{
    touch $geoserver_stdout_log $geoserver_stderr_log
    chown $geoserver_user $geoserver_stdout_log $geoserver_stderr_log
}

run_rc_command "$1"
