#!/bin/sh
#set -e

. $KUMATUXBIN/kumatux.org-vars

KUMATUX_LD_LIBRARY_PATH_ESCAPED=`$KUMATUXBIN/kumatux.org-sed-escape $KUMATUX_LD_LIBRARY_PATH`
if [ "$KUMATUX_LD_LIBRARY_PATH_ESCAPED" ]
then
    SYSTEM_LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | sed "s/$KUMATUX_LD_LIBRARY_PATH_ESCAPED://"`
    SYSTEM_LD_LIBRARY_PATH=`echo $LD_LIBRARY_PATH | sed "s/$KUMATUX_LD_LIBRARY_PATH_ESCAPED//"`
else
    SYSTEM_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
fi

export KUMATUX_LD_LIBRARY_PATH=`cat $KUMATUXETC/$KUMATUXETCLIB/*.conf 2>/dev/null | sed 's/:$//'`
if [ "$KUMATUX_LD_LIBRARY_PATH" ]
then
    if [ "$SYSTEM_LD_LIBRARY_PATH" ]
    then
        export LD_LIBRARY_PATH="$KUMATUX_LD_LIBRARY_PATH:$SYSTEM_LD_LIBRARY_PATH"
    else
	export LD_LIBRARY_PATH=$KUMATUX_LD_LIBRARY_PATH
    fi
else
    export LD_LIBRARY_PATH=$SYSTEM_LD_LIBRARY_PATH
fi
