zerotier-intercept 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. # usage:
  3. # /usr/bin/intercept program <args>
  4. if [ $# = 0 ] ; then
  5. echo "$0: insufficient arguments"
  6. exit
  7. fi
  8. case "$1" in
  9. on)
  10. if [ -z "$LD_PRELOAD" ]
  11. then
  12. export LD_PRELOAD="/lib/libzerotierintercept.so"
  13. else
  14. echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so" || \
  15. export LD_PRELOAD="/lib/libzerotierintercept.so $LD_PRELOAD"
  16. fi
  17. ;;
  18. off)
  19. export LD_PRELOAD=`echo -n $LD_PRELOAD | sed 's/\/lib\/libzerotierintercept.so \?//'`
  20. if [ -z "$LD_PRELOAD" ]
  21. then
  22. unset LD_PRELOAD
  23. fi
  24. ;;
  25. show|sh)
  26. echo "LD_PRELOAD=\"$LD_PRELOAD\""
  27. ;;
  28. -h|-?)
  29. echo ""
  30. ;;
  31. *)
  32. if [ -z "$LD_PRELOAD" ]
  33. then
  34. export LD_PRELOAD="/lib/libzerotierintercept.so"
  35. else
  36. echo $LD_PRELOAD | grep -q "/lib/libzerotierintercept\.so" || \
  37. export LD_PRELOAD="/lib/libzerotierintercept.so $LD_PRELOAD"
  38. fi
  39. if [ $# = 0 ]
  40. then
  41. ${SHELL:-/bin/sh}
  42. fi
  43. if [ $# -gt 0 ]
  44. then
  45. exec "$@"
  46. fi
  47. ;;
  48. esac
  49. #EOF