From 8808f617271cdbc003775a850904829addd36994 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Mon, 1 Sep 2014 16:02:39 -0300 Subject: [PATCH] Chat package --- INSTALL.chat.md | 30 ++++++++++++++++++------------ debian/apache2/conf.d/noosfero-chat | 9 +++++++++ debian/changelog | 8 ++++++-- debian/control | 11 +++++++++++ debian/default/noosfero-chat | 2 ++ debian/noosfero-chat.install | 6 ++++++ debian/noosfero-chat.postinst | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ debian/noosfero-runner | 8 ++++++++ debian/noosfero.install | 1 + debian/update-noosfero-odbc | 14 ++++++++++++++ etc/pam.d/noosfero-chat | 1 + etc/security/limits.d/noosfero-chat.conf | 2 ++ script/apacheconf | 1 + script/noosfero-test-chat-session | 28 ++++++++++++++++++++++++++++ script/odbcconf | 22 ++++++++++++++++++++++ util/chat/apache/xmpp.conf | 1 + 16 files changed, 180 insertions(+), 14 deletions(-) create mode 100644 debian/apache2/conf.d/noosfero-chat create mode 100644 debian/default/noosfero-chat create mode 100644 debian/noosfero-chat.install create mode 100644 debian/noosfero-chat.postinst create mode 100755 debian/noosfero-runner create mode 100755 debian/update-noosfero-odbc create mode 100644 etc/pam.d/noosfero-chat create mode 100644 etc/security/limits.d/noosfero-chat.conf create mode 100755 script/noosfero-test-chat-session create mode 100755 script/odbcconf diff --git a/INSTALL.chat.md b/INSTALL.chat.md index cb40e66..64f8c23 100644 --- a/INSTALL.chat.md +++ b/INSTALL.chat.md @@ -1,5 +1,18 @@ -XMPP/Chat Setup -=============== +Automatic XMPP/Chat Setup +========================= + +Since Noosfero 1.2, the XMPP/Chat can be installed via `noosfero-chat` Debian +package. So you don't need to follow the manual instructions here if you +already have it installed on your system. + +But if you are going to install the `noosfero-chat` package on a system that +already has `noosfero` older 1.2 installed then you need to check if apache's +configuration file `/etc/apache2/sites-available/noosfero` has this line below: + + Include /usr/share/noosfero/util/chat/apache/xmpp.conf + +Manual XMPP/Chat Setup +====================== The samples of config file to configure a XMPP/BOSH server with ejabberd, postgresql and apache2 can be found at util/chat directory. @@ -8,7 +21,7 @@ This setup supposes that you are using Noosfero installed via Debian package in a production environment. Steps -===== +----- This is a step-by-step guide to get a XMPP service working, in a Debian system. @@ -144,15 +157,8 @@ You should see a page with a message like that: ## 9. Test chat session -Open Noosfero console and execute: - ->> environment = Environment.default ->> user = Person['guest'] ->> password = user.user.crypted_password ->> login = user.jid ->> RubyBOSH.initialize_session(login, password, "http://#{environment.default_hostname}/http-bind", :wait => 30, :hold => 1, :window => 5 - -If you have luck, should see something like that: +Run `./script/noosfero-test-chat-session`. If you have luck, should see +something like that: Ruby-BOSH - SEND diff --git a/debian/apache2/conf.d/noosfero-chat b/debian/apache2/conf.d/noosfero-chat new file mode 100644 index 0000000..c01061f --- /dev/null +++ b/debian/apache2/conf.d/noosfero-chat @@ -0,0 +1,9 @@ + + StartServers 8 + MinSpareThreads 25 + MaxSpareThreads 75 + ThreadLimit 128 + ThreadsPerChild 128 + MaxClients 2048 + MaxRequestsPerChild 0 + diff --git a/debian/changelog b/debian/changelog index 36d8805..df2a0fd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,12 @@ -noosfero (1.2~0) UNRELEASED; urgency=medium +noosfero (1.2~1) UNRELEASED; urgency=medium + [ Antonio Terceiro ] * Temporary version in heavy development - -- Antonio Terceiro Fri, 08 May 2015 16:08:18 -0300 + [ Joenio Costa ] + * Build noosfero-chat package + + -- Joenio Costa Mon, 18 May 2015 14:32:21 -0300 noosfero (1.1) wheezy; urgency=low diff --git a/debian/control b/debian/control index 13ebd60..dd098bf 100644 --- a/debian/control +++ b/debian/control @@ -85,3 +85,14 @@ Description: free web-based platform for social networks (apache frontend) . This package contains the configuration files needed to run Noosfero with the Apache HTTPD server as frontend. + +Package: noosfero-chat +Architecture: all +Depends: noosfero (>= 1.2), ejabberd, odbc-postgresql, pidgin-data +Description: free web-based platform for social networks (ejabberd based chat) + Noosfero is a web platform for social and solidarity economy networks with + blog, e-Porfolios, CMS, RSS, thematic discussion, events agenda and collective + inteligence for solidarity economy in the same system. + . + This package contains the configuration files needed to run Noosfero with the + Ejabberd XMPP chat server. diff --git a/debian/default/noosfero-chat b/debian/default/noosfero-chat new file mode 100644 index 0000000..85eac35 --- /dev/null +++ b/debian/default/noosfero-chat @@ -0,0 +1,2 @@ +POLL=true +SMP=auto diff --git a/debian/noosfero-chat.install b/debian/noosfero-chat.install new file mode 100644 index 0000000..2f04fcd --- /dev/null +++ b/debian/noosfero-chat.install @@ -0,0 +1,6 @@ +debian/default/noosfero-chat etc/default +util/chat/ejabberd.cfg etc/ejabberd +debian/update-noosfero-odbc usr/sbin +etc/security/limits.d/noosfero-chat.conf etc/security/limits.d +etc/pam.d/noosfero-chat etc/pam.d +debian/apache2/conf.d/noosfero-chat etc/apache2/conf.d diff --git a/debian/noosfero-chat.postinst b/debian/noosfero-chat.postinst new file mode 100644 index 0000000..38887da --- /dev/null +++ b/debian/noosfero-chat.postinst @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e + +. /usr/share/debconf/confmodule + +echo -n "Fetching noosfero domain ..." +domain=$(noosfero-runner 'puts Environment.default.default_hostname(true)') +echo " [domain = $domain]" + +ejabberd_config='/etc/ejabberd/ejabberd.cfg' +if test -f $ejabberd_config; then + sed -i "s/acl, *\([^,]*\), *{user, *\([^,]*\), *[^}]*/acl, \1, {user, \2, \"$domain\"/" /etc/ejabberd/ejabberd.cfg + sed -i "s/hosts, *\[[^]]*/hosts, [\"$domain\"/" /etc/ejabberd/ejabberd.cfg +fi + +echo -n 'Fetching noosfero database name ...' +noosfero_database=$(noosfero-runner 'puts Environment.connection_config[:database]') +echo " [database = $noosfero_database]" + +echo 'Creating ejabberd schema ...' +. /etc/default/noosfero +noosfero_user="$NOOSFERO_USER" +su - postgres -c "psql -c 'GRANT CREATE ON DATABASE $noosfero_database TO $noosfero_user;' > /dev/null" +su - $noosfero_user -c 'rails dbconsole production < /usr/share/noosfero/util/chat/postgresql/ejabberd.sql > /dev/null' + +if which update-noosfero-odbc > /dev/null ; then + update-noosfero-odbc +fi + +ejabberd_default='/etc/default/ejabberd' +noosfero_chat_default='/etc/default/noosfero-chat' +if test -f $ejabberd_default; then + if ! cat $ejabberd_default | grep "^\. $noosfero_chat_default" > /dev/null ; then + echo 'Extending ejabberd defaults with noosfero-chat defaults ...' + echo ". $noosfero_chat_default" >> $ejabberd_default + fi +fi + +a2enmod proxy_http + +invoke-rc.d ejabberd restart +invoke-rc.d noosfero restart +invoke-rc.d apache2 restart + +# stop debconf to avoid the problem with infinite hanging, cfe +# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=295477 +db_stop + +#DEBHELPER# diff --git a/debian/noosfero-runner b/debian/noosfero-runner new file mode 100755 index 0000000..7ae200f --- /dev/null +++ b/debian/noosfero-runner @@ -0,0 +1,8 @@ +#!/bin/sh + +set -e + +environment="$2" +test -z "$environment" && environment=production + +su - noosfero -c "rails runner -e $environment '$1'" diff --git a/debian/noosfero.install b/debian/noosfero.install index 2f9b7fc..0eef3ee 100644 --- a/debian/noosfero.install +++ b/debian/noosfero.install @@ -17,6 +17,7 @@ debian/dbupgrade usr/lib/noosfero debian/default/noosfero etc/default debian/noosfero-check-dbconfig usr/sbin debian/noosfero-console usr/sbin +debian/noosfero-runner usr/sbin debian/noosfero.yml etc/noosfero debian/thin.yml etc/noosfero doc usr/share/noosfero diff --git a/debian/update-noosfero-odbc b/debian/update-noosfero-odbc new file mode 100755 index 0000000..55bf41e --- /dev/null +++ b/debian/update-noosfero-odbc @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +# automatically update configuration, but if package noosfero is also installed +if test -x /usr/share/noosfero/script/odbcconf; then + config_file="/etc/odbc.ini" + if test -e "$config_file"; then + echo "Overwriting $config_file ..." + fi + /usr/share/noosfero/script/odbcconf > "$config_file" + + echo 'Noosfero ODBC configuration updated.' +fi diff --git a/etc/pam.d/noosfero-chat b/etc/pam.d/noosfero-chat new file mode 100644 index 0000000..fa644d2 --- /dev/null +++ b/etc/pam.d/noosfero-chat @@ -0,0 +1 @@ +session required pam_limits.so diff --git a/etc/security/limits.d/noosfero-chat.conf b/etc/security/limits.d/noosfero-chat.conf new file mode 100644 index 0000000..d12d107 --- /dev/null +++ b/etc/security/limits.d/noosfero-chat.conf @@ -0,0 +1,2 @@ +ejabberd hard nofile 65536 +ejabberd soft nofile 65536 diff --git a/script/apacheconf b/script/apacheconf index f660879..589c2b8 100755 --- a/script/apacheconf +++ b/script/apacheconf @@ -32,6 +32,7 @@ when 'virtualhosts' puts " #{server_directive} #{domain.name}" server_directive = 'ServerAlias' end + puts " Include /usr/share/noosfero/util/chat/apache/xmpp.conf" puts " Include /etc/noosfero/apache/virtualhost.conf" puts "" end diff --git a/script/noosfero-test-chat-session b/script/noosfero-test-chat-session new file mode 100755 index 0000000..0d52b20 --- /dev/null +++ b/script/noosfero-test-chat-session @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby +require File.dirname(__FILE__) + '/../config/environment' + +environment = Environment.default +person = Person.first +password = person.user.crypted_password +login = person.jid + +begin + RubyBOSH.initialize_session( + login, + password, + "http://#{environment.default_hostname}/http-bind", + :wait => 30, + :hold => 1, + :window => 5 + ) +rescue Exception => e + puts "" + puts "[ERROR] XMPP/Chat setup isn't working" + puts "-------------------------------------" + puts e.to_s + exit 1 +else + puts "" + puts "[OK] XMPP/Chat setup is working" + exit 0 +end diff --git a/script/odbcconf b/script/odbcconf new file mode 100755 index 0000000..323437d --- /dev/null +++ b/script/odbcconf @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +require 'yaml' +config = YAML.load_file(File.dirname(__FILE__) + '/../config/database.yml')['production'] + + +puts "[PostgreSQLEjabberdNoosfero]" +puts "Description = PostgreSQL Noosfero ejabberd database" +puts "Driver = PostgreSQL Unicode" +puts "Trace = No" +puts "TraceFile = /tmp/psqlodbc.log" +puts "Database = #{config['database']}" +puts "Servername = #{config['host'] || 'localhost'}" +puts "UserName = #{config['username']}" +puts "Password = #{config['password']}" +puts "Port = #{config['port'] || '5432'}" +puts "ReadOnly = No" +puts "RowVersioning = No" +puts "ShowSystemTables = No" +puts "ShowOidColumn = No" +puts "FakeOidIndex = No" +puts "ConnSettings = SET search_path TO ejabberd" diff --git a/util/chat/apache/xmpp.conf b/util/chat/apache/xmpp.conf index 4305ada..0926367 100644 --- a/util/chat/apache/xmpp.conf +++ b/util/chat/apache/xmpp.conf @@ -1,6 +1,7 @@ # If your XMPP XMPP/BOSH isn't in localhost, change the config below to correct # point to address + RewriteEngine On RewriteRule /http-bind http://localhost:5280/http-bind [P,QSA,L] Order Allow,Deny -- libgit2 0.21.2