chutney 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. set -o errexit
  3. set -o nounset
  4. export PYTHONPATH="$(dirname "${0}")/lib:$(dirname "${0}")/scripts:${PYTHONPATH-}"
  5. # make a last-ditch effort to set CHUTNEY_PATH based on this script's location
  6. if ! test "${CHUTNEY_PATH+y}"
  7. then
  8. export CHUTNEY_PATH="`dirname $0`"
  9. fi
  10. binaries="python python3 python2"
  11. if ! test "${PYTHON+y}"
  12. then
  13. saved_IFS="${IFS}"
  14. for binary in ${binaries}
  15. do
  16. IFS=":"
  17. for directory in ${PATH}
  18. do
  19. case "${directory}" in
  20. "") directory="./"
  21. ;;
  22. */)
  23. ;;
  24. *) directory="${directory}/"
  25. ;;
  26. esac
  27. abs_path="${directory}${binary}"
  28. if test -f "${abs_path}" && test -x "${abs_path}"
  29. then
  30. PYTHON="${abs_path}"
  31. break
  32. fi
  33. done
  34. if test "${PYTHON+y}"
  35. then
  36. break
  37. fi
  38. done
  39. IFS="${saved_IFS}"
  40. fi
  41. if ! test "${PYTHON+y}"
  42. then
  43. printf "No compatible Python version found.\n" >&2
  44. printf "Is Python installed and in your PATH?\n" >&2
  45. exit 1
  46. fi
  47. printf "\nLaunching chutney using %s\n" "$("${PYTHON}" --version 2>&1)"
  48. "${PYTHON}" -m chutney.TorNet "${@}"