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

139 lines
3.9 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
3 years ago
if grep -Eq "Debian" /etc/*-release; then
3 years ago
ln -sf /bin/bash /bin/sh
fi
3 years ago
apt update -y
3 years ago
apt-get update -y
3 years ago
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
apt install -y expect
3 years ago
3 years ago
apt install -y locate
3 years ago
locale-gen en_US.UTF-8
3 years ago
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
3 years ago
# sudo localedef -i en_US -f UTF-8 en_US.UTF-8
3 years ago
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
3 years ago
# 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
3 years ago
# 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
3 years ago
apt install -y libunwind-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
apt install -y libvpx-dev
apt install -y libxpm-dev
apt install -y libwebp-dev
apt install -y libfreetype6-dev
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
cd /www/server/mdserver-web && ./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 1
let n+=1
if [ $n -gt 20 ];then
echo -e "start mw fail"
exit 1
fi
done
cd /www/server/mdserver-web && /etc/init.d/mw stop
3 years ago
cd /www/server/mdserver-web && /etc/init.d/mw start
cd /www/server/mdserver-web && /etc/init.d/mw default