]> Pileus Git - ~andy/sunrise/blob - mail-mta/citadel/citadel-7.82.ebuild
dev-python/python-gudev: Version bump
[~andy/sunrise] / mail-mta / citadel / citadel-7.82.ebuild
1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="2"
6 inherit eutils multilib
7
8 DESCRIPTION="Groupware/Email/Jabberserver. Collaboration, Calender, BBS/Forum, Chat with easy install and usage"
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 mailwrapper pam pic ssl threads"
16
17 DEPEND="=dev-libs/libcitadel-7.81
18         >=sys-libs/db-4.1.25_p1
19         virtual/libiconv
20         ldap? ( >=net-nds/openldap-2.0.27 )
21         pam? ( sys-libs/pam )
22         ssl? ( >=dev-libs/openssl-0.9.6 )"
23 RDEPEND="${DEPEND}
24         net-mail/mailbase
25         !mailwrapper? ( !virtual/mta !net-mail/mailwrapper )
26         mailwrapper? ( >=net-mail/mailwrapper-0.2 )"
27
28 PROVIDE="virtual/mta
29         virtual/mda
30         virtual/imapd"
31
32 MESSAGEBASE="/var/lib/citadel"
33
34 pkg_setup() {
35         #Homedir needs to be the same as --with-datadir
36         einfo "Adding Citadel User/Group"
37         enewgroup citadel
38         enewuser citadel -1 -1 ${MESSAGEBASE} citadel,mail
39 }
40
41 src_configure() {
42         econf \
43                 --with-rundir=/var/run/citadel \
44                 --with-datadir=/var/lib/citadel \
45                 --with-spooldir=/var/spool/citadel \
46                 --with-autosysconfdir=/var/lib/citadel/data \
47                 --with-staticdatadir=/etc/citadel \
48                 --with-sysconfdir=/etc/citadel \
49                 --with-ssldir=/etc/ssl/citadel \
50                 --with-helpdir=/usr/share/citadel-server \
51                 --with-docdir=/usr/share/doc/${PF} \
52                 --with-utility-bindir=/usr/$(get_libdir)/citadel \
53                 --without-libdspam \
54                 $(use_enable pic pie) \
55                 $(use_with pam) \
56                 $(use_with ssl openssl) \
57                 $(use_with ldap) \
58                 --with-db
59 }
60
61 src_install() {
62         if use pam ; then
63                  dodir /etc/pam.d || die "Creating /etc/pam.d failed in sandbox"
64         fi
65
66         emake DESTDIR="${D}" install-new || die "make install failed"
67
68         # Protect ${MESSAGEBASE}
69         echo CONFIG_PROTECT="${MESSAGEBASE}" > "${T}"/10citadel
70         doenvd "${T}"/10citadel || die "Config-protecting failed"
71
72         # Keep emerge from removing empty directories when updating
73         keepdir "${MESSAGEBASE}"/data
74         keepdir /var/spool/citadel/network/{systems,spoolout,spoolin}
75         keepdir /var/run/citadel/network/{systems,spoolout,spoolin}
76         keepdir /etc/citadel/messages
77
78         #Fix some permissions and sendmail stuff
79         fowners citadel:citadel /etc/citadel /var/lib/citadel || die "Changing owner failed"
80         fowners root:citadel /usr/sbin/citmail || die "Changing owner failed"
81         rm "${D}"/usr/sbin/sendmail || die "Removinf sendmail bin failed"
82
83         if use mailwrapper ; then
84                 insinto /etc/mail
85                 doins "${FILESDIR}"/mailer.conf || die "Installing mailer.conf failed"
86         else
87                 dosym /usr/sbin/citmail /usr/sbin/sendmail || die "Linking sendmail to citmail failed"
88                 dosym /usr/sbin/citmail /usr/$(get_libdir)/sendmail || die "Compatibility sendmail link failed"
89         fi
90
91         if use ldap ; then
92                 insinto /etc/openldap/schema
93                 doins openldap/citadel.schema || die "Inserting LDAP schema failed"
94                 doins openldap/rfc2739.schema || die "Inserting LDAP schema failed"
95         fi
96
97         newinitd "${FILESDIR}"/citadel.init citadel || die "Inserting initscript failed"
98         newconfd "${FILESDIR}"/citadel.confd citadel || die  "Inserting conf for initscript failed"
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         einfo "The administration tools have been placed in /usr/$(get_libdir)/citadel"
106         einfo
107         einfo "There are two possible options to get Citadel running, if this is"
108         einfo "a new install:"
109         einfo
110         einfo "1. The no-nonse fullspeed approach with most stuff done for you:"
111         einfo "# emerge --config =${CATEGORY}/${PF}"
112         einfo
113         einfo "2. Manually configuring it with its setup routine:"
114         einfo "You should make yourself familiar with Citadels setup:"
115         einfo "http://www.citadel.org/doku.php/documentation:cmdman:setup"
116         einfo "You probalby do not want to let setup chose the mode of starting"
117         einfo
118         einfo "The second approach is only recommended to experienced users!!!"
119         einfo
120         einfo "The service will automatically start after you configured it."
121         einfo "Initscript is /etc/init.d/citadel. Also look into /etc/conf.d"
122         einfo
123         einfo "The following clients are available:"
124         einfo "a) the citadel console client was installed with this ebuild"
125         einfo "b) www-servers/webcit provides a web-based gui"
126 }
127
128 pkg_config() {
129         #we have to stop the server if it is accidently running
130         [ -f /var/run/citadel/citadel.socket ] && \
131                 die "Citadel seems to be running, please stop it while configuring!"
132
133         #Citadel's setup uses a few enviromental variables to control it.
134         # Mandatory for non-interactive setup!
135         export CITADEL_INSTALLER="yes"
136
137         # Citadel location.
138         export CITADEL="/var/run/citadel/"
139
140         if use ldap ; then
141                 export SLAPD_Binary="/usr/$(get_libdir)/openldap/slapd"
142                 export LDAP_CONFIG="/etc/openldap/sldap.conf"
143         fi
144
145         # Don't create any inittab/initscript/xinet stuff entry.
146         # We'll provide our own init script
147         export CREATE_INITTAB_ENTRY="no"
148         export CREATE_XINETD_ENTRY="no"
149         export NO_INIT_SCRIPTS="yes"
150         export ACT_AS_MTA="no" #just prohibits setup to mess with init scripts
151
152         einfo "On which ip should the server listen?"
153         einfo "Press enter to default to 0.0.0.0 and listen on all interfaces."
154         read -rp "   >" ipadress ; echo
155         if  [ -z "$ipadress" ] ; then
156                 export IP_ADDR="0.0.0.0"
157         else
158                 export IP_ADDR="$ipadress"
159         fi
160
161         # The main admin name for citadel can be chosen at random
162         einfo "Insert a name for your citadel admin account:"
163         read -rp "   >" sysadminname ; echo
164         export SYSADMIN_NAME="$sysadminname"
165
166         local pwd1="misch"
167         local pwd2="masch"
168
169         until [[ "x$pwd1" = "x$pwd2" ]] ; do
170                 einfo "Insert a password for the citadel admin user"
171                 einfo "Avoid [\"'\\_%] characters in the password"
172                 read -rsp "   >" pwd1 ; echo
173
174                 einfo "Retype the password"
175                 read -rsp "   >" pwd2 ; echo
176
177                 if [[ "x$pwd1" != "x$pwd2" ]] ; then
178                         ewarn "Passwords are not the same"
179                 fi
180         done
181         export SYSADMIN_PW="$pwd2"
182
183         #Now we will create the config using defaults and enviromental variables.
184         /usr/$(get_libdir)/citadel/setup -q
185         unset SYSADMIN_PW
186
187         #Verify the /etc/services entry was made
188         if [ -f /etc/services ] && ! grep -q '^citadel' /etc/services ; then
189                 echo "citadel           504/tcp         # citadel" >> /etc/services
190         fi
191
192         einfo "Be sure to read the documentation in /usr/share/doc/${PF}"
193         einfo
194         einfo "The server should now be up and running, enjoy!"
195         einfo "Citadel will listen on its default port 504"
196         if use mailwrapper; then
197                 einfo
198                 einfo "Citadel listens on port 25 by default, even with mailwrapper useflag!"
199                 einfo "Right now this can only be disabled in WebCit or with the cli client."
200                 einfo "There is no elegant way to disable that atm, will be fixed upstream."
201                 einfo "Sorry for this inconvenience!"
202         fi
203 }