First revision
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 16 Jul 2008 16:28:09 +0000 (16:28 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 16 Jul 2008 16:28:09 +0000 (16:28 +0000)
README [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/install [new file with mode: 0644]
debian/oomailing.init [new file with mode: 0755]
debian/postinst [new file with mode: 0644]
debian/postrm [new file with mode: 0644]
debian/rules [new file with mode: 0755]
debian/xvfb.init [new file with mode: 0755]
mvoomail [new file with mode: 0755]

diff --git a/README b/README
new file mode 100644 (file)
index 0000000..7a8f7f8
--- /dev/null
+++ b/README
@@ -0,0 +1,23 @@
+Databases must be registered in the openoffice registry of user oomailing
+
+The easy way to do that is to lunch openoffice as oomailing:
+
+As root, set a password:
+host:~# passwd oomailing
+
+Then login with an X display:
+user@host:~$ ssh -X oomaling@localhost
+
+Lunch openoffice
+oomailing@host:~$ soffice
+
+If necessary, load sdbc-postgres driver, using Tools/Package Manager from the menu, then click on "Add" and select postgres-sdbc-0.7.5.zip that you've downloaded from http://dba.openoffice.org/drivers/postgresql/index.html
+On modern distro, you might prefer to install the package:
+host:~# apt-get install openoffice.org-sdbc-postgresql
+
+You need to restart openoffice after that. Also restart oomailing server:
+host:~# /etc/init.d/oomailing restart
+
+You might need to register databases. Launch openoffice again:
+oomailing@host:~$ oowriter
+Then choose Edit/Select Database from the menu. Here you can add a database, such as /var/www/guideogm/static/guideogm.odb
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..ea66449
--- /dev/null
@@ -0,0 +1,5 @@
+oomailing (0.1) UNRELEASED; urgency=low
+
+  * Initial release.
+
+ -- Jean-Michel Vourgère <jmv_deb@nirgal.com>  Wed, 16 Jul 2008 12:44:22 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..f4a9503
--- /dev/null
@@ -0,0 +1,14 @@
+Source: oomailing
+Section: misc
+Priority: optional
+Maintainer: Jean-Michel Vourgère <jmv_deb@nirgal.com>
+Build-Depends: debhelper (>> 3.0.0)
+Standards-Version: 3.7.3
+
+Package: oomailing
+Section: misc
+Architecture: all
+Depends: openoffice.org, xvfb, sudo
+Description: Openoffice mailing server
+ Create an openoffice instance running on a virtual X frame buffer.
+ It listen on a port for mailmerge commands.
diff --git a/debian/install b/debian/install
new file mode 100644 (file)
index 0000000..3e09b2f
--- /dev/null
@@ -0,0 +1 @@
+mvoomail /usr/bin
diff --git a/debian/oomailing.init b/debian/oomailing.init
new file mode 100755 (executable)
index 0000000..08ad994
--- /dev/null
@@ -0,0 +1,33 @@
+#! /bin/sh
+# /etc/init.d/oomailing: start openoffice in server mode
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+binpath=/usr/bin/soffice
+binpathsub=/usr/lib/openoffice/program/soffice.bin
+param="-nologo -nodefault -invisible -display :99 -accept=socket,host=localhost,port=2002;urp;"
+
+test -f $binpath || exit 0
+
+case "$1" in
+  start)
+    echo -n "Starting openoffice server: soffice"
+    start-stop-daemon --start --quiet --exec $binpath --background --chuid oomailing:nogroup -- $param
+    echo "."
+    ;;
+  stop)
+    echo -n "Stopping openoffice server: soffice"
+    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpathsub
+    echo "."
+    ;;
+  restart|force-reload)
+    echo -n "Restarting openoffice server: soffice"
+    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpathsub
+    start-stop-daemon --start --quiet --exec $binpath --background --chuid oomailing:nogroup -- $param
+    echo "."
+    ;;
+  *)
+    echo "Usage: /etc/init.d/xvfb {start|stop|restart|force-reload}"
+    exit 1
+esac
+
+exit 0
diff --git a/debian/postinst b/debian/postinst
new file mode 100644 (file)
index 0000000..5f6ee16
--- /dev/null
@@ -0,0 +1,52 @@
+#! /bin/sh
+# postinst script for oomailing
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+
+case "$1" in
+    configure)
+        if ! id -u oomailing>/dev/null 2>&1; then
+            adduser --system --shell /bin/sh oomailing
+        fi
+        if ! grep -q mvoomail /etc/sudoers; then
+            echo "ALL     ALL=(root) NOPASSWD: /usr/bin/mvoomail">>/etc/sudoers
+        fi
+    ;;
+
+    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 100644 (file)
index 0000000..257d192
--- /dev/null
@@ -0,0 +1,40 @@
+#! /bin/sh
+# postrm script for dolthread
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see /usr/share/doc/packaging-manual/
+
+case "$1" in
+    remove)
+        if id -u oomailing>/dev/null; then 
+            deluser --remove-home oomailing
+        fi
+        grep -v mvoomail /etc/sudoers>/etc/sudoers.new
+        mv /etc/sudoers.new /etc/sudoers
+        ;;
+
+    purge|upgrade|failed-upgrade|abort-install|abort-upgrade|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#
+
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..8808be9
--- /dev/null
@@ -0,0 +1,61 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+build: build-stamp
+build-stamp:
+       dh_testdir
+       touch build-stamp
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp
+       dh_clean
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_install -X.svn
+#      dh_installdebconf
+       dh_installdocs
+       dh_installexamples
+       dh_installmenu
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+       dh_installinit --name=xvfb --update-rcd-params='defaults 90'
+       dh_installinit --name=oomailing --update-rcd-params='defaults 91'
+       dh_installcron
+#      dh_installman
+       dh_installinfo
+       dh_installchangelogs
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+#      dh_makeshlibs
+       dh_installdeb
+#      dh_perl
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/debian/xvfb.init b/debian/xvfb.init
new file mode 100755 (executable)
index 0000000..ef82411
--- /dev/null
@@ -0,0 +1,32 @@
+#! /bin/sh
+# /etc/init.d/xvfb: start a virtual X server
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+binpath=/usr/bin/Xvfb
+param=:99
+
+test -f $binpath || exit 0
+
+case "$1" in
+  start)
+    echo -n "Starting virtual X server: Xvfb"
+    start-stop-daemon --start --quiet --exec $binpath --background -- $param
+    echo "."
+    ;;
+  stop)
+    echo -n "Stopping virtual X server: Xvfb"
+    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpath
+    echo "."
+    ;;
+  restart|force-reload)
+    echo -n "Restarting virtual X server: Xvfb"
+    start-stop-daemon --stop --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $binpath
+    start-stop-daemon --start --quiet --exec $binpath --background -- $param
+    echo "."
+    ;;
+  *)
+    echo "Usage: /etc/init.d/xvfb {start|stop|restart|force-reload}"
+    exit 1
+esac
+
+exit 0
diff --git a/mvoomail b/mvoomail
new file mode 100755 (executable)
index 0000000..f9b6d17
--- /dev/null
+++ b/mvoomail
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+# Moves a generated mail from /tmp/ to a given folder
+# File ownership is changed to the owner of the folder
+# File permissions are changed to 644
+
+set -e
+
+exitusage() {
+       echo $'\n' $@ $'\n' >&2
+       echo "Usage:" >&2
+       echo "   $0 <basefilename> <folder>" >&2
+       exit 1
+}
+
+if [[ `id -u` != 0 ]]; then
+       exitusage This script must be run as root or with sudo
+fi
+if [[ $# != 2 ]]; then
+       exitusage Need two parameters
+fi
+
+if ! echo "$1" | grep -q "^[A-Za-z0-9]*$"; then
+       exitusage SECURITY ERROR: Base file name can only contain alphanumerical characters
+fi
+
+basefilename=$1.odt
+target=$2
+
+test -r /tmp/$basefilename || exitusage "Can't read file /tmp/$basefilename"
+test -d $target || exitusage "$target is not a folder"
+
+targetuid=`ls -dln $target | cut -d \  -f 3`
+targetgid=`ls -dln $target | cut -d \  -f 4`
+
+mv /tmp/$basefilename $target
+chown $targetuid:$targetgid $target/$basefilename
+chmod 644 $target/$basefilename