#!/bin/sh
# usage:
# /usr/bin/intercept program <args>
if [ $# = 0 ] ; then
echo "$0: insufficient arguments"
exit
fi
case "$1" in
on)
if [ -z "$LD_PRELOAD" ]
then
export LD_PRELOAD="/lib/libzerotierintercept.so"
else
echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so" || \
export LD_PRELOAD="/lib/libzerotierintercept.so $LD_PRELOAD"
;;
off)
export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/lib\/libzerotierintercept.so \?//'`
unset LD_PRELOAD
show|sh)
echo "LD_PRELOAD=\"$LD_PRELOAD\""
-h|-?)
echo ""
*)
if [ $# = 0 ]
${SHELL:-/bin/sh}
if [ $# -gt 0 ]
exec "$@"
esac
#EOF