]> Pileus Git - ~andy/sunrise/blob - mail-mta/citadel/citadel-8.04.ebuild
mail-mta/citadel: Version bump to 8.04 and EAPI=4 cleanups. Initscript improved and...
[~andy/sunrise] / mail-mta / citadel / citadel-8.04.ebuild
1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI=4
6 inherit user multilib
7
8 DESCRIPTION="Groupware with BBS/Email/XMPP Server, Collaboration and Calendar"
9 HOMEPAGE="http://www.citadel.org/"
10 SRC_URI="http://easyinstall.citadel.org/${P}.tar.gz"
11
12 LICENSE="GPL-3"
13 SLOT="0"
14 KEYWORDS="~amd64 ~x86"
15 IUSE="ldap pam pic postfix ssl threads"
16 # postfix can be used as mta with citadel. citadel needs to provide virtual/mta
17 # in all other cases or other ebuilds depending on virtual/mta cause blockers
18
19 DEPEND="=dev-libs/libcitadel-${PV}
20         >=sys-libs/db-4.2
21         virtual/libiconv
22         ldap? ( net-nds/openldap )
23         pam? ( sys-libs/pam )
24         ssl? ( dev-libs/openssl )"
25 RDEPEND="${DEPEND}
26         net-mail/mailbase
27         postfix? ( mail-mta/postfix )"
28
29 MESSAGEBASE="/var/lib/citadel"
30
31 pkg_setup() {
32         #Homedir needs to be the same as --with-datadir
33         einfo "Adding Citadel User/Group"
34         enewgroup citadel
35         enewuser citadel -1 -1 ${MESSAGEBASE} citadel,mail
36 }
37
38 src_configure() {
39         econf \
40                 --with-autosysconfdir=/var/lib/citadel/data \
41                 --with-datadir=/var/lib/citadel \
42                 --with-docdir=/usr/share/doc/${PF} \
43                 --with-helpdir=/usr/share/citadel-server \
44                 --with-localedir=/usr/share/locale \
45                 --with-rundir=/var/run/citadel \
46                 --with-spooldir=/var/spool/citadel \
47                 --with-ssldir=/etc/ssl/citadel \
48                 --with-staticdatadir=/etc/citadel \
49                 --with-sysconfdir=/etc/citadel \
50                 --with-utility-bindir=/usr/$(get_libdir)/citadel \
51                 --with-db \
52                 $(use_with pam) \
53                 $(use_enable pic pie) \
54                 $(use_with ldap with-ldap) \
55                 $(use_with ssl)
56 }
57
58 src_install() {
59         if use pam ; then
60                  dodir /etc/pam.d
61         fi
62
63         emake DESTDIR="${D}" install-new
64
65         # Protect files created at runtime by the server
66         echo CONFIG_PROTECT="${MESSAGEBASE}" > "${T}"/10citadel
67         doenvd "${T}"/10citadel
68
69         # Keep emerge from removing empty directories when updating
70         keepdir "${MESSAGEBASE}"/data
71         keepdir /var/spool/citadel/network/{systems,spoolout,spoolin}
72         keepdir /var/run/citadel/network/{systems,spoolout,spoolin}
73         keepdir /etc/citadel/messages
74
75         #Fix some permissions and sendmail stuff
76         fowners citadel:citadel /etc/citadel /var/lib/citadel
77         fowners root:citadel /usr/sbin/citmail
78         rm "${D}"/usr/sbin/sendmail || die "Removing sendmail bin failed"
79
80         if ! use postfix ; then
81                 dosym /usr/sbin/citmail /usr/sbin/sendmail
82                 dosym /usr/sbin/citmail /usr/$(get_libdir)/sendmail
83         fi
84
85         if use ldap ; then
86                 insinto /etc/openldap/schema
87                 doins openldap/citadel.schema
88                 doins openldap/rfc2739.schema
89         fi
90
91         newinitd "${FILESDIR}"/citadel.init citadel
92         newconfd "${FILESDIR}"/citadel.confd citadel
93
94         dodoc "${FILESDIR}"/README.gentoo
95 }
96
97 pkg_postinst() {
98         #remove a file Citadel complains about in the logs while running
99         rm /var/lib/citadel/data/.keep_mail-mta_citadel-0 || die "Removing keepdir dummie failed"
100
101         elog "The administration tools have been placed in /usr/$(get_libdir)/citadel"
102         elog
103         elog "If this is your first install, run the following for a quick setup:"
104         elog "# emerge --config =${CATEGORY}/${PF}"
105         elog
106         elog "For further information check /usr/share/doc/${PF}/README.gentoo"
107 }
108
109 pkg_config() {
110         #we have to stop the server if it is accidently running
111         [ -f /var/run/citadel/citadel.socket ] && \
112                 die "Citadel seems to be running, please stop it while configuring!"
113
114         #Citadel's setup uses a few enviromental variables to control it.
115         # Mandatory for non-interactive setup!
116         export CITADEL_INSTALLER="yes"
117
118         # Citadel location.
119         export CITADEL="/var/run/citadel/"
120
121         if use ldap ; then
122                 export SLAPD_Binary="/usr/$(get_libdir)/openldap/slapd"
123                 export LDAP_CONFIG="/etc/openldap/sldap.conf"
124         fi
125
126         # Don't create any inittab/initscript/xinet stuff entry.
127         # We'll provide our own init script
128         export CREATE_INITTAB_ENTRY="no"
129         export CREATE_XINETD_ENTRY="no"
130         export NO_INIT_SCRIPTS="yes"
131         export ACT_AS_MTA="no" #just prohibits setup to mess with init scripts
132
133         einfo "On which ip should the server listen?"
134         einfo "Press enter to default to 0.0.0.0 and listen on all interfaces."
135         read -rp "   >" ipadress ; echo
136         if  [ -z "$ipadress" ] ; then
137                 export IP_ADDR="0.0.0.0"
138         else
139                 export IP_ADDR="$ipadress"
140         fi
141
142         # The main admin name for citadel can be chosen at random
143         einfo "Insert a name for your citadel admin account:"
144         read -rp "   >" sysadminname ; echo
145         export SYSADMIN_NAME="$sysadminname"
146
147         local pwd1="misch"
148         local pwd2="masch"
149
150         until [[ "x$pwd1" = "x$pwd2" ]] ; do
151                 einfo "Insert a password for the citadel admin user"
152                 einfo "Avoid [\"'\\_%] characters in the password"
153                 read -rsp "   >" pwd1 ; echo
154
155                 einfo "Retype the password"
156                 read -rsp "   >" pwd2 ; echo
157
158                 if [[ "x$pwd1" != "x$pwd2" ]] ; then
159                         ewarn "Passwords are not the same"
160                 fi
161         done
162         export SYSADMIN_PW="$pwd2"
163
164         #Now we will create the config using defaults and enviromental variables.
165         /usr/$(get_libdir)/citadel/setup -q
166         unset SYSADMIN_PW
167
168         #Verify the /etc/services entry was made
169         if [ -f /etc/services ] && ! grep -q '^citadel' /etc/services ; then
170                 echo "citadel           504/tcp         # citadel" >> /etc/services
171         fi
172
173         einfo "Be sure to read the documentation in /usr/share/doc/${PF}"
174         einfo
175         einfo "The server should now be up and running, enjoy!"
176         einfo "Citadel will listen on its default port 504"
177         if use postfix ; then
178                 elog
179                 elog "Citadel listens on port 25 by default, even with postfix useflag!"
180                 elog "Right now this can only be disabled in WebCit or with the cli client."
181                 elog "There is no elegant way to disable that atm, will be fixed upstream."
182                 elog "Sorry for this inconvenience!"
183         fi
184 }