Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/pgadmin/install.sh

102 lines
2.5 KiB

7 months ago
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
export PATH
7 months ago
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"; }
7 months ago
curPath=`pwd`
rootPath=$(dirname "$curPath")
rootPath=$(dirname "$rootPath")
serverPath=$(dirname "$rootPath")
7 months ago
P_VER=`python3 -V | awk '{print $2}'`
echo "python:$P_VER"
7 months ago
# cd /Users/midoks/Desktop/mwdev/server/mdserver-web/plugins/pgadmin && bash install.sh install 4
7 months ago
# cd /www/server/mdserver-web/plugins/pgadmin && bash install.sh install 4
7 months ago
7 months ago
install_tmp=${rootPath}/tmp/mw_install.pl
if [ "$sys_os" == "Darwin" ];then
BAK='_bak'
else
BAK=''
fi
sysName=`uname`
echo "use system: ${sysName}"
if [ "${sysName}" == "Darwin" ]; then
OSNAME='macos'
elif grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then
OSNAME='centos'
elif grep -Eqi "Fedora" /etc/issue || grep -Eq "Fedora" /etc/*-release; then
OSNAME='fedora'
elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then
OSNAME='debian'
elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then
OSNAME='ubuntu'
elif grep -Eqi "Raspbian" /etc/issue || grep -Eq "Raspbian" /etc/*-release; then
OSNAME='raspbian'
else
OSNAME='unknow'
fi
# if [ -f ${rootPath}/bin/activate ];then
# source ${rootPath}/bin/activate
# fi
Install_pgadmin()
{
7 months ago
# if [ -d $serverPath/pgadmin ];then
# exit 0
# fi
7 months ago
7 months ago
if version_lt "$P_VER" "3.8.0" ;then
echo 'Python版本太低,无法安装'
fi
PG_DIR=${serverPath}/pgadmin
mkdir -p $PG_DIR
7 months ago
echo "${1}" > ${serverPath}/pgadmin/version.pl
7 months ago
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
7 months ago
if [ -f ${PG_DIR}/bin/activate ];then
source ${PG_DIR}/bin/activate
fi
7 months ago
VER=$1
echo '安装完成'
cd ${rootPath} && python3 ${rootPath}/plugins/pgadmin/index.py start
}
Uninstall_pgadmin()
{
cd ${rootPath} && python3 ${rootPath}/plugins/pgadmin/index.py stop
rm -rf ${serverPath}/pgadmin
echo '卸载完成'
}
action=$1
if [ "${1}" == 'install' ];then
Install_pgadmin $2
else
Uninstall_pgadmin $2
fi