From 50502cf7bb1da2e2d3f37339abf9baf673b72ded Mon Sep 17 00:00:00 2001 From: ly1217 Date: Tue, 26 Nov 2019 18:37:47 -0800 Subject: [PATCH] Modify check python executable in scripts. --- scripts/reset-admin.sh | 24 +++++++++++++----------- scripts/seahub.sh | 24 +++++++++++++----------- scripts/setup-seafile-mysql.sh | 24 +++++++++++++----------- scripts/setup-seafile.sh | 24 +++++++++++++----------- 4 files changed, 52 insertions(+), 44 deletions(-) diff --git a/scripts/reset-admin.sh b/scripts/reset-admin.sh index b9d7ce2..2e2554d 100755 --- a/scripts/reset-admin.sh +++ b/scripts/reset-admin.sh @@ -11,21 +11,23 @@ function check_python_executable() { return 0 fi - if !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then + if which python3 2>/dev/null 1>&2; then + PYTHON=python3 + elif !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then echo echo "The current version of python is not 3.x.x, please use Python 3.x.x ." echo exit 1 - fi - - PYTHON="python"$(python --version | cut -b 8-10) - if !which $PYTHON 2>/dev/null 1>&2; then - echo - echo "Can't find a python executable of $PYTHON in PATH" - echo "Install $PYTHON before continue." - echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" - echo - exit 1 + else + PYTHON="python"$(python --version | cut -b 8-10) + if !which $PYTHON 2>/dev/null 1>&2; then + echo + echo "Can't find a python executable of $PYTHON in PATH" + echo "Install $PYTHON before continue." + echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" + echo + exit 1 + fi fi } diff --git a/scripts/seahub.sh b/scripts/seahub.sh index a2a5c1d..6a9ae9e 100755 --- a/scripts/seahub.sh +++ b/scripts/seahub.sh @@ -51,21 +51,23 @@ function check_python_executable() { return 0 fi - if !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then + if which python3 2>/dev/null 1>&2; then + PYTHON=python3 + elif !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then echo echo "The current version of python is not 3.x.x, please use Python 3.x.x ." echo exit 1 - fi - - PYTHON="python"$(python --version | cut -b 8-10) - if !which $PYTHON 2>/dev/null 1>&2; then - echo - echo "Can't find a python executable of $PYTHON in PATH" - echo "Install $PYTHON before continue." - echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" - echo - exit 1 + else + PYTHON="python"$(python --version | cut -b 8-10) + if !which $PYTHON 2>/dev/null 1>&2; then + echo + echo "Can't find a python executable of $PYTHON in PATH" + echo "Install $PYTHON before continue." + echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" + echo + exit 1 + fi fi } diff --git a/scripts/setup-seafile-mysql.sh b/scripts/setup-seafile-mysql.sh index b90abf7..2135a50 100755 --- a/scripts/setup-seafile-mysql.sh +++ b/scripts/setup-seafile-mysql.sh @@ -23,21 +23,23 @@ function check_python_executable() { return 0 fi - if !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then + if which python3 2>/dev/null 1>&2; then + PYTHON=python3 + elif !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then echo echo "The current version of python is not 3.x.x, please use Python 3.x.x ." echo err_and_quit - fi - - PYTHON="python"$(python --version | cut -b 8-10) - if !which $PYTHON 2>/dev/null 1>&2; then - echo - echo "Can't find a python executable of $PYTHON in PATH" - echo "Install $PYTHON before continue." - echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" - echo - err_and_quit + else + PYTHON="python"$(python --version | cut -b 8-10) + if !which $PYTHON 2>/dev/null 1>&2; then + echo + echo "Can't find a python executable of $PYTHON in PATH" + echo "Install $PYTHON before continue." + echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" + echo + err_and_quit + fi fi } diff --git a/scripts/setup-seafile.sh b/scripts/setup-seafile.sh index f935f62..a00e327 100755 --- a/scripts/setup-seafile.sh +++ b/scripts/setup-seafile.sh @@ -95,21 +95,23 @@ function check_python_executable() { return 0 fi - if !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then + if which python3 2>/dev/null 1>&2; then + PYTHON=python3 + elif !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then echo echo "The current version of python is not 3.x.x, please use Python 3.x.x ." echo err_and_quit - fi - - PYTHON="python"$(python --version | cut -b 8-10) - if !which $PYTHON 2>/dev/null 1>&2; then - echo - echo "Can't find a python executable of $PYTHON in PATH" - echo "Install $PYTHON before continue." - echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" - echo - err_and_quit + else + PYTHON="python"$(python --version | cut -b 8-10) + if !which $PYTHON 2>/dev/null 1>&2; then + echo + echo "Can't find a python executable of $PYTHON in PATH" + echo "Install $PYTHON before continue." + echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it" + echo + err_and_quit + fi fi echo "Find python: $PYTHON"