summaryrefslogtreecommitdiff
path: root/netcon/zerotier-intercept
blob: 85e9fba154b5f3f6efe33eeab549d286b4acd3ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/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.1.0"
			else
				echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so.1.0" || \
				export LD_PRELOAD="/lib/libzerotierintercept.so $LD_PRELOAD"
		fi
	;;
	off)
		export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/lib\/libzerotierintercept.so.1.0 \?//'`
		if [ -z "$LD_PRELOAD" ]
			then
				unset LD_PRELOAD
		fi
	;;
	show|sh)
		echo "LD_PRELOAD=\"$LD_PRELOAD\""
	;;
	-h|-?)
      echo ""
   ;;
	*)
		if [ -z "$LD_PRELOAD" ]
		then
			export LD_PRELOAD="/lib/libzerotierintercept.so.1.0"
		else
			echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so.1.0" || \
			export LD_PRELOAD="/lib/libzerotierintercept.so.1.0 $LD_PRELOAD"
		fi

		if [ $# = 0 ]
		then
			${SHELL:-/bin/sh}
		fi

		if [ $# -gt 0 ]
		then
			exec "$@"
		fi
	;;
esac

#EOF