summaryrefslogtreecommitdiff
blob: 3b3a5169ce9ba4186ceddab2da1fe2b72dff43d5 (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
# Copyright 1999-2005 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# app-admin/postfixadmin/postfixadmin-2.1.0.ebuild, SteveB (tp22a@softhome.net)
#
# Revisions:
#   15.11.2003: app-admin/postfixadmin/postfixadmin-1.5.4.ebuild
#     - initial ebuild
#   03.09.2004: app-admin/postfixadmin/postfixadmin-2.0.5.ebuild
#     - switched to webapp
#   01.02.2005: app-admin/postfixadmin/postfixadmin-2.1.0.ebuild
# $Header: $

inherit eutils webapp

IUSE="mysql postgres vhosts"
DESCRIPTION="Postfix Admin is a Web Based Management tool for Postfix when you are dealing with Postfix Style Virtual Domains and Virtual Users that are stored in MySQL."
HOMEPAGE="http://high5.net/postfixadmin/"
SRC_URI="http://high5.net/${PN}/${PN}-${PV}.tgz"
RESTRICT="nomirror"
KEYWORDS="~x86"
DEPEND=">=mail-mta/postfix-2.0.0
	>=net-www/apache-1.3.27
	>=dev-php/php-4.1 <dev-php/php-5.0
	mysql? ( >=dev-db/mysql-3.23
		>=dev-lang/perl-5.0
		dev-perl/DBI
		dev-perl/DBD-mysql )
	postgres? ( >=dev-db/postgresql-7.4.3 )"

RDEPEND=">=sys-apps/sed-4.0.5
	 sys-apps/grep
	 sys-apps/findutils"

LICENSE="MPL-1.1"

pkg_setup() {
	webapp_pkg_setup
	if use mysql; then
		id vacation 2>/dev/null || enewgroup vacation
		id vacation 2>/dev/null || enewuser vacation -1 /bin/false /dev/null vacation
	fi
}

src_unpack() {
	unpack ${A} || die
	cd ${S}

	# Remove .cvs* files and CVS directories
	find ${S} -name .cvs\* -or \( -type d -name CVS -prune \) -exec rm -rf {} \;

	# Database support (we don't care wich one is used. Allow both of them!)
	if use mysql; then
		cp ./DATABASE_MYSQL.TXT ${T}/mysql-setup.sql || die "Creating MySQL setup script failed!"
		cp ./TABLE_CHANGES.TXT ${T}/mysql-update.sql || die "Creating MySQL update script failed!"
		cp ./VIRTUAL_VACATION/INSTALL.TXT ${T}/VIRTUAL_VACATION_INSTALL.TXT
	fi
	if use postgres ; then
		cp ./DATABASE_PGSQL.TXT ${T}/pgsql-setup.sql || die "Creating PostgreSQL setup script failed!"
	fi

	# Rename config.inc.php
	cp ./config.inc.php.sample ${T}/config.inc.php || die "Creating config file failed!"

	# Fix .htaccess
	if ! use vhosts; then
		sed -i "s:^\(AuthUserFile \).*$:\1${VHOST_ROOT}/${MY_HTDOCSBASE}/${PN}/admin/.htpasswd:gI" ./admin/.htaccess
	else
		sed -i "s:^\(AuthUserFile \).*$:\1/var/www/localhost/htdocs/${PN}/admin/.htpasswd:gI" ./admin/.htaccess
	fi
}

src_install() {
	webapp_src_preinst


	# Virtual Vacation only works with MySQL
	if use mysql; then
		diropts -m0770 -o vacation -g vacation
		dodir /var/spool/vacation
		keepdir /var/spool/vacation
		insinto /var/spool/vacation
		insopts -m770 -o vacation -g vacation
		doins ${S}/VIRTUAL_VACATION/vacation.pl
	fi

	# Documentation
	#
	local docs="BACKUP_MX.TXT CHANGELOG.TXT INSTALL.TXT LANGUAGE.TXT LICENSE.TXT TABLE_BACKUP_MX.TXT TABLE_CHANGES.TXT UPGRADE.TXT"
	if use mysql; then
		docs="${docs} DATABASE_MYSQL.TXT ${T}/VIRTUAL_VACATION_INSTALL.TXT"
	fi
	if use postgres ; then
		docs="${docs} DATABASE_PGSQL.TXT"
	fi


	# install the SQL scripts available to us
	#
	# unfortunately, we do not have scripts to upgrade from older versions
	# these are things we need to add at a later date
	#
	if use mysql; then
		webapp_sqlscript mysql ${T}/mysql-setup.sql
		webapp_sqlscript mysql ${T}/mysql-update.sql 2.0.x
		webapp_sqlscript mysql ${T}/mysql-update.sql 1.5x
	fi
	if use postgres ; then
		webapp_sqlscript pgsql ${T}/pgsql-setup.sql
	fi


	# Copy the app's main files
	#
	einfo "Installing main files"
	mkdir -p ${D}${MY_HTDOCSDIR}
	cp -r . ${D}${MY_HTDOCSDIR} || die "cp failed"
	cp ${T}/config.inc.php ${D}${MY_HTDOCSDIR} || die "cp failed"

	# handle documentation files
	#
	# NOTE that doc files go into /usr/share/doc as normal; they do NOT
	# get installed per vhost!
	#
	dodoc ${docs}
	for foo in ${docs} DATABASE_MYSQL.TXT DATABASE_PGSQL.TXT
	do
		rm -f ${D}${MY_HTDOCSDIR}/${foo}
	done

	# handle additional (maybe) not needed files and directories
	#
	for foo in ADDITIONS VIRTUAL_VACATION
	do
		rm -rf ${D}${MY_HTDOCSDIR}/${foo}
	done
	
	# Identify the configuration files that this app uses
	#
	webapp_configfile ${MY_HTDOCSDIR}/config.inc.php

	# Add the post-installation instructions
	#
	webapp_postinst_txt en ${FILESDIR}/postinstall-en.txt

	# All done
	#
	# Now we let the eclass strut its stuff ;-)
	#
	webapp_src_install
}