#!/bin/sh

# Debian postinst script for Kannel.

set -e

# Automatically added by dh_installdocs
if [ "$1" = "configure" ]; then
        if [ -d /usr/doc -a ! -e /usr/doc/aktion -a -d /usr/share/doc/aktion ]; then
                ln -sf ../share/doc/aktion /usr/doc/aktion
        fi
fi
# End automatically added section

# Create a "kannel" user. This has modeled after the code in the postfix.deb
# postinst. We first try to set the ownership of /var/log/kannel. If that
# fails, we create the user and re-try. If that still fails, we abort.

if chown kannel.root /var/log/kannel 2>/dev/null
then
    :
elif adduser --system --group kannel
then
    chown kannel.root /var/log/kannel
fi

# Update rc.d links.

update-rc.d kannel defaults >/dev/null

# Start Kannel.
# XXX we *should* check that which run-level we're in and only start
# Kannel if /etc/rcX.d/S??kannel exists. I don't know how to figure out
# the current run-level, though.

/etc/init.d/kannel restart || true
