summaryrefslogtreecommitdiff
blob: f001528f709821b7ad79d894f72b6c99d2b0bcac (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
# Copyright 1999-2002 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-ftp/glftpd/glftpd-1.27.ebuild,v 1.3 2002/12/15 10:44:20 bjb Exp $

DESCRIPTION="a HIGHLY configurable ftp server"
HOMEPAGE="http://www.glftpd.com/"
MY_P=${P/-/-LNX_}
SRC_URI="http://www.glftpd.com/files/${MY_P}.tgz"
LICENSE="freedist"
SLOT="0"
KEYWORDS="~x86 ~ppc ~sparc ~alpha"

DEPEND=""
RDEPEND="sys-apps/xinetd"

S=${WORKDIR}/${MY_P}
GLROOT="${D}/opt/glftpd/"
[ -z "${GLFTPD_PORT}" ]	&&	GLFTPD_PORT=21

pkg_setup() {
	[ -d /proc/sysvipc/ ] || die "You need System V IPC support in your kernel"
}

src_compile() {
	[ "( use tcpd )" ]	&&	USETCPD=y	||	USETCPD=n
	[ -z "${JAIL}" ]	&&	JAIL=y		||	JAIL=n
	WHICHNETD=x

	cp ${S}/installgl.sh ${S}/installgl.sh.old
	sed -e "s:read usetcpd:usetcpd=${USETCPD}:" \
	 -e "s:read jaildir:jaildir=${GLROOT}:" \
	 -e "s:read jail:jail=y:" \
	 -e "s:read reply:echo OMG; exit 1:" \
	 -e "s:read useprivgroup:useprivgroup=n:" \
	 -e "s:read glroot:break:" \
	 -e "s:read port:port=${GLFTPD_PORT}:" \
	 -e "s:read whichnetd:whichnetd=x:" \
	 -e "s:killall -USR2 xinetd:0:" \
	 -e "s:/etc/xinetd.d/glftpd:${D}/etc/xinetd.d/glftpd:" \
	 -e "s:> /etc/services.new:>/dev/null:" \
	 -e "s:mv -f /etc/services.new:dumbvar=:" \
	 -e "s:| crontab -:>/dev/null:" \
		${S}/installgl.sh.old > ${S}/installgl.sh
}

src_install() {
	dodir /etc/xinetd.d

	${S}/installgl.sh

	#fix the glftpd.conf file
	cp ${GLROOT}/glftpd.conf ${GLROOT}/glftpd.conf.old
	sed -e "s:${GLROOT}:/opt/glftpd/:" \
		${GLROOT}/glftpd.conf.old > ${GLROOT}/glftpd.conf
	rm ${GLROOT}/glftpd.conf.old

	mv ${GLROOT}/glftpd.conf ${D}/etc/
	ln -s /etc/glftpd.conf ${GLROOT}/glftpd.conf

	#xinetd.d entry (use our custom one :])
	insinto /etc/xinetd.d
	newins ${FILESDIR}/glftpd.xinetd.d glftpd

	#env entry to protect our ftp passwd/group files
	insinto /etc/env.d
	newins ${FILESDIR}/glftpd.env.d 99glftpd

	#chmod the glftpd dir so that user files will work
	chmod 711 ${D}/opt/glftpd
}

pkg_postinst() {
	echo ""
	einfo "Read the documentation in /opt/glftpd/docs/"
	einfo "After you setup your conf file, edit the xinetd"
	einfo "entry in /etc/xinetd.d/glftpd to enable, then"
	einfo "start xinetd: /etc/init.d/xinetd start"
	echo ""
	einfo "To add glftpd to your services file and to"
	einfo "create a cronjob for auto generating statistics,"
	einfo "just run this command after you install:"
	echo ""
	einfo "ebuild /var/db/pkg/${CATEGORY}/${P}/${P}.ebuild config"
	echo ""
}

pkg_config() {
	einfo "Updating /etc/services"
	{ grep -v ^glftpd /etc/services;
	echo "glftpd   ${GLFTPD_PORT}/tcp"
	} > /etc/services.new
	mv -f /etc/services.new /etc/services

	einfo "Updating crontab"
	{ crontab -l | grep -v "bin/reset"
	  echo "0  0 * * *      $jaildir$glroot/bin/reset $confpath"
	} | crontab - > /dev/null
}