summaryrefslogtreecommitdiff
blob: 82afbc292435597676a3ae680cb324d920302aab (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
# 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-r1.ebuild,v 1.1 2005/02/10 17:26:25 ka0ttic Exp $

inherit webapp eutils

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

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

IUSE=""

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

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

src_unpack() {
	unpack ${MY_P}.tar.gz
	cd ${S}
	# sec bug 80578
	unpack Mambo450SecurityPatchFeb05a.zip
}

src_install () {
	webapp_src_preinst
	local files="administrator/backups administrator/components components images media language modules templates uploadfiles"

	dodoc documentation/Changelog-4.5 INSTALL
	dohtml documentation/Install.html

	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 ebuild /var/db/pkg/${CATEGORY}/${PF}/${PF}.ebuild config"
	einfo "to setup the database"
	einfo "Note that db and dbuser need to be present prior to running db setup"
}

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
	if (test -z ${MY_DB}) ; then MY_DB=${D_DB} ; fi

	echo -n "mysql db host [${D_HOST}]: "; read MY_HOST
	if (test -z ${MY_HOST}) ; then MY_HOST=${D_HOST}; fi

	echo -n "mysql dbuser name [${D_USER}]: "; read MY_USER
	if (test -z ${MY_USER}) ; then MY_USER=${D_USER} ; fi

	echo -n "mysql dbuser password: "; read mypwd
	if (test -z ${mypwd}) ; then die "Error: no dbuser password" ; fi

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

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