#! /bin/sh
#
# convenience wrapper for dbmcli
#
# sets LD_ASSUME_KERNEL if started on a 2.6 kernel system and calls
# dbmcli through rlwrap to enable command history if rlwrap is
# installed
#
# (c) 2004 Martin Kittel <debian@martin-kittel.de>
#

DBMCLICMD=dbmcli
ARCH=`uname -m`

case "$ARCH" in
    i386|i486|i586|i686)
        DISABLE_NPTL="YES"
        ;;
esac

if getconf GNU_LIBPTHREAD_VERSION | grep NPTL > /dev/null 2>&1; then
    HAS_NPTL="YES"
fi

if [ "$DISABLE_NPTL" != "YES" -a "$HAS_NPTL" != "YES" ]; then
    echo "You are running on a system without NPTL support."
    echo "Consider upgrading your kernel to version 2.6."
fi

if [ "$DISABLE_NPTL" = "YES" -a "$HAS_NPTL" = "YES" ]; then
    export LD_ASSUME_KERNEL=2.4.1
fi


if [ -x /usr/bin/rlwrap ]; then
    exec rlwrap $DBMCLICMD $@
else
    exec $DBMCLICMD $@
fi
