summaryrefslogtreecommitdiff
path: root/www/jakarta-tomcat/files/tomcat.sh
blob: 040aed8ef0ef91426f090d80e988c3b4cf70289f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#! @RCD_SCRIPTS_SHELL@
#
# $NetBSD: tomcat.sh,v 1.10 2004/04/29 18:24:55 erh Exp $
#
# PROVIDE: tomcat
# REQUIRE: DAEMON
#
# To start tomcat at startup, copy this script to /etc/rc.d and set
# tomcat=YES in /etc/rc.conf.

PREFIX=@PREFIX@
TOMCAT_LIB=@TOMCAT_LIB@

if [ -z "${JAVA_HOME}" ]
then
	JAVA_HOME="@JAVA_HOME@"
	export JAVA_HOME
fi

name="tomcat"
rcvar=$name
command="${TOMCAT_LIB}/bin/catalina.sh"

# set defaults
if [ -r /etc/rc.conf ]
then
	. /etc/rc.conf
else
	eval ${rcvar}=YES
fi

# $flags from environment overrides ${rcvar}_flags
if [ -n "${flags}" ]
then
	eval ${rcvar}_flags="${flags}"
fi

CLASSPATH=${CLASSPATH}:${PREFIX}/lib/java/servlet.jar:${PREFIX}/lib/java/jaxp.jar:${PREFIX}/lib/java/parser.jar:${PREFIX}/lib/java/crimson.jar:${PREFIX}/lib/java/ant.jar
if [ -n "${tomcat_classpath}" ]
then
	CLASSPATH=${CLASSPATH}:${tomcat_classpath}
fi
export CLASSPATH

cmd=${1:-start}

checkyesno()
{
	eval _value=\$${1}
	case $_value in
	[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)	return 0 ;;
	[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)	return 1 ;;
	*)
		echo "\$${1} is not set properly."
		return 1
		;;
	esac
}

if checkyesno ${rcvar}
then
	if [ -x ${command} ]
	then
		case ${cmd} in
		run|start)
			echo "Starting ${name}."
			(cd ${TOMCAT_LIB} && ${command} ${cmd})
			;;

		stop)
			echo "Stopping ${name}."
			(cd ${TOMCAT_LIB} && ${command} ${cmd})
			;;

		restart)
			( $0 stop )
			sleep 5
			$0 start
			;;

		flush)
			cd ${TOMCAT_LIB}/work && rm -rf */*
			;;

		*)
			echo 1>&2 "Usage: $0 [restart|start|stop|flush]"
			exit 1
			;;
		esac
	fi
fi
exit 0