summaryrefslogtreecommitdiff
blob: d8e1a6aa5990dbf567195fedbbf30a5be60edf65 (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
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/www-apps/mambo/mambo-4.5.2.3.ebuild,v 1.5 2005/10/23 15:04:30 rl03 Exp $

inherit webapp eutils

MY_P="${PN/M/m}V${PV}-Stable"
DESCRIPTION="Mambo is yet another CMS"
HOMEPAGE="http://www.mamboserver.com/"
SRC_URI="http://mamboforge.net/frs/download.php/4004/${MY_P}.tar.gz"

LICENSE="GPL-2"
KEYWORDS="~x86 ~ppc ~sparc ~amd64"
S=${WORKDIR}

IUSE=""

RDEPEND="dev-db/mysql
	virtual/php
	net-www/apache"
DEPEND="app-arch/unzip"

pkg_setup () {
	webapp_pkg_setup
	einfo "Please make sure that your PHP is compiled with XML and MySQL support"
}

src_install () {
	webapp_src_preinst
	local files="administrator/backups administrator/components components
	images images/banners images/stories mambots mambots/content mambots/search
	media language administrator/modules administrator/templates cache modules
	templates"

	dodoc CHANGELOG INSTALL

	cp -R [^d]* ${D}/${MY_HTDOCSDIR}

	for file in ${files}; do
		webapp_serverowned "${MY_HTDOCSDIR}/${file}"
	done

	webapp_postinst_txt en ${FILESDIR}/postinstall-en.txt

	webapp_src_install
}

pkg_postinst () {
	einfo "Now run \"emerge --config =${PF}\""
	einfo "to setup the database"
	einfo "Note that db and dbuser need to be present prior to running db setup"
	webapp_pkg_postinst
}

pkg_config() {
	# default values for db stuff
	D_DB="mambo"
	D_HOST="localhost"
	D_USER="mambo"

	# do we want to start mysqld?
	/etc/init.d/mysql restart || die "mysql needs to be running"

	echo -n "mysql db name [${D_DB}]: "; read MY_DB
	[[ -z ${MY_DB} ]] && MY_DB=${D_DB}

	echo -n "mysql db host [${D_HOST}]: "; read MY_HOST
	[[ -z ${MY_HOST} ]] && MY_HOST=${D_HOST}

	echo -n "mysql dbuser name [${D_USER}]: "; read MY_USER
	[[ -z ${MY_USER} ]] && MY_USER=${D_USER}

	echo -n "mysql dbuser password: "; read mypwd
	[[ -z ${mypwd} ]] && die "Error: no dbuser password"

	# privileges
	echo -n "Please enter login info for user who has grant privileges on ${MY_HOST} [$USER]: "; read adminuser
	[[ -z ${adminuser} ]] && adminuser="$USER"
	if [ "${MY_HOST}" != "localhost" ]; then
		echo -n "Client address (at db side) [$(hostname -f)]: "; read clientaddr
		[[ -z ${clientaddr} ]] && clientaddr="$(hostname -f)"
	fi
	# this will be default for localhost
	[[ -z ${clientaddr} ]] && clientaddr="${MY_HOST}"

	# if $MY_HOST == localhost, don't specify -h argument, so local socket can be used.
	host=${MY_HOST/localhost}
	mysqladmin -u ${adminuser} ${host:+-h ${host}} -p create ${MY_DB} || die "Error creating database"
	mysql -u "${adminuser}" "${host:+-h ${host}}" -p \
		-e "GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE,DROP,REFERENCES
		ON ${MY_DB}.* TO '${MY_USER}'@'${clientaddr}' IDENTIFIED BY '${mypwd}'; FLUSH PRIVILEGES;"  || die "Error initializing database. Please grant permissions manually."
}