1 # Copyright 1999-2013 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}
25 ldap? ( net-nds/openldap )
27 ssl? ( dev-libs/openssl )"
31 postfix? ( mail-mta/postfix )"
33 MESSAGEBASE="/var/lib/citadel"
36 #Homedir needs to be the same as --with-datadir
37 einfo "Adding Citadel User/Group"
39 enewuser citadel -1 -1 ${MESSAGEBASE} citadel,mail
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 \
57 $(use_enable pic pie) \
58 $(use_with ldap with-ldap) \
67 emake DESTDIR="${D}" install-new
69 # Protect files created at runtime by the server
70 echo CONFIG_PROTECT="${MESSAGEBASE}" > "${T}"/10citadel
71 doenvd "${T}"/10citadel
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
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"
84 if ! use postfix ; then
85 dosym /usr/sbin/citmail /usr/sbin/sendmail
86 dosym /usr/sbin/citmail /usr/$(get_libdir)/sendmail
90 insinto /etc/openldap/schema
91 doins openldap/citadel.schema
92 doins openldap/rfc2739.schema
95 newinitd "${FILESDIR}"/citadel.init citadel
96 newconfd "${FILESDIR}"/citadel.confd citadel
98 dodoc "${FILESDIR}"/README.gentoo
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"
105 elog "The administration tools have been placed in /usr/$(get_libdir)/citadel"
107 elog "If this is your first install, run the following for a quick setup:"
108 elog "# emerge --config =${CATEGORY}/${PF}"
110 elog "For further information check /usr/share/doc/${PF}/README.gentoo"
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!"
118 #Citadel's setup uses a few enviromental variables to control it.
119 # Mandatory for non-interactive setup!
120 export CITADEL_INSTALLER="yes"
123 export CITADEL="/var/run/citadel/"
126 export SLAPD_Binary="/usr/$(get_libdir)/openldap/slapd"
127 export LDAP_CONFIG="/etc/openldap/sldap.conf"
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
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"
143 export IP_ADDR="$ipadress"
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"
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
159 einfo "Retype the password"
160 read -rsp " >" pwd2 ; echo
162 if [[ "x$pwd1" != "x$pwd2" ]] ; then
163 ewarn "Passwords are not the same"
166 export SYSADMIN_PW="$pwd2"
168 #Now we will create the config using defaults and enviromental variables.
169 /usr/$(get_libdir)/citadel/setup -q
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
177 einfo "Be sure to read the documentation in /usr/share/doc/${PF}"
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
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!"