summaryrefslogtreecommitdiff
blob: 30e6632d600ed7526698abf0c0653f39ad91d619 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-www/tomcat/tomcat-4.1.24.ebuild,v 1.3 2003/04/06 08:41:12 absinthe Exp $

S=${WORKDIR}/jakarta-${P}
At="jakarta-tomcat-${PV}.tar.gz"
DESCRIPTION="Apache Servlet Engine"
SRC_URI="http://jakarta.apache.org/builds/jakarta-tomcat-4.0/release/v${PV}/bin/${At}"
HOMEPAGE="http://jakarta.apache.org/tomcat"
KEYWORDS="x86 ppc sparc ~alpha"
LICENSE="Apache-1.1"
SLOT="0"
DEPEND=">=virtual/jdk-1.2"

src_unpack() {
	tar xzf ${DISTDIR}/${At} || die
	cd ${S}
	epatch ${FILESDIR}/${PV}/gentoo.diff
}


pkg_setup() {
	if ! groupmod tomcat ; then
		groupadd -g 265 tomcat || die "problem adding group tomcat, gid 265"
	fi
	if ! id tomcat; then
		useradd -u 265 -g tomcat -s /bin/bash -d /opt/tomcat -c "Apache Tomcat" tomcat || die "problem adding user tomcat, uid 265"
	fi
}

src_install() {
	TOMCAT_HOME="/opt/tomcat"
	INSTALLING="yes"
	DIROPTIONS="--mode=0775 --owner=tomcat --group=tomcat"
	
	# Create directories
	dodir ${TOMCAT_HOME}
	dodir /var/log/${PN}
	dosym /var/log/${PN} ${TOMCAT_HOME}/logs
	dodir ${TOMCAT_HOME}/temp
	dodir ${TOMCAT_HOME}/work

	touch ${D}${TOMCAT_HOME}/logs/.keep
	touch ${D}${TOMCAT_HOME}/temp/.keep
	touch ${D}${TOMCAT_HOME}/work/.keep

	cd ${S}

	# INIT SCRIPTS AND ENV
	
	cp -a ${FILESDIR}/${PV}/tomcat.init ${S}/tomcat
	insinto /etc/init.d
	insopts -m0750
	doins ${S}/tomcat

	cp -a ${FILESDIR}/${PV}/tomcat.conf ${S}/tomcat
	insinto /etc/conf.d
	insopts -m0755
	doins ${S}/tomcat
	
	cp -a ${FILESDIR}/${PV}/21tomcat ${S}/21tomcat
	insinto /etc/env.d
	insopts -m0755
	doins ${S}/tomcat

	# SEND JARS TO SHARED LOCATION
	for i in \
		common/endorsed/*.jar \
		common/lib/*.jar
	do
		dojar ${i}
		rm ${i}
	done

	dodoc RELEASE-NOTES-* README.txt RUNNING.txt LICENSE RELEASE-PLAN-4.1.txt
	
	chown -R tomcat.tomcat ${S}
	DIROPTIONS="--mode=0775 --owner=tomcat --group=tomcat"
	dodir ${TOMCAT_HOME}/common
	dodir ${TOMCAT_HOME}/common/classes
	dodir ${TOMCAT_HOME}/webapps
	
	cp -Rdp \
		bin \
		conf \
		server \
		shared \
		webapps \
		work \
		${D}${TOMCAT_HOME}
	
	dosym /usr/share/tomcat/package.env ${TOMCAT_HOME}/common/package.env
	dosym /usr/share/tomcat/lib ${TOMCAT_HOME}/common/endorsed
	dosym /usr/share/tomcat/lib ${TOMCAT_HOME}/common/lib
	
}

pkg_postinst() {
	einfo " "
	einfo " NOTICE!"
	einfo " User and group 'tomcat' have been added."
	einfo " "
	einfo " FILE LOCATIONS:"
	einfo " 1.  Tomcat home directory: ${TOMCAT_HOME}"
	einfo "     Contains application data, configuration files."
	einfo " 2.  Runtime settings: /etc/conf.d/tomcat"
	einfo "     Contains CLASSPATH and JAVA_HOME settings."
	einfo " 3.  Logs:  /var/log/tomcat/"
	einfo " 4.  Executables, libraries:  /usr/share/tomcat/"
	einfo " "
	einfo " "
	einfo " STARTING AND STOPPING ORION:"
	einfo "   /etc/init.d/tomcat start"
	einfo "   /etc/init.d/tomcat stop"
	einfo "   /etc/init.d/tomcat restart"
	einfo " "
	einfo " "
	einfo " NETWORK CONFIGURATION:"
	einfo " By default, Tomcat runs on port 8080.  You can change this"
	einfo " value by editing ${TOMCAT_HOME}/conf/server.xml."
	einfo " "
	einfo " To test Tomcat while it's running, point your web browser to:"
	einfo " http://localhost:8080/"
	einfo " "
	einfo " "
	einfo " BUGS:"
	einfo " Please file any bugs at http://bugs.gentoo.org/ or else it"
	einfo " may not get seen.  Thank you."
	einfo " "
	echo -ne "\a" ; sleep 1 ; echo -ne "\a" ; sleep 1 ; echo -ne "\a" ; sleep 1
        sleep 10

}

pkg_postrm() {
	if [ -z "${INSTALLING}" ] ; then
		einfo ">>> Removing user for Tomcat"
		userdel tomcat || die "Error removing Tomcat user"
		einfo ">>> Removing group for Tomcat"
		groupdel tomcat || die "Error removing Tomcat group"
	else
		einfo ">>> Tomcat user and group preserved"
	fi
}