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