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 newinitd "${FILESDIR}"/tinyerp-init.d tinyerp
49 newconfd "${FILESDIR}"/tinyerp-conf.d tinyerp
51 keepdir /var/run/tinyerp
52 fowners ${TINYERP_USER} ${TINYERP_GROUP} /var/run/tinyerp
54 keepdir /var/log/tinyerp
55 fowners ${TINYERP_USER} ${TINYERP_GROUP} /var/log/tinyerp
59 enewgroup ${TINYERP_GROUP}
60 enewuser ${TINYERP_USER} -1 -1 -1 ${TINYERP_GROUP}
62 einfo "In order to setup the initial database, run:"
63 einfo " emerge --config =${CATEGORY}/${PF}"
64 einfo "Be sure the database is started before"
68 psql -q -At -U postgres -d template1 -c "$@"
72 einfo "In the following, the 'postgres' user will be used."
73 if ! pquery "SELECT usename FROM pg_user WHERE usename = '${TINYERP_USER}'" | grep -q ${TINYERP_USER}; then
74 ebegin "Creating database user ${TINYERP_USER}"
75 createuser --quiet --username=postgres --no-createdb --no-adduser --no-createrole ${TINYERP_USER}
76 eend $? || die "Failed to create database user"
79 if ! pquery "SELECT datname FROM pg_database WHERE datname = '${TINYERP_DATABASE}'" |grep -q terp; then
80 ebegin "Creating database ${TINYERP_DATABASE}"
81 createdb --quiet --username=postgres --owner=terp --encoding=UNICODE ${TINYERP_DATABASE}
82 eend $? || die "Failed to create database"
85 einfo "The first time tinyerp-server is run it will initialize the database"