initial commit for ejabberd
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Mon, 15 Mar 2010 12:12:13 +0000 (12:12 +0000)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Mon, 15 Mar 2010 12:12:13 +0000 (12:12 +0000)
Makefile [new file with mode: 0644]
ejabberd.init [new file with mode: 0644]
ejabberd.logrotate [new file with mode: 0644]
ejabberd.pam [new file with mode: 0644]
ejabberd.spec [new file with mode: 0644]
ejabberd.sysconfig [new file with mode: 0644]
ejabberdctl.apps [new file with mode: 0644]
ejabberdctl.pam [new file with mode: 0644]

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..f74890f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,62 @@
+# $Id$
+# $URL$
+#
+WEBFETCH               := wget
+SHA1SUM                        := sha1sum
+
+ALL                    += pyaspects
+ejabberd-URL           := http://www.process-one.net/downloads/ejabberd/2.1.3/ejabberd-2.1.3.tar.gz
+ejabberd-SHA1SUM       := 77fdf18c0bb3b25cf9045e0c833ba4d82f180469
+ejabberd               := $(notdir $(ejabberd-URL))
+
+all: $(ALL)
+.PHONY: all
+
+##############################
+define download_target
+$(1): $($(1))
+.PHONY: $($(1))
+$($(1)): 
+       @if [ ! -e "$($(1))" ] ; then echo "$(WEBFETCH) $($(1)-URL)" ; $(WEBFETCH) $($(1)-URL) ; fi
+       @if [ ! -e "$($(1))" ] ; then echo "Could not download source file: $($(1)) does not exist" ; exit 1 ; fi
+       @if test "$$$$($(SHA1SUM) $($(1)) | awk '{print $$$$1}')" != "$($(1)-SHA1SUM)" ; then \
+           echo "sha1sum of the downloaded $($(1)) does not match the one from 'Makefile'" ; \
+           echo "Local copy: $$$$($(SHA1SUM) $($(1)))" ; \
+           echo "In Makefile: $($(1)-SHA1SUM)" ; \
+           false ; \
+       else \
+           ls -l $($(1)) ; \
+       fi
+endef
+
+$(eval $(call download_target,ejabberd))
+
+sources: $(ALL)
+.PHONY: sources
+
+####################
+# default - overridden by the build
+SPECFILE = ejabberd.spec
+
+PWD=$(shell pwd)
+PREPARCH ?= noarch
+RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)"
+trees: sources
+       rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
+
+srpm: sources
+       rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps -bs $(SPECFILE)
+
+TARGET ?= $(shell uname -m)
+rpm: sources
+       rpmbuild $(RPMDIRDEFS) $(RPMDEFS) --nodeps --target $(TARGET) -bb $(SPECFILE)
+
+clean:
+       rm -f *.rpm *.tgz *.bz2 *.gz
+
+++%: varname=$(subst +,,$@)
+++%:
+       @echo "$(varname)=$($(varname))"
++%: varname=$(subst +,,$@)
++%:
+       @echo "$($(varname))"
diff --git a/ejabberd.init b/ejabberd.init
new file mode 100644 (file)
index 0000000..61edaff
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# ejabberd    Start and stop ejabberd.
+
+# chkconfig: - 40 60
+# description: ejabberd
+# processname: ejabberd
+# pidfile: /var/run/ejabberd.pid
+
+### BEGIN INIT INFO
+# Provides: ejabberd
+# Required-Start: network
+# Required-Stop: network
+# Short-Description: Start and stop ejabberd
+# Description: A distributed, fault-tolerant Jabber/XMPP server
+### END INIT INFO
+
+. /etc/rc.d/init.d/functions
+
+if [ -r /etc/sysconfig/ejabberd ]; then
+       . /etc/sysconfig/ejabberd
+fi
+
+if [ ! "$CONFIG_FILE" ]; then
+       CONFIG_FILE=/etc/ejabberd/ejabberd.cfg
+fi
+
+start() {
+        echo -n $"Starting ejabberd: "
+       if [ "$ULIMIT_MAX_FILES" ]; then
+               ulimit -n $ULIMIT_MAX_FILES
+       fi
+       daemon /usr/sbin/ejabberdctl start
+                               --config $CONFIG_FILE \
+                               --ctl-config /etc/ejabberd/ejabberdctl.cfg \
+                               --logs "/var/log/ejabberd" \
+                               --spool "/var/lib/ejabberd/spool" \
+                               2>/dev/null
+        RETVAL=$?
+        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ejabberd
+        echo
+        return $RETVAL
+}
+
+stop() {
+        # Stop daemons.
+        echo -n "Shutting down ejabberd: "
+       daemon /usr/sbin/ejabberdctl stop 2>/dev/null
+        RETVAL=$?
+        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ejabberd
+        echo
+        return $RETVAL
+}
+
+restart() {
+        stop
+       sleep 5
+        start
+}
+
+# See how we were called.
+case "$1" in
+  start)
+        start
+        ;;
+  stop)
+        stop
+        ;;
+  restart)
+        restart
+        ;;
+  force-reload)
+       restart
+       ;;
+  condrestart)
+        [ -f /var/lock/subsys/ejabberd ] && restart || :
+        ;;
+  try-restart)
+        [ -f /var/lock/subsys/ejabberd ] && restart || :
+        ;;
+  status)
+       /usr/sbin/ejabberdctl status
+        ;;
+  *)
+        echo "Usage: ejabberd {start|stop|restart|force-reload|condrestart|try-restart|status}"
+        exit 1
+esac
+
+exit $?
+
+
diff --git a/ejabberd.logrotate b/ejabberd.logrotate
new file mode 100644 (file)
index 0000000..9fff8e1
--- /dev/null
@@ -0,0 +1,9 @@
+/var/log/ejabberd/ejabberd.log /var/log/ejabberd/sasl.log {
+    missingok
+    notifempty
+    create 0640 ejabberd ejabberd
+    sharedscripts
+    postrotate
+    runuser -s /bin/bash - ejabberd -c "/usr/sbin/ejabberdctl reopen-log" >/dev/null 2>/dev/null || true
+    endscript
+}
diff --git a/ejabberd.pam b/ejabberd.pam
new file mode 100644 (file)
index 0000000..2f9b69c
--- /dev/null
@@ -0,0 +1,4 @@
+#%PAM-1.0
+auth       include      system-auth
+account    include      system-auth
+
diff --git a/ejabberd.spec b/ejabberd.spec
new file mode 100644 (file)
index 0000000..42a18eb
--- /dev/null
@@ -0,0 +1,182 @@
+Name:           ejabberd
+Version:        2.1.3
+Release:        1%{?dist}
+Summary:        A distributed, fault-tolerant Jabber/XMPP server
+
+Group:          Applications/Internet
+License:        GPLv2+
+URL:            http://www.ejabberd.im/
+Source0:        http://www.process-one.net/downloads/%{name}/%{version}/%{name}-%{version}.tar.gz
+Source1:        ejabberd.init
+Source2:        ejabberd.logrotate
+Source3:        ejabberd.sysconfig
+
+# PAM support
+Source9:        ejabberdctl.pam
+Source10:       ejabberdctl.apps
+Source11:       ejabberd.pam
+
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildRequires:  expat-devel
+BuildRequires:  openssl-devel
+BuildRequires:  pam-devel
+BuildRequires:  erlang
+BuildRequires:  hevea
+
+Requires:       erlang
+Requires:       usermode
+
+Requires(pre): fedora-usermgmt
+Requires(post): /sbin/chkconfig
+Requires(post): /usr/bin/openssl
+Requires(preun): /sbin/chkconfig
+Requires(preun): /sbin/service
+Requires(postun): /sbin/service
+
+%description
+ejabberd is a Free and Open Source distributed fault-tolerant
+Jabber/XMPP server. It is mostly written in Erlang, and runs on many
+platforms (tested on Linux, FreeBSD, NetBSD, Solaris, Mac OS X and
+Windows NT/2000/XP).
+
+%package doc
+Summary: Documentation for ejabberd
+Group: Documentation
+
+%description doc
+Documentation for ejabberd.
+
+%pre
+/usr/sbin/fedora-groupadd 27 -r ejabberd &>/dev/null || :
+/usr/sbin/fedora-useradd  27 -r -s /sbin/nologin -d /var/lib/ejabberd -M \
+                             -c 'ejabberd' -g ejabberd ejabberd &>/dev/null || :
+
+%post
+/sbin/chkconfig --add ejabberd
+
+(cd /etc/ejabberd
+if [ ! -f ejabberd.pem ]
+then
+    echo "Generating SSL certificate /etc/ejabberd/ejabberd.pem..."
+    HOSTNAME=$(hostname -s 2>/dev/null || echo "localhost")
+    DOMAINNAME=$(hostname -d 2>/dev/null || echo "localdomain")
+    openssl req -new -x509 -days 365 -nodes -out ejabberd.pem \
+                -keyout ejabberd.pem > /dev/null 2>&1 <<+++
+.
+.
+.
+$DOMAINNAME
+$HOSTNAME
+ejabberd
+root@$HOSTNAME.$DOMAINNAME
++++
+chown ejabberd:ejabberd ejabberd.pem
+chmod 600 ejabberd.pem
+fi)
+
+%preun
+if [ $1 = 0 ]; then
+        /sbin/service ejabberd stop >/dev/null 2>&1
+        /sbin/chkconfig --del ejabberd
+fi
+
+%postun
+if [ "$1" -ge "1" ]; then
+        /sbin/service ejabberd condrestart >/dev/null 2>&1
+fi
+
+%prep
+%setup -q
+
+
+%build
+pushd src
+%configure --enable-odbc --enable-debug --enable-pam
+# doesn't builds on SMP currently
+make
+popd
+
+%install
+rm -rf %{buildroot}
+
+pushd src
+make install DESTDIR=%{buildroot}
+popd
+
+chmod a+x %{buildroot}%{_libdir}/%{name}/priv/lib/*.so
+
+%{__perl} -pi -e 's!./ssl.pem!/etc/ejabberd/ejabberd.pem!g' %{buildroot}/etc/ejabberd/ejabberd.cfg
+
+mkdir -p %{buildroot}/var/log/ejabberd
+mkdir -p %{buildroot}/var/lib/ejabberd/spool
+
+mkdir -p %{buildroot}%{_bindir}
+ln -s consolehelper %{buildroot}%{_bindir}/ejabberdctl
+install -D -p -m 0644 %{S:9} %{buildroot}%{_sysconfdir}/pam.d/ejabberdctl
+install -D -p -m 0644 %{S:10} %{buildroot}%{_sysconfdir}/security/console.apps/ejabberdctl
+install -D -p -m 0644 %{S:11} %{buildroot}%{_sysconfdir}/pam.d/ejabberd
+
+# install init-script
+install -D -p -m 0755 %{S:1} %{buildroot}%{_initrddir}/ejabberd
+
+# install config for logrotate
+install -D -p -m 0644  %{S:2} %{buildroot}%{_sysconfdir}/logrotate.d/ejabberd
+
+# install sysconfig file
+install -D -p -m 0644  %{S:3} %{buildroot}%{_sysconfdir}/sysconfig/ejabberd
+
+%{__perl} -pi -e 's!\@libdir\@!%{_libdir}!g'  %{buildroot}%{_initrddir}/ejabberd %{buildroot}%{_sysconfdir}/logrotate.d/ejabberd %{buildroot}%{_sbindir}/ejabberdctl
+%{__perl} -pi -e 's!\@version\@!%{version}!g' %{buildroot}%{_initrddir}/ejabberd %{buildroot}%{_sysconfdir}/logrotate.d/ejabberd %{buildroot}%{_sbindir}/ejabberdctl
+
+# BZ# 439583
+%{__perl} -pi -e 's!MAINDIR=!MAINDIR=%{_libdir}/ejabberd!g' %{buildroot}%{_sbindir}/ejabberdctl
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%doc COPYING src/odbc/mysql.sql src/odbc/pg.sql tools/captcha.sh
+
+%attr(750,ejabberd,ejabberd) %dir %{_sysconfdir}/ejabberd
+%attr(640,ejabberd,ejabberd) %config(noreplace) %{_sysconfdir}/ejabberd/ejabberd.cfg
+%attr(640,ejabberd,ejabberd) %config(noreplace) %{_sysconfdir}/ejabberd/ejabberdctl.cfg
+%attr(640,ejabberd,ejabberd) %config(noreplace) %{_sysconfdir}/ejabberd/inetrc
+
+%{_initrddir}/ejabberd
+%config(noreplace) %{_sysconfdir}/logrotate.d/ejabberd
+%config(noreplace) %{_sysconfdir}/sysconfig/ejabberd
+%config(noreplace) %{_sysconfdir}/pam.d/ejabberd
+%config(noreplace) %{_sysconfdir}/pam.d/ejabberdctl
+%config(noreplace) %{_sysconfdir}/security/console.apps/ejabberdctl
+%{_bindir}/ejabberdctl
+%{_sbindir}/ejabberdctl
+
+%dir %{_libdir}/%{name}
+%dir %{_libdir}/%{name}/include
+%dir %{_libdir}/%{name}/ebin
+%dir %{_libdir}/%{name}/priv
+%dir %{_libdir}/%{name}/priv/bin
+%attr(4750,root,ejabberd)    %{_libdir}/%{name}/priv/bin/epam
+%dir %{_libdir}/%{name}/priv/lib
+%dir %{_libdir}/%{name}/priv/msgs
+
+%{_libdir}/%{name}/include/*
+%{_libdir}/%{name}/ebin/*.app
+%{_libdir}/%{name}/ebin/*.beam
+%{_libdir}/%{name}/priv/lib/*.so
+%{_libdir}/%{name}/priv/msgs/*.msg
+%{_libdir}/%{name}/priv/bin/captcha.sh
+
+%attr(750,ejabberd,ejabberd) %dir /var/lib/ejabberd
+%attr(750,ejabberd,ejabberd) %dir /var/lib/ejabberd/spool
+%attr(750,ejabberd,ejabberd) %dir /var/log/ejabberd
+
+%files doc
+%defattr(-,root,root,-)
+/usr/share/doc
+
+%changelog
+* Mon Mar 16 2010 Baris Metin <tmetin@sophia.inria.fr>
+- first package from Fedora SRPM, for planetlab 
diff --git a/ejabberd.sysconfig b/ejabberd.sysconfig
new file mode 100644 (file)
index 0000000..fac25b1
--- /dev/null
@@ -0,0 +1,13 @@
+## Settings for ejabberd
+
+## Where should ejabberd find its configuration file?
+#
+#CONFIG_FILE=/etc/ejabberd/ejabberd.cfg
+
+## ULIMIT_MAX_FILES alters the number of files that ejabberd is
+## allowed to have open at once.  If it is unset the system default
+## (usually 1024) will be used.  ejabberd will want over twice as many
+## open files as it has active connections, so if you have a few
+## hundred or more users you will want to set this.
+#
+#ULIMIT_MAX_FILES=1024
diff --git a/ejabberdctl.apps b/ejabberdctl.apps
new file mode 100644 (file)
index 0000000..30eab2c
--- /dev/null
@@ -0,0 +1,5 @@
+USER=root
+PROGRAM=/usr/sbin/ejabberdctl
+SESSION=yes
+FALLBACK=no
+GUI=no
diff --git a/ejabberdctl.pam b/ejabberdctl.pam
new file mode 100644 (file)
index 0000000..1952d97
--- /dev/null
@@ -0,0 +1,4 @@
+#%PAM-1.0
+auth            include         config-util
+account         include         config-util
+session         include         config-util