1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
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"
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
19 DEPEND="=dev-libs/libcitadel-${PV}
22 ldap? ( net-nds/openldap )
24 ssl? ( dev-libs/openssl )"
27 postfix? ( mail-mta/postfix )"
29 MESSAGEBASE="/var/lib/citadel"
32 #Homedir needs to be the same as --with-datadir
33 einfo "Adding Citadel User/Group"
35 enewuser citadel -1 -1 ${MESSAGEBASE} citadel,mail
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 \
53 $(use_enable pic pie) \
54 $(use_with ldap with-ldap) \
63 emake DESTDIR="${D}" install-new
65 # Protect files created at runtime by the server
66 echo CONFIG_PROTECT="${MESSAGEBASE}" > "${T}"/10citadel
67 doenvd "${T}"/10citadel
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
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"
80 if ! use postfix ; then
81 dosym /usr/sbin/citmail /usr/sbin/sendmail
82 dosym /usr/sbin/citmail /usr/$(get_libdir)/sendmail
86 insinto /etc/openldap/schema
87 doins openldap/citadel.schema
88 doins openldap/rfc2739.schema
91 newinitd "${FILESDIR}"/citadel.init citadel
92 newconfd "${FILESDIR}"/citadel.confd citadel
94 dodoc "${FILESDIR}"/README.gentoo
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"
101 elog "The administration tools have been placed in /usr/$(get_libdir)/citadel"
103 elog "If this is your first install, run the following for a quick setup:"
104 elog "# emerge --config =${CATEGORY}/${PF}"
106 elog "For further information check /usr/share/doc/${PF}/README.gentoo"
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!"
114 #Citadel's setup uses a few enviromental variables to control it.
115 # Mandatory for non-interactive setup!
116 export CITADEL_INSTALLER="yes"
119 export CITADEL="/var/run/citadel/"
122 export SLAPD_Binary="/usr/$(get_libdir)/openldap/slapd"
123 export LDAP_CONFIG="/etc/openldap/sldap.conf"
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
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"
139 export IP_ADDR="$ipadress"
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"
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
155 einfo "Retype the password"
156 read -rsp " >" pwd2 ; echo
158 if [[ "x$pwd1" != "x$pwd2" ]] ; then
159 ewarn "Passwords are not the same"
162 export SYSADMIN_PW="$pwd2"
164 #Now we will create the config using defaults and enviromental variables.
165 /usr/$(get_libdir)/citadel/setup -q
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
173 einfo "Be sure to read the documentation in /usr/share/doc/${PF}"
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
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!"