#!/bin/sh

# Debian postinst script for Kannel.

set -e

# 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 start
