summaryrefslogtreecommitdiff
blob: e7553cba40d085f4306e5de7b26d6905bcbae969 (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
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-ftp/glftpd/glftpd-2.00.ebuild,v 1.5 2006/07/15 05:09:29 vapier Exp $

inherit eutils

MY_P=${P/-/-LNX_}
DESCRIPTION="a HIGHLY configurable ftp server"
HOMEPAGE="http://www.glftpd.com/"
SRC_URI="http://www.glftpd.com/files/${MY_P}.tgz"

LICENSE="freedist"
SLOT="0"
KEYWORDS="-* x86"
IUSE=""

DEPEND="dev-libs/openssl"
RDEPEND="${DEPEND}
	sys-apps/xinetd"

S=${WORKDIR}/${MY_P}

# custom options
export CUSTOMGLROOT=${CUSTOMGLROOT:-/opt/glftpd}
export GLROOT=${GLROOT:-${D}${CUSTOMGLROOT}}

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

src_unpack() {
	unpack ${A}
	cd "${S}"
	cp installgl.sh{,.orig}
	epatch "${FILESDIR}"/${P}-install.patch
	epatch "${FILESDIR}"/${P}-gcc.patch
	epatch "${FILESDIR}"/${P}-script-path-checks.patch
}

yesno() { if $@ ; then echo y ; else echo n ; fi ; }

src_install() {
	dodir /etc/xinetd.d

	# custom options
	export USETCPD=$(yesno useq tcpd)
	export JAIL=y
	export MAKETLS=$(yesno [[ ! -e ${ROOT}/etc/glftpd-dsa.pem ]])
	export WHICHNETD=x
	"${S}"/installgl.sh || die "installgl.sh failed"

	# fix the glftpd.conf file
	sed -i \
		-e "s:${GLROOT}:${CUSTOMGLROOT}/:" \
		${GLROOT}/glftpd.conf

	mv ${GLROOT}/glftpd.conf ${D}/etc/
	ln -s /etc/glftpd.conf ${GLROOT}/glftpd.conf
	if [[ -e ${ROOT}/etc/glftpd-dsa.pem ]] ; then
		cp "${ROOT}"/etc/glftpd-dsa.pem "${D}"/etc/
	else
		cp ftpd-dsa.pem "${D}"/etc/glftpd-dsa.pem
	fi
	ln -s /etc/glftpd-dsa.pem ${GLROOT}/etc/glftpd-dsa.pem
	fperms o-r /etc/glftpd-dsa.pem

	# xinetd.d entry (use our custom one :])
	insinto /etc/xinetd.d
	newins ${FILESDIR}/glftpd.xinetd.d glftpd
	dosed "s:GLROOT:${CUSTOMGLROOT}:g" /etc/xinetd.d/glftpd

	# env entry to protect our ftp passwd/group files
	newenvd ${FILESDIR}/glftpd.env.d 99glftpd
	dosed "s:GLROOT:${CUSTOMGLROOT}:g" /etc/env.d/99glftpd

	# chmod the glftpd dir so that user files will work
	chmod 711 ${GLROOT}
}

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 "emerge --config =${CATEGORY}/${PF}"
}

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

	einfo "Updating crontab"
	{ crontab -l | grep -v "bin/reset"
	echo "0  0 * * *      ${CUSTOMGLROOT}/bin/reset -r ${CUSTOMGLROOT}/glftpd.conf"
	} | crontab - > /dev/null
}