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/scripts/lib.sh

120 lines
3.7 KiB

7 years ago
#!/bin/bash
2 years ago
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:/opt/homebrew/bin
7 years ago
2 years 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"; }
P_VER=`python3 -V | awk '{print $2}'`
echo "python:$P_VER"
2 years ago
sleep 1
2 years ago
7 years ago
curPath=`pwd`
rootPath=$(dirname "$curPath")
serverPath=$(dirname "$rootPath")
7 years ago
sourcePath=$serverPath/source/lib
7 years ago
libPath=$serverPath/lib
7 years ago
7 years ago
mkdir -p $sourcePath
7 years ago
mkdir -p $libPath
7 years ago
rm -rf ${libPath}/lib.pl
7 years ago
3 years ago
3 years ago
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
3 years ago
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
echo "${OSNAME}:${VERSION_ID}"
6 years ago
3 years ago
# system judge
3 years ago
if [ "$OSNAME" == "macos" ]; then
5 years ago
brew install libmemcached
brew install curl
brew install zlib
brew install freetype
brew install openssl
brew install libzip
3 years ago
elif [ "$OSNAME" == "opensuse" ];then
echo "opensuse lib"
elif [ "$OSNAME" == "arch" ];then
echo "arch lib"
3 years ago
elif [ "$OSNAME" == "freebsd" ];then
echo "freebsd lib"
3 years ago
elif [ "$OSNAME" == "centos" ];then
echo "centos lib"
2 years ago
elif [ "$OSNAME" == "rocky" ]; then
echo "rocky lib"
3 years ago
elif [ "$OSNAME" == "fedora" ];then
echo "fedora lib"
elif [ "$OSNAME" == "alma" ];then
echo "alma lib"
elif [ "$OSNAME" == "ubuntu" ];then
echo "ubuntu lib"
elif [ "$OSNAME" == "debian" ]; then
echo "debian lib"
5 years ago
else
3 years ago
echo "OK"
5 years ago
fi
3 years ago
2 years ago
2 years ago
# HTTP_PREFIX="https://"
# LOCAL_ADDR=common
# ping -c 1 github.com > /dev/null 2>&1
# if [ "$?" != "0" ];then
# LOCAL_ADDR=cn
# HTTP_PREFIX="https://ghproxy.com/"
# fi
2 years ago
HTTP_PREFIX="https://"
LOCAL_ADDR=common
2 years ago
cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"")
2 years ago
if [ ! -z "$cn" ] || [ "$?" == "0" ] ;then
2 years ago
LOCAL_ADDR=cn
HTTP_PREFIX="https://ghproxy.com/"
2 years ago
fi
2 years ago
PIPSRC="https://pypi.python.org/simple"
2 years ago
if [ "$LOCAL_ADDR" != "common" ];then
2 years ago
PIPSRC="https://pypi.tuna.tsinghua.edu.cn/simple"
fi
2 years ago
echo "local:${LOCAL_ADDR}"
2 years ago
echo "pypi source:$PIPSRC"
2 years ago
#面板需要的库
2 years ago
if [ ! -f /usr/local/bin/pip3 ] && [ ! -f /usr/bin/pip3 ];then
2 years ago
python3 -m pip install --upgrade pip setuptools wheel -i $PIPSRC
2 years ago
which pip3 && pip3 install --upgrade pip -i $PIPSRC
pip3 install --upgrade pip setuptools wheel -i $PIPSRC
fi
2 years ago
if [ ! -f /www/server/mdserver-web/bin/activate ];then
2 years ago
if version_ge "$P_VER" "3.11.0" ;then
cd /www/server/mdserver-web && python3 -m venv /www/server/mdserver-web
else
2 years ago
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
2 years ago
cd /www/server/mdserver-web && python3 -m venv .
fi
3 years ago
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
else
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
fi
2 years ago
pip3 install --upgrade pip -i $PIPSRC
2 years ago
pip3 install --upgrade setuptools -i $PIPSRC
2 years ago
# --no-cache-dir
2 years ago
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
2 years ago
# Different versions use different python lib
P_VER_D=`echo "$P_VER"|awk -F '.' '{print $1}'`
P_VER_M=`echo "$P_VER"|awk -F '.' '{print $2}'`
2 years ago
NEW_P_VER=${P_VER_D}.${P_VER_M}
2 years ago
if [ -f /www/server/mdserver-web/version/r${NEW_P_VER}.txt ];then
2 years ago
echo "cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/version/r${NEW_P_VER}.txt"
2 years ago
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/version/r${NEW_P_VER}.txt -i $PIPSRC
fi
2 years ago
echo "lib ok!"