From c0f64df47d3448c2b2b3f4e097043a9a11ae283b Mon Sep 17 00:00:00 2001 From: Dominik Schulz Date: Sun, 19 Feb 2012 17:33:06 +0100 Subject: [PATCH] Restructure debian packaging. This commit restructures the debian packaging. First it splits off the modules from the djabberd package which allows installing all required libraries w/o getting another deamon (e.g. as build dependency for building other modules or custom jabberds). Second it adds the missing wiring to the djabberd to get an jabber server which is easy to set up. Including propper logging and an ssl certificate. --- debian/.gitignore | 4 ++ debian/control | 98 ++++++--------------------------- debian/djabberd.dirs | 1 + debian/djabberd.init.d | 85 ++++++++++++++++++++++++++++ debian/djabberd.install | 4 +- debian/djabberd.logrotate | 8 +++ debian/djabberd.postinst | 60 ++++++++++++++++++++ debian/djabberd.postrm | 27 +++++++++ debian/libdjabberd-perl.install | 1 + etc/djabberd.conf | 76 +++++++++++++++++++++++++ etc/log.conf | 9 +++ 11 files changed, 291 insertions(+), 82 deletions(-) create mode 100644 debian/djabberd.dirs create mode 100644 debian/djabberd.init.d create mode 100644 debian/djabberd.logrotate create mode 100644 debian/djabberd.postinst create mode 100644 debian/djabberd.postrm create mode 100644 debian/libdjabberd-perl.install create mode 100644 etc/djabberd.conf create mode 100644 etc/log.conf diff --git a/debian/.gitignore b/debian/.gitignore index 3fec32c..e39aff9 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1 +1,5 @@ tmp/ +djabberd/ +libdjabberd-perl/ +*.debhelper +*.substvars diff --git a/debian/control b/debian/control index baf710c..1fbb655 100644 --- a/debian/control +++ b/debian/control @@ -11,10 +11,8 @@ Package: djabberd Section: perl Priority: optional Architecture: all -Depends: ${perl:Depends}, liblog-log4perl-perl, libnet-dns-perl, libnet-ssleay-perl, libxml-sax-perl, libxml-libxml-perl, libdanga-socket-perl -Provides: libdjabberd-perl -Conflicts: libdjabberd-perl -Suggests: djabberd-doc, openssl +Depends: ${perl:Depends}, libdjabberd-perl +Suggests: djabberd-doc Description: Distributed Jabber server djabberd is a high-performance, scalable, extensible Jabber/XMPP server framework. While it comes with an example server, it's @@ -25,84 +23,22 @@ Description: Distributed Jabber server . Homepage: http://danga.com/djabberd/ -Package: libdjabberd-authen-htdigest-perl -Section: perl -Priority: optional -Architecture: all -Depends: djabberd -Suggests: apache2-utils | apache-common (<< 1.3.28.0.1-1) -Description: HTDigest Authentication module for DJabberd - This module provides htdigest-based authentication for DJabberd. - -Package: libdjabberd-authen-mysql-perl -Section: perl -Priority: optional -Architecture: all -Depends: djabberd, libdbi-perl, libdbd-mysql-perl -Description: MySQL Authentication module for DJabberd - This module allows DJabberd to authenticate through MySQL. - -Package: libdjabberd-authen-pam-perl -Section: perl -Priority: optional -Architecture: all -Depends: djabberd, libauthen-pam-perl -Description: PAM Authentication module for DJabberd - This module allows DJabberd to authenticate through PAM. - -Package: libdjabberd-bot-eliza-perl -Section: perl -Priority: optional -Architecture: all -Depends: djabberd, libchatbot-eliza-perl -Description: Eliza Chatbot module for DJabberd - This module allows DJabberd to use Chatbot::Eliza to confuse - users. - -Package: djabberd-livejournal -Section: perl -Priority: optional -Architecture: all -Depends: djabberd, libgearman-client-async-perl, libgearman-client-perl, libwww-perl -Description: LiveJournal module for DJabberd - This module allows DJabberd to talk to LiveJournal. - -Package: djabberd-misc -Section: perl -Priority: optional -Architecture: all -Depends: djabberd -Description: DJabberd miscellany - Provides DJabberd::RosterStorage::Dummy - -Package: djabberd-muc -Section: perl -Priority: optional -Architecture: all -Depends: djabberd -Description: DJabberd MUC - Provides MUC modules for DJabberd - -Package: djabberd-rosterstorage-sqlite +Package: libdjabberd-perl Section: perl Priority: optional Architecture: all -Depends: djabberd, libdbi-perl, libdbd-sqlite3-perl -Description: DJabberd RosterStorage using SQLite - Provides DJabberd RosterStorage using SQLite - -Package: libdjabberd-plugin-vcard-perl -Section: perl -Priority: optional -Architecture: all -Depends: djabberd -Description: DJabberd VCard plugins - Provides VCard plugins for DJabberd +Depends: ${perl:Depends}, liblog-log4perl-perl, libnet-dns-perl, libnet-ssleay-perl, libxml-sax-perl, libxml-libxml-perl, libdanga-socket-perl +Suggests: openssl +Description: Core Modules for DJabberd + djabberd is a high-performance, scalable, extensible Jabber/XMPP + server framework. While it comes with an example server, it's + really a set of classes for you to build your own Jabber server + without understanding Jabber. Instead of working with XML and + protocol-specific details, you subclass parts and work with sane + objects and data structures and let DJabberd do all the ugly work. + . + Homepage: http://danga.com/djabberd/ + . + This package contains the core libraries needed to build your + own jabber server. -Package: djabberd-webadmin -Section: perl -Priority: optional -Architecture: all -Depends: djabberd, libperlbal-perl -Description: DJabberd WebAdmin - Provides DJabberd::WebAdmin diff --git a/debian/djabberd.dirs b/debian/djabberd.dirs new file mode 100644 index 0000000..4dc8eed --- /dev/null +++ b/debian/djabberd.dirs @@ -0,0 +1 @@ +/etc/djabberd diff --git a/debian/djabberd.init.d b/debian/djabberd.init.d new file mode 100644 index 0000000..6795baa --- /dev/null +++ b/debian/djabberd.init.d @@ -0,0 +1,85 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: djabberd +# Required-Start: $local_fs $remote_fs +# Required-Stop: $local_fs $remote_fs +# Should-Start: $all +# Should-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start/stop djabberd +# Description: Start/stop djabberd +### END INIT INFO + +# Original Version from http://graveyard.martinjansen.com/2006/08/06/djabberd.html +# Modified by Dominik Schulz + +set -e + +test $DEBIAN_SCRIPT_DEBUG && set -v -x + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DESC="DJabberd" +NAME="djabberd" +CONFIG_DIR=/etc/djabberd +HOME_DIR=/var/lib/djabberd +DAEMON=/usr/bin/djabberd +PIDFILE=/var/run/djabberd/djabberd.pid +SCRIPTNAME=/etc/init.d/djabberd +OPTS="--conf=$CONFIG_DIR/djabberd.conf" + +test -x $DAEMON || exit 0 +text -d $CONFIG_DIR || exit 0 + +d_start() { + start-stop-daemon --start --quiet --pidfile $PIDFILE -m \ + -d $HOME_DIR \ + --chuid djabberd \ + --background \ + --exec $DAEMON -- $OPTS +} + +d_stop() { + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + -d $HOME_DIR \ + --name $NAME -- $OPTS +} + +d_reload() { + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --name $NAME --signal 1 +} + +case "$1" in + start) + echo -n "Starting $DESC: $NAME" + d_start + echo "." + ;; + stop) + echo -n "Stopping $DESC: $NAME" + d_stop + echo "." + ;; + reload) + echo -n "Reloading $DESC: $NAME" + d_reload + echo "." + ;; + restart|force-reload) + echo -n "Restarting $DESC: $NAME" + d_stop + sleep 1 + d_start + echo "." + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|reload|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 + +# vim: set ai sts=2 sw=2 tw=0: diff --git a/debian/djabberd.install b/debian/djabberd.install index 55c2cbb..c52c103 100644 --- a/debian/djabberd.install +++ b/debian/djabberd.install @@ -1 +1,3 @@ -debian/tmp/usr / +debian/tmp/usr/bin / +/etc/djabberd.conf /etc/djabberd/ +/etc/log.conf /etc/djabberd/ diff --git a/debian/djabberd.logrotate b/debian/djabberd.logrotate new file mode 100644 index 0000000..a7aa9fa --- /dev/null +++ b/debian/djabberd.logrotate @@ -0,0 +1,8 @@ +/var/log/djabberd/djabberd.log { + daily + missingok + copytruncate + rotate 90 + compress + notifempty +} diff --git a/debian/djabberd.postinst b/debian/djabberd.postinst new file mode 100644 index 0000000..cd35f47 --- /dev/null +++ b/debian/djabberd.postinst @@ -0,0 +1,60 @@ +#!/bin/sh -e + +# DJabberd Common postinst +# Dominik Schulz + +makedir() { + if [ ! -d $1 ]; then + mkdir $1 + fi + chown $2 $1 && chmod $3 $1 +} + +umask 022 + +# postinst processing + +case "$1" in + configure) + OLDVERSION="$2" + # see below + ;; + abort-upgrade) + exit 0 + ;; + abort-remove|abort-deconfigure) + exit 0 + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# make sure that the user exists. the simplest portable way to check that +# is to chown something. +makedir /tmp/djabberd root:root 700 +chgrp djabberd /tmp/djabberd 2>/dev/null || + addgroup --system djabberd +chown djabberd /tmp/djabberd 2>/dev/null || + adduser --system --home /var/lib/djabberd --no-create-home --ingroup djabberd --disabled-password djabberd +# create missing directories and/or make sure the permissions fit +makedir /var/lib/djabberd djabberd:djabberd 755 +makedir /var/log/djabberd djabberd:djabberd 755 +makedir /var/run/djabberd djabberd:djabberd 755 +makedir /etc/djabberd djabberd:djabberd 750 + +# generate a snakeoil keypair so that SSL works OOTB +SERVERKEY="/etc/djabberd/snakeoil-server-key.pem" +SERVERCRT="/etc/djabberd/snakeoil-server-crt.pem" +if [ ! -f $SERVERKEY -a ! -f $SERVERCRT ]; then + openssl req -x509 -batch -newkey rsa:1024 -keyout $SERVERKEY -out $SERVERCRT -days 3650 -nodes +fi + +# remove the temporary directory +rm -r /tmp/djabberd + +# functionality generated by debhelper (e.g. invoking start/stop scripts) will be added here +#DEBHELPER# + +exit 0 diff --git a/debian/djabberd.postrm b/debian/djabberd.postrm new file mode 100644 index 0000000..a895ef5 --- /dev/null +++ b/debian/djabberd.postrm @@ -0,0 +1,27 @@ +#!/bin/sh -e + +# DJabberd Common postrm +# Dominik Schulz + +case "$1" in + remove) + ;; + upgrade) + ;; + purge) + rm -rf /etc/djabberd + rm -rf /var/lib/djabberd + rm -rf /var/log/djabberd + rm -rf /var/run/djabberd + userdel djabberd >/dev/null 2>&1 || true + groupdel djabberd >/dev/null 2>&1 || true + ;; + failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# diff --git a/debian/libdjabberd-perl.install b/debian/libdjabberd-perl.install new file mode 100644 index 0000000..08accc7 --- /dev/null +++ b/debian/libdjabberd-perl.install @@ -0,0 +1 @@ +debian/tmp/usr/share / diff --git a/etc/djabberd.conf b/etc/djabberd.conf new file mode 100644 index 0000000..32a1ec5 --- /dev/null +++ b/etc/djabberd.conf @@ -0,0 +1,76 @@ +OldSSL enable + +# health checks from this IP (directive can be repeated) won't log and +# won't allocate a connection id +DeclareMonitor 127.0.0.1 +AdminPort 5200 + +# defaults: +ClientPort 5222 +ServerPort 5269 + +SSLCertificateFile /etc/djabberd/snakeoil-server-crt.pem +SSLCertificateKeyFile /etc/djabberd/snakeoil-server-key.pem + +PidFile /var/run/djabberd/djabberd.pid + + + S2S enable + RequireSSL yes + + + Optional no + Mechanisms PLAIN LOGIN + + + + Database /var/lib/djabberd/roster.sqlite + + + + Realm djabberd + HtDigest /var/lib/djabberd/djabberd.htdigest + + + + Storage /var/lib/djabberd/vcards.sqlite + + +# This needs the package libdjabberd-authen-userlimit-perl +# +# UserLimit 150 +# + +# This needs the package libdjabberd-entitytime-perl +# + +# This needs the package libdjabberd-plugin-balancer-perl +# + +# This needs the package libdjabberd-plugin-jabberiqversion-perl +# +# OS Debian GNU/Linux +# Name A poorly maintained Jabber Server +# Version Beta +# + +# This needs the package libdjabberd-plugin-ping-perl +# + + + + + +# This needs the package libdjabberd-delivery-offlinestorage-perl +# IMPORTANT: This plugin MUST be loaded last! +# +# Database /var/lib/djabberd/offline.sqlite +# Types Message +# + + + + + + + diff --git a/etc/log.conf b/etc/log.conf new file mode 100644 index 0000000..1c52cea --- /dev/null +++ b/etc/log.conf @@ -0,0 +1,9 @@ +log4perl.logger.DJabberd = ERROR, LOGFILE +log4perl.logger.DJabberd.Hook = WARN + +log4perl.appender.LOGFILE=Log::Log4perl::Appender::File +log4perl.appender.LOGFILE.filename=/var/log/djabberd/djabberd.log +log4perl.appender.LOGFILE.mode=append + +log4perl.appender.LOGFILE.layout=Log::Log4perl::Layout::PatternLayout +log4perl.appender.LOGFILE.layout.ConversionPattern=%-5p %-40c %m %n