1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils multilib
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"
14 KEYWORDS="~amd64 ~x86"
15 IUSE="ldap mailwrapper pam pic ssl threads"
17 DEPEND="=dev-libs/libcitadel-7.81
18 >=sys-libs/db-4.1.25_p1
20 ldap? ( >=net-nds/openldap-2.0.27 )
22 ssl? ( >=dev-libs/openssl-0.9.6 )"
25 !mailwrapper? ( !virtual/mta !net-mail/mailwrapper )
26 mailwrapper? ( >=net-mail/mailwrapper-0.2 )"
32 MESSAGEBASE="/var/lib/citadel"
35 #Homedir needs to be the same as --with-datadir
36 einfo "Adding Citadel User/Group"
38 enewuser citadel -1 -1 ${MESSAGEBASE} citadel,mail
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 \
54 $(use_enable pic pie) \
56 $(use_with ssl openssl) \
63 dodir /etc/pam.d || die "Creating /etc/pam.d failed in sandbox"
66 emake DESTDIR="${D}" install-new || die "make install failed"
68 # Protect ${MESSAGEBASE}
69 echo CONFIG_PROTECT="${MESSAGEBASE}" > "${T}"/10citadel
70 doenvd "${T}"/10citadel || die "Config-protecting failed"
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
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"
83 if use mailwrapper ; then
85 doins "${FILESDIR}"/mailer.conf || die "Installing mailer.conf failed"
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"
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"
97 newinitd "${FILESDIR}"/citadel.init citadel || die "Inserting initscript failed"
98 newconfd "${FILESDIR}"/citadel.confd citadel || die "Inserting conf for initscript failed"
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 einfo "The administration tools have been placed in /usr/$(get_libdir)/citadel"
107 einfo "There are two possible options to get Citadel running, if this is"
108 einfo "a new install:"
110 einfo "1. The no-nonse fullspeed approach with most stuff done for you:"
111 einfo "# emerge --config =${CATEGORY}/${PF}"
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"
118 einfo "The second approach is only recommended to experienced users!!!"
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"
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"
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!"
133 #Citadel's setup uses a few enviromental variables to control it.
134 # Mandatory for non-interactive setup!
135 export CITADEL_INSTALLER="yes"
138 export CITADEL="/var/run/citadel/"
141 export SLAPD_Binary="/usr/$(get_libdir)/openldap/slapd"
142 export LDAP_CONFIG="/etc/openldap/sldap.conf"
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
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"
158 export IP_ADDR="$ipadress"
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"
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
174 einfo "Retype the password"
175 read -rsp " >" pwd2 ; echo
177 if [[ "x$pwd1" != "x$pwd2" ]] ; then
178 ewarn "Passwords are not the same"
181 export SYSADMIN_PW="$pwd2"
183 #Now we will create the config using defaults and enviromental variables.
184 /usr/$(get_libdir)/citadel/setup -q
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
192 einfo "Be sure to read the documentation in /usr/share/doc/${PF}"
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
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!"