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/ubuntu.sh

114 lines
2.7 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
if grep -Eq "Ubuntu" /etc/*-release; then
3 years ago
sudo ln -sf /bin/bash /bin/sh
#sudo dpkg-reconfigure dash
fi
3 years ago
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
apt install -y python3-venv
3 years ago
apt install -y python3-dev
3 years ago
3 years ago
apt install -y cron
3 years ago
3 years ago
if [ ! -d /root/.acme.sh ];then
3 years ago
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
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
sed -i 's#IndividualCalls=no#IndividualCalls=yes#g' /etc/firewalld/firewalld.conf
3 years ago
firewall-cmd --reload
3 years ago
fi
3 years ago
#安装时不开启
3 years ago
systemctl stop firewalld
3 years ago
3 years ago
3 years ago
cd /www/server/mdserver-web/scripts && bash lib.sh
3 years ago
chmod 755 /www/server/mdserver-web/data
3 years ago
3 years ago
3 years ago
# mysql8.0 在ubuntu22需要的库
apt install -y patchelf
3 years ago
VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'`
3 years ago
if [ "${VERSION_ID}" == "22.04" ];then
pip3 install -U --force-reinstall --no-binary :all: gevent
fi
if [ ! -f /www/server/mdserver-web/bin/activate ];then
cd /www/server/mdserver-web && python3 -m venv .
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
if [ "${VERSION_ID}" == "22.04" ];then
pip3 install -U --force-reinstall --no-binary :all: gevent
fi
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
3 years ago