ports/devel/p5-Java/files/javaserver.sh.in
Doug Barton 83eb2c3700 In the rc.d scripts, change assignments to rcvar to use the
literal name_enable wherever possible, and ${name}_enable
when it's not, to prepare for the demise of set_rcvar().

In cases where I had to hand-edit unusual instances also
modify formatting slightly to be more uniform (and in
some cases, correct). This includes adding some $FreeBSD$
tags, and most importantly moving rcvar= to right after
name= so it's clear that one is derived from the other.
2012-01-14 08:57:23 +00:00

51 lines
1.3 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: javaserver
# REQUIRE: NETWORKING SERVERS
# BEFORE: DAEMON
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable javaserver:
# javaserver_enable (bool): Set to "NO" by default.
# Set it to "YES" to enable apache22
# javaserver_classpath (str): Set to "" by default.
# Define your classpath here.
# javaserver_user (str): Set to "nobody" by default.
# Define owner of the javaserver process.
. /etc/rc.subr
name="javaserver"
rcvar=javaserver_enable
load_rc_config $name
start_cmd="${name}_start"
stop_cmd="${name}_stop"
pidfile="/var/run/${name}.pid"
classpath="%%PREFIX%%"/share/p5-Java/JavaServer.jar
[ -z "$javaserver_classpath" ] || classpath="${javaserver_classpath}":$classpath
[ -z "$javaserver_enable" ] && javaserver_enable="NO"
[ -z "$javaserver_user" ] && javaserver_user="nobody"
javaserver_start()
{
su -m ${javaserver_user} -c "nohup %%PREFIX%%/bin/java -cp ${classpath} com.zzo.javaserver.JavaServer >/dev/null & ; echo \$! " | tail -1 > ${pidfile}
}
javaserver_stop()
{
if [ -f ${pidfile} ]; then
rc_pid=`cat ${pidfile}`
kill -TERM $rc_pid
wait_for_pids $rc_pid
rm ${pidfile}
fi
}
run_rc_command "$1"