mdserver-web/scripts/lib.sh

96 lines
2.6 KiB
Bash
Raw Normal View History

2018-11-25 10:30:19 -05:00
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
2018-11-26 06:18:50 -05:00
curPath=`pwd`
rootPath=$(dirname "$curPath")
serverPath=$(dirname "$rootPath")
2018-11-27 06:20:46 -05:00
sourcePath=$serverPath/source/lib
2018-11-26 06:18:50 -05:00
libPath=$serverPath/lib
2018-11-25 10:30:19 -05:00
2018-11-27 06:20:46 -05:00
mkdir -p $sourcePath
2018-11-26 06:18:50 -05:00
mkdir -p $libPath
2018-11-27 06:20:46 -05:00
rm -rf ${libPath}/lib.pl
2018-11-26 00:57:06 -05:00
2022-06-10 04:42:31 -04:00
2022-07-07 03:28:20 -04:00
bash ${rootPath}/scripts/getos.sh
OSNAME=`cat ${rootPath}/data/osname.pl`
2022-06-30 01:35:32 -04:00
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
echo "${OSNAME}:${VERSION_ID}"
2019-03-12 01:11:00 -04:00
2022-06-14 11:05:25 -04:00
# system judge
2022-06-10 04:42:31 -04:00
if [ "$OSNAME" == "macos" ]; then
2020-07-12 03:27:25 -04:00
brew install libmemcached
brew install curl
brew install zlib
brew install freetype
brew install openssl
brew install libzip
2022-07-03 13:01:29 -04:00
elif [ "$OSNAME" == "opensuse" ];then
echo "opensuse lib"
elif [ "$OSNAME" == "arch" ];then
echo "arch lib"
2022-07-04 07:15:09 -04:00
elif [ "$OSNAME" == "freebsd" ];then
echo "freebsd lib"
2022-07-15 14:04:31 -04:00
elif [ "$OSNAME" == "centos" ];then
echo "centos lib"
2022-11-27 12:40:40 -05:00
elif [ "$OSNAME" == "rocky" ]; then
echo "rocky lib"
2022-07-17 05:27:57 -04:00
elif [ "$OSNAME" == "fedora" ];then
echo "fedora lib"
elif [ "$OSNAME" == "alma" ];then
echo "alma lib"
2022-11-03 12:25:47 -04:00
elif [ "$OSNAME" == "ubuntu" ];then
echo "ubuntu lib"
elif [ "$OSNAME" == "debian" ]; then
echo "debian lib"
2020-07-12 03:27:25 -04:00
else
2022-07-17 05:27:57 -04:00
echo "OK"
2020-07-12 03:27:25 -04:00
fi
2022-06-14 11:04:10 -04:00
2023-03-23 03:21:22 -04:00
2023-02-24 04:12:31 -05:00
HTTP_PREFIX="https://"
LOCAL_ADDR=common
2023-03-23 03:21:22 -04:00
ping -c 1 ipinfo.io > /dev/null 2>&1
if [ "$?" == "0" ];then
CN=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"")
2023-03-29 04:08:55 -04:00
if [ ! -z "$CN" ];then
2023-03-23 03:21:22 -04:00
LOCAL_ADDR=cn
HTTP_PREFIX="https://ghproxy.com/"
fi
2023-02-24 04:12:31 -05:00
fi
2022-12-09 13:47:12 -05:00
PIPSRC="https://pypi.python.org/simple"
2023-02-24 04:12:31 -05:00
if [ "$LOCAL_ADDR" != "common" ];then
2022-12-09 13:47:12 -05:00
PIPSRC="https://pypi.tuna.tsinghua.edu.cn/simple"
fi
2023-03-15 11:26:23 -04:00
echo "pypi source:$PIPSRC"
2022-06-26 07:07:10 -04:00
#面板需要的库
2022-12-09 13:47:12 -05:00
if [ ! -f /usr/local/bin/pip3 ] && [ ! -f /usr/bin/pip3 ];then
2022-12-09 12:51:07 -05:00
python3 -m pip install --upgrade pip setuptools wheel -i $PIPSRC
2022-06-26 07:07:10 -04:00
fi
2022-12-09 12:51:07 -05:00
which pip && pip install --upgrade pip -i $PIPSRC
2022-12-12 12:24:29 -05:00
pip3 install --upgrade pip setuptools wheel -i $PIPSRC
2023-03-23 03:21:22 -04:00
2022-12-09 12:51:07 -05:00
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
2022-06-26 07:07:10 -04:00
2022-11-01 08:11:16 -04:00
# pip3 install flask-caching==1.10.1
2022-08-07 03:02:48 -04:00
# pip3 install mysqlclient
2022-06-26 07:07:10 -04:00
if [ ! -f /www/server/mdserver-web/bin/activate ];then
cd /www/server/mdserver-web && python3 -m venv .
2022-06-26 07:08:50 -04:00
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
2022-06-26 07:07:10 -04:00
else
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
fi
2022-12-09 12:51:07 -05:00
pip install --upgrade pip -i $PIPSRC
pip3 install --upgrade setuptools -i $PIPSRC
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt -i $PIPSRC
2022-06-26 07:07:10 -04:00
2022-11-27 12:21:00 -05:00
echo "lib ok!"
2022-11-01 08:11:16 -04:00
# pip3 install flask-caching==1.10.1
2022-08-07 03:02:48 -04:00
# pip3 install mysqlclient
2022-06-26 07:07:10 -04:00