diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..c4ec33d --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,49 @@ +jmc for Debian +-------------- +- edit /etc/jabber/jmc.xml to match jabber server configuration : + - for jabberd2, port must match router.xml port + - for ejabberd, add new listening port : + {5347, ejabberd_service, [{access, all}, + {host, "jmc.localhost", + [{password, "secret"}]}]} + +- then run: +# /etc/init.d/jmc start + +Usage: + +- Now you can register new mail server connection with your favorite +jabber client. +- all connection are then listed under your service browser and you +can edit mail server parameters by registering on listed connection. + +Feedback: + +Send me feedback and comments to dax at happycoders dot org + +Utils: +- jmc_converter convert from one storage type to another. + +$ jmc_converter + +-> give you the list of supported types. + +Example of usage : + +$ jmc_converter \ + DBM \ + registered.db \ + SQLite \ + registered.sqlite + +-> converts a DBM file (registered.db) to a SQLite file +(registered.sqlite). Once converted, the new file copied in +${spool_dir}/${service}/registered.db where ${spool_dir} and +${service} are defined in jmc.xml configuration file. + +- jmc_dump dump a db file. example : + +$ jmc_dump DBM registered.db + + + -- David Rousselie , Wed, 26 Jul 2006 22:04:38 +0200 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..b9d30be --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +jmc (0.2.2-1) unstable; urgency=low + + * Initial Debian release + + -- David Rousselie Wed, 26 Jul 2006 23:07:24 +0200 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +4 diff --git a/debian/conffiles b/debian/conffiles new file mode 100644 index 0000000..e046b6b --- /dev/null +++ b/debian/conffiles @@ -0,0 +1,2 @@ +/etc/default/jmc +/etc/jabber/jmc.conf diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..3af3750 --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: jmc +Section: python +Priority: optional +Maintainer: David Rousselie +Build-Depends: debhelper (>= 4.1.0) +Standards-Version: 3.6.2 + +Package: jmc +Architecture: all +Depends: ${python:Depends}, python-pyxmpp (>= 0.5) +Recommends: python2.4-pysqlite2 (>= 2.0) +Description: JMC is an email gateway for Jabber + JMC is a jabber service to check email from POP3 and IMAP4 server and retrieve them or just a notification of new emails. Jabber users can register multiple email accounts. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..91ba0ce --- /dev/null +++ b/debian/copyright @@ -0,0 +1,26 @@ +This package was debianized by David Rousselie on +Wed, 26 Jul 2006 22:04:38 +0200. + +It was downloaded from http://people.happycoders.org/dax/jabber/jmc.html + +Copyright Holder: David Rousselie + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 0000000..872d7bc --- /dev/null +++ b/debian/dirs @@ -0,0 +1,7 @@ +var/run/jabber +var/log/jabber +var/spool/jabber +etc/default +etc/jabber +usr/share/jmc +usr/bin diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..724e084 --- /dev/null +++ b/debian/docs @@ -0,0 +1,2 @@ +README +TODO diff --git a/debian/init.d b/debian/init.d new file mode 100755 index 0000000..e25fdb3 --- /dev/null +++ b/debian/init.d @@ -0,0 +1,147 @@ +#! /bin/bash -e + +export PATH=/sbin:/bin:/usr/sbin:/usr/bin + +# ----- load init-functions if they exist ----- + +if [ -f /lib/lsb/init-functions ]; then + . /etc/lsb-release + . /lib/lsb/init-functions +fi + +# ----- Functions for printing messages (Works for debian and looks good in ubuntu too) + +log_start() +{ + case $DISTRIB_ID.$DISTRIB_RELEASE in + Ubuntu.[0-4].*|Ubuntu.5.[0-9]|Ubuntu.5.10) + log_begin_msg $1 + ;; + Ubuntu.*.*) + log_daemon_msg $1 + ;; + *) + echo -n $1 + ;; + esac +} + +log_end() +{ + case $DISTRIB_ID.$DISTRIB_RELEASE in + Ubuntu.*.*) + log_end_msg $1 + ;; + *) + if [ "$1" = "0" ]; then + echo "Started" + else + echo "Error starting daemon, check the logs." + fi + ;; + esac +} + +log_failure() +{ + case $DISTRIB_ID.$DISTRIB_RELEASE in + Ubuntu.*.*) + log_failure_msg $1 + ;; + *) + echo $1 + ;; + esac +} + +# ----- set required environment ----- + +TRANS_NAME=jmc +TRANS_DESC="Jabber Mail Component" +TRANS_HOME=/usr/share/$TRANS_NAME +TRANS_CONFIG=/etc/jabber/$TRANS_NAME.conf +TRANS_USER=jabber +TRANS_GROUP=daemon +TRANS_PID=`grep ".*" $TRANS_CONFIG | sed 's:.*\(.*\).*:\1:'` +TRANS_DAEMON=/usr/bin/jmc +TRANS_START="--chuid $TRANS_USER:$TRANS_GROUP --chdir $TRANS_HOME --pidfile $TRANS_PID" +TRANS_STOP="--pidfile $TRANS_PID" +TRANS_OPTIONS="-c $TRANS_CONFIG" +TRANSPORT_DEFAULTS_FILE=/etc/default/$TRANS_NAME + +# ----- Check if transport is enabled ----- + +if [ -s $TRANSPORT_DEFAULTS_FILE ]; then + . $TRANSPORT_DEFAULTS_FILE + case "x$ENABLE" in + xtrue) ;; + xfalse) + exit 0 + ;; + *) + log_failure "Value of ENABLE in $TRANSPORT_DEFAULTS_FILE must be either 'true' or 'false';" + log_failure "not starting $TRANS_NAME daemon." + exit 0 + ;; + esac +else + log_failure "$TRANSPORT_DEFAULTS_FILE not found. Not starting $TRANS_NAME daemon." + exit 1 +fi + +# ----- do the action ----- + +case "$1" in +config) + echo "Configuration:" + echo " TRANS_NAME=$TRANS_NAME" + echo " TRANS_DESC=$TRANS_DESC" + echo " TRANS_HOME=$TRANS_HOME" + echo " TRANS_CONFIG=$TRANS_CONFIG" + echo " TRANS_USER=$TRANS_USER" + echo " TRANS_PID=$TRANS_PID" + echo " TRANS_DAEMON=$TRANS_DAEMON" + echo " TRANS_OPTIONS=$TRANS_OPTIONS" + ;; + +console) + $TRANS_DAEMON $TRANS_OPTIONS + ;; + +start) + log_start "Starting $TRANS_DESC: " + if start-stop-daemon $TRANS_START --start --oknodo --exec $TRANS_DAEMON -- $TRANS_OPTIONS $DAEMON_OPTS >/dev/null 2>&1; then + log_end 0 + else + log_end 1 + fi + ;; +stop) + log_start "Stopping $TRANS_DESC: " + if start-stop-daemon --stop $TRANS_STOP --retry 10 --oknodo 2>&1; then + log_end 0 + else + log_end 1 + fi + ;; +reload|force-reload) + log_start "Reloading $TRANS_DESC: " + if start-stop-daemon --stop $TRANS_STOP --signal HUP >/dev/null 2>&1; then + log_end 0 + else + log_end 1 + fi + ;; +restart) + $0 stop + sleep 5 + $0 start + ;; +*) + echo "Usage: /etc/init.d/$TRANS_NAME {config|console|start|stop|restart|reload|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 + diff --git a/debian/jmc-default b/debian/jmc-default new file mode 100644 index 0000000..ad28540 --- /dev/null +++ b/debian/jmc-default @@ -0,0 +1,10 @@ +# Defaults for jmc initscript +# sourced by /etc/init.d/jmc +# installed at /etc/default/jmc by the maintainer scripts + +ENABLE="false" + +# Additional options that are passed to the Daemon. +# use this line to activate debug +#DAEMON_OPTS="-D" +DAEMON_OPTS="" diff --git a/debian/jmc.conf b/debian/jmc.conf new file mode 100644 index 0000000..696adce --- /dev/null +++ b/debian/jmc.conf @@ -0,0 +1,22 @@ + + + 127.0.0.1 + 5347 + secret + jmc.localhost + 5 + + en + + Jabber Mail Component + A Jabber mail server component + http://people.happycoders.org/dax/jabber/jmc/ + + + DBM + /var/spool/jabber + /var/run/jabber/jmc.pid + + 5 + iso-8859-1 + diff --git a/debian/jmc.sh b/debian/jmc.sh new file mode 100755 index 0000000..d2b64a0 --- /dev/null +++ b/debian/jmc.sh @@ -0,0 +1,3 @@ +#!/bin/sh +python /usr/share/jmc/jmc.py $* & + diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..10c4f62 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,65 @@ +#! /bin/sh +# postinst script for jabber-pyaim +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package +# + +case "$1" in + configure) + uid=`getent passwd jabber | cut -d ":" -f 3` + + # if there is the uid the account is there and we can do + # the sanit(ar)y checks otherwise we can safely create it. + + if [ "$uid" ]; then + # guess??? the checks!!! + if [ $uid -ge 100 ] && [ $uid -le 999 ]; then + echo "jabber uid check: ok" + else + echo "ERROR: jabber account has a non-system uid!" + exit 1 + fi + else + adduser --quiet \ + --system \ + --disabled-password \ + --home /var/run/jabber \ + --no-create-home \ + --shell /bin/false \ + jabber + fi + chown jabber:daemon /var/spool/jabber + chown jabber:daemon /var/run/jabber + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/postrm b/debian/postrm new file mode 100755 index 0000000..010466a --- /dev/null +++ b/debian/postrm @@ -0,0 +1,38 @@ +#! /bin/sh +# postrm script for jabber-pyaim +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' overwrit>r> +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + + + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/preinst b/debian/preinst new file mode 100755 index 0000000..6b18bff --- /dev/null +++ b/debian/preinst @@ -0,0 +1,38 @@ +#! /bin/sh +# preinst script for jabber-pyaim +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 0000000..405058d --- /dev/null +++ b/debian/prerm @@ -0,0 +1,38 @@ +#! /bin/sh +# prerm script for jabber-pyaim +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + ;; + failed-upgrade) + ;; + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..8a0d1fe --- /dev/null +++ b/debian/rules @@ -0,0 +1,76 @@ +#!/usr/bin/make -f +# jmc debian/rules file +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +configure: configure-stamp +configure-stamp: + dh_testdir + touch configure-stamp + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + + # Clean up package tree + rm -f -R $(CURDIR)/debian/jmc + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Create directory tree for package + + cp -R $(CURDIR)/debian/jmc.conf $(CURDIR)/debian/jmc/etc/jabber/jmc.conf + cp -R $(CURDIR)/debian/jmc-default $(CURDIR)/debian/jmc/etc/default/jmc + cp -R $(CURDIR)/debian/jmc.sh $(CURDIR)/debian/jmc/usr/bin/jmc + cp -R $(CURDIR)/src/* $(CURDIR)/debian/jmc/usr/share/jmc + +# Build architecture-independent files here. +binary-indep: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs +# dh_installexamples + dh_install +# dh_installmenu +# dh_installdebconf + dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime + dh_installinit +# dh_installcron +# dh_installinfo +# dh_installman + dh_link +# dh_strip +# dh_compress + dh_fixperms +# dh_perl + dh_python /usr/share/jmc +# dh_makeshlibs + dh_installdeb +# dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +# Build architecture-dependent files here. +binary-arch: build install +# We have nothing to do by default. + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/src/jmc.py b/src/jmc.py index 1b5aec1..84d3989 100755 --- a/src/jmc.py +++ b/src/jmc.py @@ -64,6 +64,7 @@ def main(config_file = "jmc.xml", isDebug = 0): print "starting..." mailcomp.run(1) + os.remove(config.get_content("config/pidfile")) except ComponentFatalError,e: print e print "Aborting."