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/install/debian.sh

182 lines
5.0 KiB

3 years ago
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
3 years ago
export PATH
3 years ago
LANG=en_US.UTF-8
3 years ago
# RED='\e[1;31m' # 红色
# GREEN='\e[1;32m' # 绿色
# YELLOW='\e[1;33m' # 黄色
# BLUE='\e[1;34m' # 蓝色
# PURPLE='\e[1;35m' # 紫色
# CYAN='\e[1;36m' # 蓝绿色
# WHITE='\e[1;37m' # 白色
# NC='\e[0m' # 没有颜色
3 years ago
apt update -y
3 years ago
3 years ago
apt install -y wget curl lsof unzip
3 years ago
apt install -y python3-pip
3 years ago
apt install -y python3-dev
3 years ago
apt install -y python3-venv
3 years ago
apt install -y cron
3 years ago
if [ ! -d /root/.acme.sh ];then
curl https://get.acme.sh | sh
fi
3 years ago
if [ -f /usr/sbin/ufw ];then
ufw allow 22/tcp
ufw allow 80/tcp
ufw allow 443/tcp
ufw allow 888/tcp
ufw allow 7200/tcp
ufw allow 3306/tcp
3 years ago
# ufw allow 30000:40000/tcp
3 years ago
3 years ago
fi
3 years ago
if [ -f /usr/sbin/ufw ];then
ufw disable
fi
3 years ago
if [ ! -f /usr/sbin/ufw ];then
apt install -y firewalld
systemctl enable firewalld
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-port=22/tcp
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --permanent --zone=public --add-port=888/tcp
firewall-cmd --permanent --zone=public --add-port=7200/tcp
firewall-cmd --permanent --zone=public --add-port=3306/tcp
3 years ago
# firewall-cmd --permanent --zone=public --add-port=30000-40000/tcp
3 years ago
# fix:debian10 firewalld faq
# https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled/fang-huo-qiang#debian-10-firewalld-0.6.3-error-commandfailed-usrsbinip6tablesrestorewn-failed-ip6tablesrestore-v1.8
3 years ago
sed -i 's#IndividualCalls=no#IndividualCalls=yes#g' /etc/firewalld/firewalld.conf
firewall-cmd --reload
3 years ago
fi
#安装时不开启
3 years ago
systemctl stop firewalld
3 years ago
3 years ago
#fix zlib1g-dev fail
3 years ago
echo -e "\e[0;32mfix zlib1g-dev install question start\e[0m"
3 years ago
Install_TmpFile=/tmp/debian-fix-zlib1g-dev.txt
apt install -y zlib1g-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
ZLIB1G_BASE_VER=$(cat ${Install_TmpFile} | grep zlib1g | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
3 years ago
ZLIB1G_BASE_VER=`echo ${ZLIB1G_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
3 years ago
# echo "1${ZLIB1G_BASE_VER}1"
3 years ago
echo -e "\e[1;31mapt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev\e[0m"
3 years ago
echo "Y" | apt install zlib1g=${ZLIB1G_BASE_VER} zlib1g-dev
3 years ago
fi
3 years ago
rm -rf ${Install_TmpFile}
3 years ago
echo -e "\e[0;32mfix zlib1g-dev install question end\e[0m"
3 years ago
#fix libunwind-dev fail
echo -e "\e[0;32mfix libunwind-dev install question start\e[0m"
Install_TmpFile=/tmp/debian-fix-libunwind-dev.txt
apt install -y zlib1g-dev > ${Install_TmpFile}
if [ "$?" != "0" ];then
liblzma5_BASE_VER=$(cat ${Install_TmpFile} | grep liblzma-dev | awk -F "=" '{print $2}' | awk -F ")" '{print $1}')
liblzma5_BASE_VER=`echo ${liblzma5_BASE_VER} | sed "s/^[ \s]\{1,\}//g;s/[ \s]\{1,\}$//g"`
echo -e "\e[1;31mapt install liblzma5=${liblzma5_BASE_VER} libunwind-dev\e[0m"
echo "Y" | apt install liblzma5=${liblzma5_BASE_VER} libunwind-dev
fi
rm -rf ${Install_TmpFile}
echo -e "\e[0;32mfix libunwind-dev install question end\e[0m"
3 years ago
cd /www/server/mdserver-web/scripts && bash lib.sh
chmod 755 /www/server/mdserver-web/data
3 years ago
3 years ago
if [ ! -f /usr/local/bin/pip3 ];then
python3 -m pip install --upgrade pip setuptools wheel -i https://mirrors.aliyun.com/pypi/simple
fi
pip install --upgrade pip
sed -i "/mysqlclient/d" /www/server/mdserver-web/requirements.txt
cd /www/server/mdserver-web && pip3 install -r /www/server/mdserver-web/requirements.txt
3 years ago
3 years ago
pip3 install gunicorn==20.1.0
pip3 install gevent==21.1.2
pip3 install gevent-websocket==0.10.1
pip3 install requests==2.20.0
3 years ago
pip3 install flask-caching==1.10.1
3 years ago
pip3 install pymongo
pip3 install psutil
3 years ago
pip3 install flask-socketio==5.2.0
3 years ago
if [ ! -f /www/server/mdserver-web/bin/activate ];then
cd /www/server/mdserver-web && python3 -m venv .
3 years ago
cd /www/server/mdserver-web && source /www/server/mdserver-web/bin/activate
pip install --upgrade pip
3 years ago
pip3 install -r /www/server/mdserver-web/requirements.txt
pip3 install gunicorn==20.1.0
pip3 install gevent==21.1.2
pip3 install gevent-websocket==0.10.1
pip3 install requests==2.20.0
pip3 install flask-caching==1.10.1
pip3 install pymongo
3 years ago
pip3 install psutil
pip3 install flask-socketio==5.2.0
fi
3 years ago
3 years ago
cd /www/server/mdserver-web && ./cli.sh start
3 years ago
sleep 5
3 years ago
3 years ago
echo -e "stop mw"
isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'`
3 years ago
port=7200
if [ -f /www/server/mdserver-web/data/port.pl ];then
port=$(cat /www/server/mdserver-web/data/port.pl)
fi
3 years ago
n=0
while [[ "$isStart" != "" ]];
do
echo -e ".\c"
sleep 0.5
isStart=$(lsof -n -P -i:$port|grep LISTEN|grep -v grep|awk '{print $2}'|xargs)
let n+=1
if [ $n -gt 15 ];then
break;
fi
done
echo -e "start mw"
cd /www/server/mdserver-web && sh cli.sh start
isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'`
n=0
while [[ ! -f /etc/init.d/mw ]];
do
echo -e ".\c"
sleep 0.5
let n+=1
if [ $n -gt 15 ];then
break;
fi
done
echo -e "start mw success"
3 years ago
systemctl daemon-reload
3 years ago
cd /www/server/mdserver-web && ./scripts/init.d/mw default