Recently I set up an instance of djabberd on a box running Debian. Brad Fitzpatrick has posted helpful instructions for getting the daemon set up and configured (even though I needed to tweak the configuration a bit; see below).

What was missing was the ability to start/stop/reload the daemon the Debian way using "/etc/init.d/djabberd (start|stop|restart)". Fortunately Debian makes this pretty easy:

#! /bin/sh

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="DJabberd"
NAME="djabberd"
DAEMON=/usr/local/djabberd/djabberd
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
OPTS="--conf=/etc/djabberd/my.conf"

test -x $DAEMON || exit 0

d_start() {
        start-stop-daemon --start --quiet --pidfile $PIDFILE -m \
                -d /usr/local/djabberd \
                --chuid djabberd \
                --background \
                --exec $DAEMON -- $OPTS
}

d_stop() {
        start-stop-daemon --stop --quiet --pidfile $PIDFILE \
                -d /usr/local/djabberd \
                --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 "."
        ;;
  restart|force-reload)
        echo -n "Restarting $DESC: $NAME"
        d_stop
        sleep 1
        d_start
        echo "."
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        exit 1
        ;;
esac

exit 0
    

I'm running djabberd with an unprivileged system-user called "djabberd", which you'll have to add before using the above script. The djabberd instance is located in /usr/local/djabberd in my configuration.

As mentioned above, Brad's configuration sample wasn't fully up-to-date. Here is what I'm using in /etc/djabberd/my.conf:

OldSSL  enable

SSLCertificateFile    /etc/djabberd/server-cert.pem
SSLCertificateKeyFile /etc/djabberd/server-key.pem

<VHost example.com>

  S2S enable
  RequireSSL yes

  <Plugin DJabberd::Authen::HTDigest>
     Realm djabberd
     HtDigest /etc/djabberd/djabberd.users
  </Plugin>

  <Plugin DJabberd::RosterStorage::SQLite>
     Database /etc/djabberd/jabber.sqlite
  </Plugin>

</VHost>
    

And finally, here is what I use for logging djabberd errors:

log4perl.logger.DJabberd = ERROR, LOGFILE
log4perl.logger.DJabberd.Hook = WARN

log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/var/log/djabberd.log
log4perl.appender.LOGFILE.mode=append

log4perl.appender.LOGFILE.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=%-5p %-40c %m %n
    

(Put this file in /etc/djabberd/log.conf and djabberd will find it automagically.)

Written on 2006-08-06 10:59:55.