#!/bin/sh

PATH_LIB="/usr/lib/"
NXREDIR_LIBRARY="$PATH_LIB/libnxredir.so.0"

if [ -z "$NXCUPS_PORT" -a -z "$NXSAMBA_PORT" ]
then
	echo "nxredir: Redirect standard ports to nxproxy"
	echo ""
	echo "Usage: export NXCUPS_PORT='where_cups_is_running'"
	echo "       export NXSAMBA_PORT='where_samba_is_running'"
	
	# invoke the program with the args given
	exec "$@"
	exit 0
fi

export LD_PRELOAD="$NXREDIR_LIBRARY${LD_PRELOAD:+:$LD_PRELOAD}"

# invoke the program with the args given
exec "$@"
