From c4ebfff55e740d8b103b525781f5d6e307fb9032 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Tue, 1 Oct 2024 12:22:10 +0800 Subject: [PATCH] Update install.sh --- plugins/pgadmin/install.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/plugins/pgadmin/install.sh b/plugins/pgadmin/install.sh index bdcfc5f80..ec98ded01 100755 --- a/plugins/pgadmin/install.sh +++ b/plugins/pgadmin/install.sh @@ -2,11 +2,19 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin export PATH +function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" != "$1"; } +function version_le() { test "$(echo "$@" | tr " " "\n" | sort -V | head -n 1)" == "$1"; } +function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; } +function version_ge() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" == "$1"; } + curPath=`pwd` rootPath=$(dirname "$curPath") rootPath=$(dirname "$rootPath") serverPath=$(dirname "$rootPath") +P_VER=`python3 -V | awk '{print $2}'` +echo "python:$P_VER" + # cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/pgadmin && bash install.sh install 4 # cd /www/server/mdserver-web/plugins/pgadmin && bash install.sh install 4 @@ -43,12 +51,26 @@ fi Install_pgadmin() { - if [ -d $serverPath/pgadmin ];then - exit 0 - fi + # if [ -d $serverPath/pgadmin ];then + # exit 0 + # fi - mkdir -p ${serverPath}/pgadmin + if version_lt "$P_VER" "3.8.0" ;then + echo 'Python版本太低,无法安装' + fi + PG_DIR=${serverPath}/pgadmin + mkdir -p $PG_DIR echo "${1}" > ${serverPath}/pgadmin/version.pl + + if [ ! -f $PG_DIR/bin/activate ];then + if version_ge "$P_VER" "3.11.0" ;then + echo "python3 > 3.11" + cd $PG_DIR && python3 -m venv $PG_DIR + else + echo "python3 < 3.10" + cd $PG_DIR && python3 -m venv . + fi + fi VER=$1