1 # Copyright 1999-2006 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 inherit eutils distutils
7 DESCRIPTION="Open Source ERP & CRM"
8 HOMEPAGE="http://tinyerp.org/"
17 DEPEND=">=dev-db/postgresql-7.4
22 =dev-python/psycopg-1*
31 DOWNLOAD_URL="http://tinyerp.com/component/option,com_vfm/Itemid,61/do,download/file,stable|source|${P}.tar.gz/"
33 einfo "Please donwload ${SRC_URI} from:"
35 einfo "and move it to ${DISTDIR}"
39 if ! built_with_use dev-libs/libxslt python ; then
40 eerror "dev-libs/libxslt must be built with python"
41 die "${PN} requires dev-libs/libxslt with USE=python"
48 epatch "${FILESDIR}/${P}-setup.patch"
54 newinitd "${FILESDIR}"/tinyerp-init.d tinyerp
55 newconfd "${FILESDIR}"/tinyerp-conf.d tinyerp
57 keepdir /var/run/tinyerp
58 fowners ${TINYERP_USER}:${TINYERP_GROUP} /var/run/tinyerp
60 keepdir /var/log/tinyerp
61 fowners ${TINYERP_USER}:${TINYERP_GROUP} /var/log/tinyerp
65 enewgroup ${TINYERP_GROUP}
66 enewuser ${TINYERP_USER} -1 -1 -1 ${TINYERP_GROUP}
68 einfo "In order to setup the initial database, run:"
69 einfo " emerge --config =${CATEGORY}/${PF}"
70 einfo "Be sure the database is started before"
74 psql -q -At -U postgres -d template1 -c "$@"
78 einfo "In the following, the 'postgres' user will be used."
79 if ! pquery "SELECT usename FROM pg_user WHERE usename = '${TINYERP_USER}'" | grep -q ${TINYERP_USER}; then
80 ebegin "Creating database user ${TINYERP_USER}"
81 createuser --quiet --username=postgres --no-createdb --no-adduser --no-createrole ${TINYERP_USER}
82 eend $? || die "Failed to create database user"
85 if ! pquery "SELECT datname FROM pg_database WHERE datname = '${TINYERP_DATABASE}'" |grep -q terp; then
86 ebegin "Creating database ${TINYERP_DATABASE}"
87 createdb --quiet --username=postgres --owner=terp --encoding=UNICODE ${TINYERP_DATABASE}
88 eend $? || die "Failed to create database"
91 einfo "The first time tinyerp-server is run it will initialize the database"