enable-python27.sh 596 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/bash
  2. python27_exists=0
  3. python_vers=("/usr/bin" "/usr/local/python27/bin" "/opt/rh/python27/root/usr/bin")
  4. function run_python() {
  5. $1 --version >/dev/null 2>&1
  6. if [ ! $? -eq 0 ]; then
  7. echo 0
  8. else
  9. echo 1
  10. fi
  11. }
  12. for binpath in ${python_vers[@]}; do
  13. if [[ $binpath == "/opt/rh/python27"* ]]; then
  14. . /opt/rh/python27/enable
  15. fi
  16. out=$(run_python $binpath/python2.7)
  17. if [ $out -eq 1 ]; then
  18. export PATH=$binpath:$PATH
  19. python27_exists=1
  20. break
  21. fi
  22. done
  23. if [ $python27_exists -eq 0 ]; then
  24. echo "ERROR: Unable to find python 2.7 installation"
  25. exit 1
  26. fi