summaryrefslogtreecommitdiff
blob: 2fb046336d6267dabae4b14b295e967e91b72294 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-www/tomcat/tomcat-4.1.29.ebuild,v 1.4 2004/06/25 01:14:15 agriffis Exp $

inherit eutils


At="jakarta-tomcat-${PV}.tar.gz"
DESCRIPTION="Apache Servlet-2.3/JSP-1.2 Container"
SRC_URI="http://apache.sunsite.ualberta.ca/jakarta/tomcat-4/v4.1.29/bin/${At}"
HOMEPAGE="http://jakarta.apache.org/tomcat"
KEYWORDS="x86 ~ppc ~sparc ~alpha"
LICENSE="Apache-1.1"
SLOT="0"
DEPEND="sys-apps/sed"
RDEPEND=">=virtual/jdk-1.2"
IUSE=""

S=${WORKDIR}/jakarta-${P}

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


pkg_setup() {
	USERADDED=false
	if ! groupmod tomcat >/dev/null 2>&1 ; then
		groupadd -g 265 tomcat || die "problem adding group tomcat, gid 265"
		USERADDED=true
	fi
	if ! id tomcat >/dev/null 2>&1 ; then
		useradd -u 265 -g tomcat -s /bin/bash -d /opt/tomcat -c "Apache Tomcat" tomcat || die "problem adding user tomcat, uid 265"
		USERADDED=true
	fi
}

src_install() {
	TOMCAT_HOME="/opt/tomcat"
	INSTALLING="yes"
	DIROPTIONS="--mode=0755 --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

	keepdir /var/log/${PN}
	keepdir ${TOMCAT_HOME}/temp
	keepdir ${TOMCAT_HOME}/work

	cd ${S}

	# INIT SCRIPTS AND ENV

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

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

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

	# SEND JARS TO SHARED LOCATION
	for i in \
		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=0755 --owner=tomcat --group=tomcat"
	dodir ${TOMCAT_HOME}/common
	dodir ${TOMCAT_HOME}/common/classes
	dodir ${TOMCAT_HOME}/webapps

	rm bin/*.bat bin/*.exe

	cp -Rdp \
		bin \
		server \
		shared \
		webapps \
		work \
		${D}${TOMCAT_HOME}

	cp -Rdp common/endorsed ${D}${TOMCAT_HOME}/common/

	cp -Rdp conf ${D}/etc/tomcat
	fperms 640 /etc/tomcat/tomcat-users.xml

	dosym /usr/share/tomcat/package.env ${TOMCAT_HOME}/common/package.env
	dosym /usr/share/tomcat/lib ${TOMCAT_HOME}/common/lib
	dosym /etc/tomcat ${TOMCAT_HOME}/conf

}

pkg_postinst() {
	einfo " "
	einfo " NOTICE!"
	if ${USERADDED} ; then
		einfo " User and group 'tomcat' have been added."
		einfo " "
	fi
	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.  Configuration:  /etc/tomcat/"
	einfo " 4.  Logs:  /var/log/tomcat/"
	einfo " 5.  Executables, libraries:  /usr/share/tomcat/"
	einfo " "
	einfo " "
	einfo " STARTING AND STOPPING TOMCAT:"
	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 /etc/tomcat/server.xml."
	einfo " "
	einfo " To test Tomcat while it's running, point your web browser to:"
	einfo " http://${HOSTNAME}: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() gets called during an unmerge and seperately (new environment)
# from the src_install() earlier so setting the INSTALLING var does not work.
#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
#}