chutney 1.3 KB

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