diff --git a/README.md b/README.md index d9a03e87e..aa5bc78d2 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ 简单的Linux面板,感谢BT.CN写出如此好的web管理软件。我一看到,就知道这是我一直想要的页面化管理方式。 复制了后台管理界面,按照自己想要的方式写了一版。 - +![EulerOS](https://img.shields.io/badge/LINUX-EulerOS-blue?style=for-the-badge&logo=EulerOS) ![Debian](https://img.shields.io/badge/LINUX-Debian-blue?style=for-the-badge&logo=Debian) ![Ubuntu](https://img.shields.io/badge/LINUX-Ubuntu-blue?style=for-the-badge&logo=Ubuntu) ![Fedora](https://img.shields.io/badge/LINUX-Fedora-blue?style=for-the-badge&logo=Fedora) @@ -103,6 +103,11 @@ docker run -itd --name mw-server --privileged=true -p 7200:7200 -p 80:80 -p 443: ### 版本更新 0.16.1 * 给防盗链增加禁止空来源。 +* OpenResty安装兼容。 +* Debian10安装优化。 +* 安装时默认监控开启。 +* MySQL/MYSQL-YUM/MySQL-APT添加重置master功能。 +* 支持华为欧拉系统。 ### JSDelivr安装地址 diff --git a/class/core/common.py b/class/core/common.py index 28f624fc6..d4db9d980 100755 --- a/class/core/common.py +++ b/class/core/common.py @@ -32,6 +32,7 @@ from flask import redirect def init(): + initSystemControl() initDB() initDBSshPort() initUserInfo() @@ -145,10 +146,22 @@ def initInitTask(): api.createCertCron() +def initSystemControl(): + path = 'data/default.db' + if os.path.exists(path): + return False + + import system_api + sapi = system_api.system_api() + r = sapi.setControl(1, 30) + print(r) + + def initUserInfo(): data = mw.M('users').where('id=?', (1,)).getField('password') if data == '21232f297a57a5a743894a0e4a801fc3': + pwd = mw.getRandomString(8).lower() file_pw = mw.getRunDir() + '/data/default.pl' mw.writeFile(file_pw, pwd) diff --git a/class/core/config_api.py b/class/core/config_api.py index c1511fdec..53f0e2b2d 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -27,7 +27,7 @@ from flask import request class config_api: - __version = '0.16.0' + __version = '0.16.1' __api_addr = 'data/api.json' def __init__(self): diff --git a/plugins/gogs/info.json b/plugins/gogs/info.json index 8b427426a..5f745f2f0 100755 --- a/plugins/gogs/info.json +++ b/plugins/gogs/info.json @@ -2,7 +2,7 @@ "ps": "Gogs是一款极易搭建的自助Git服务", "name": "gogs", "title": "Gogs", - "versions": ["0.11.86","0.12.9"], + "versions": ["0.11.86","0.12.9","0.13.0"], "tip": "soft", "checks": "server/gogs", "path":"server/gogs", diff --git a/plugins/gogs/install.sh b/plugins/gogs/install.sh index 371267366..23da6e351 100755 --- a/plugins/gogs/install.sh +++ b/plugins/gogs/install.sh @@ -9,6 +9,10 @@ serverPath=$(dirname "$rootPath") install_tmp=${rootPath}/tmp/mw_install.pl +if [ -f ${rootPath}/bin/activate ];then + source ${rootPath}/bin/activate +fi + GOGS_DOWNLOAD='https://dl.gogs.io' diff --git a/plugins/memcached/info.json b/plugins/memcached/info.json index 5c03d1db8..b0a9b6463 100755 --- a/plugins/memcached/info.json +++ b/plugins/memcached/info.json @@ -5,7 +5,7 @@ "title": "Memcached", "shell": "install.sh", "versions":["1.6"], - "updates":["1.6.15"], + "updates":["1.6.21"], "tip": "soft", "checks": "server/memcached", "path":"server/memcached", diff --git a/plugins/mysql-apt/index.py b/plugins/mysql-apt/index.py index 8deeae18f..ece366263 100755 --- a/plugins/mysql-apt/index.py +++ b/plugins/mysql-apt/index.py @@ -1596,6 +1596,15 @@ def setDbMasterAccess(): return mw.returnJson(True, '设置成功!') +def resetMaster(version=''): + pdb = pMysqlDb() + r = pdb.execute('reset master') + isError = isSqlError(r) + if isError != None: + return isError + return mw.returnJson(True, '重置成功!') + + def getMasterDbList(version=''): try: args = getArgs() @@ -2850,6 +2859,8 @@ if __name__ == "__main__": print(getDbrunMode(version)) elif func == 'set_dbrun_mode': print(setDbrunMode(version)) + elif func == 'reset_master': + print(resetMaster(version)) elif func == 'get_masterdb_list': print(getMasterDbList(version)) elif func == 'get_master_status': diff --git a/plugins/mysql-apt/js/mysql-apt.js b/plugins/mysql-apt/js/mysql-apt.js index f7c9c50a1..452458dfd 100755 --- a/plugins/mysql-apt/js/mysql-apt.js +++ b/plugins/mysql-apt/js/mysql-apt.js @@ -1601,6 +1601,14 @@ function setDbMasterAccess(username){ }); } +function resetMaster(){ + myPost('reset_master', '', function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + },{icon: rdata.status ? 1 : 2}); + },'正在执行重置master命令[reset master]'); +} + function getMasterRepSlaveList(){ var _data = {}; if (typeof(page) =='undefined'){ @@ -2446,6 +2454,7 @@ function masterOrSlaveConf(version=''){

\ Master[主]配置\ \ + \

\
\ \ diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index fda6c4788..7e2798e97 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -1577,6 +1577,15 @@ def setDbMasterAccess(): return mw.returnJson(True, '设置成功!') +def resetMaster(version=''): + pdb = pMysqlDb() + r = pdb.execute('reset master') + isError = isSqlError(r) + if isError != None: + return isError + return mw.returnJson(True, '重置成功!') + + def getMasterDbList(version=''): try: args = getArgs() @@ -2827,6 +2836,8 @@ if __name__ == "__main__": print(getDbrunMode(version)) elif func == 'set_dbrun_mode': print(setDbrunMode(version)) + elif func == 'reset_master': + print(resetMaster(version)) elif func == 'get_masterdb_list': print(getMasterDbList(version)) elif func == 'get_master_status': diff --git a/plugins/mysql-yum/js/mysql-yum.js b/plugins/mysql-yum/js/mysql-yum.js index d215d27b2..fe7ca62e6 100755 --- a/plugins/mysql-yum/js/mysql-yum.js +++ b/plugins/mysql-yum/js/mysql-yum.js @@ -1601,6 +1601,14 @@ function setDbMasterAccess(username){ }); } +function resetMaster(){ + myPost('reset_master', '', function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + },{icon: rdata.status ? 1 : 2}); + },'正在执行重置master命令[reset master]'); +} + function getMasterRepSlaveList(){ var _data = {}; if (typeof(page) =='undefined'){ @@ -2446,6 +2454,7 @@ function masterOrSlaveConf(version=''){

\ Master[主]配置\ \ + \

\
\ \ diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 092598e91..610ee237d 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -1811,6 +1811,15 @@ def setDbMasterAccess(): return mw.returnJson(True, '设置成功!') +def resetMaster(version=''): + pdb = pMysqlDb() + r = pdb.execute('reset master') + isError = isSqlError(r) + if isError != None: + return isError + return mw.returnJson(True, '重置成功!') + + def getMasterDbList(version=''): try: args = getArgs() @@ -3073,6 +3082,8 @@ if __name__ == "__main__": print(getDbrunMode(version)) elif func == 'set_dbrun_mode': print(setDbrunMode(version)) + elif func == 'reset_master': + print(resetMaster(version)) elif func == 'get_masterdb_list': print(getMasterDbList(version)) elif func == 'get_master_status': diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index 402993a44..6754df892 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -1601,6 +1601,15 @@ function setDbMasterAccess(username){ }); } + +function resetMaster(){ + myPost('reset_master', '', function(data){ + var rdata = $.parseJSON(data.data); + showMsg(rdata.msg,function(){ + },{icon: rdata.status ? 1 : 2}); + },'正在执行重置master命令[reset master]'); +} + function getMasterRepSlaveList(){ var _data = {}; if (typeof(page) =='undefined'){ @@ -2446,6 +2455,7 @@ function masterOrSlaveConf(version=''){

\ Master[主]配置\ \ + \

\
\ \ diff --git a/plugins/openresty/install.sh b/plugins/openresty/install.sh index a16b9ee05..86bb88cd1 100755 --- a/plugins/openresty/install.sh +++ b/plugins/openresty/install.sh @@ -72,7 +72,7 @@ Install_openresty() # Last Download Method if [ ! -f ${openrestyDir}/openresty-${VERSION}.tar.gz ];then - wget --no-check-certificate -O ${openrestyDir}/openresty-${VERSION}.tar.gz https://dl.midoks.me/soft/openresty/openresty-${VERSION}.tar.gz -T 3 + wget --no-check-certificate -O ${openrestyDir}/openresty-${VERSION}.tar.gz http://dl.midoks.me/soft/openresty/openresty-${VERSION}.tar.gz -T 3 fi cd ${openrestyDir} && tar -zxvf openresty-${VERSION}.tar.gz diff --git a/plugins/php/lib/icu.sh b/plugins/php/lib/icu.sh index 42802fdf2..f988c4c88 100644 --- a/plugins/php/lib/icu.sh +++ b/plugins/php/lib/icu.sh @@ -13,9 +13,9 @@ rootPath=$(dirname "$rootPath") SERVER_ROOT=$rootPath/lib SOURCE_ROOT=$rootPath/source/lib -cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/plugins/php/lib/libiconv.sh b/plugins/php/lib/libiconv.sh index b5316b310..ce08d77f7 100644 --- a/plugins/php/lib/libiconv.sh +++ b/plugins/php/lib/libiconv.sh @@ -13,9 +13,9 @@ rootPath=$(dirname "$rootPath") SERVER_ROOT=$rootPath/lib SOURCE_ROOT=$rootPath/source/lib -cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/plugins/php/lib/libzip.sh b/plugins/php/lib/libzip.sh index 688d4f99b..fca760d12 100644 --- a/plugins/php/lib/libzip.sh +++ b/plugins/php/lib/libzip.sh @@ -14,9 +14,9 @@ SERVER_ROOT=$rootPath/lib SOURCE_ROOT=$rootPath/source/lib -cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/plugins/php/lib/oniguruma.sh b/plugins/php/lib/oniguruma.sh index 3c04b4c08..100d2d109 100644 --- a/plugins/php/lib/oniguruma.sh +++ b/plugins/php/lib/oniguruma.sh @@ -13,9 +13,9 @@ rootPath=$(dirname "$rootPath") SERVER_ROOT=$rootPath/lib SOURCE_ROOT=$rootPath/source/lib -cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/plugins/php/lib/openssl_10.sh b/plugins/php/lib/openssl_10.sh index d39a6b46e..49918c0f6 100644 --- a/plugins/php/lib/openssl_10.sh +++ b/plugins/php/lib/openssl_10.sh @@ -13,9 +13,9 @@ rootPath=$(dirname "$rootPath") SERVER_ROOT=$rootPath/lib SOURCE_ROOT=$rootPath/source/lib -cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/plugins/php/lib/zlib.sh b/plugins/php/lib/zlib.sh index f248192b5..e3b45c1cd 100644 --- a/plugins/php/lib/zlib.sh +++ b/plugins/php/lib/zlib.sh @@ -13,9 +13,9 @@ rootPath=$(dirname "$rootPath") SERVER_ROOT=$rootPath/lib SOURCE_ROOT=$rootPath/source/lib -cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/plugins/php/versions/73/install.sh b/plugins/php/versions/73/install.sh index 088c8134a..53ee09ff0 100755 --- a/plugins/php/versions/73/install.sh +++ b/plugins/php/versions/73/install.sh @@ -33,7 +33,7 @@ if [ ! -d $sourcePath/php/php${PHP_VER} ];then # 中国优化安装 cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") LOCAL_ADDR=common - if [ ! -z "$cn" ];then + if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then LOCAL_ADDR=cn fi @@ -70,7 +70,7 @@ fi ZIP_OPTION='--enable-zip' libzip_version=`pkg-config libzip --modversion` -if version_lt "$libzip_version" "0.11.0" ;then +if [ "$?" != "0" ] || version_lt "$libzip_version" "0.11.0" ;then cd ${rootPath}/plugins/php/lib && /bin/bash libzip.sh export PKG_CONFIG_PATH=$serverPath/lib/libzip/lib/pkgconfig ZIP_OPTION="--with-libzip=$serverPath/lib/libzip" diff --git a/plugins/php/versions/common/zip.sh b/plugins/php/versions/common/zip.sh index 828235592..63bee1116 100755 --- a/plugins/php/versions/common/zip.sh +++ b/plugins/php/versions/common/zip.sh @@ -40,6 +40,10 @@ else BAK='' fi +if [ ! -d $serverPath/lib/libzip ];then + cd ${rootPath}/plugins/php/lib && /bin/bash libzip.sh +fi + export PKG_CONFIG_PATH=/www/server/lib/libzip/lib/pkgconfig Install_lib() @@ -51,6 +55,7 @@ Install_lib() return fi + if [ ! -f "$extFile" ];then if [ ! -d $sourcePath/php${version}/ext ];then diff --git a/plugins/tgbot/startup/extend/push_notice_msg.py b/plugins/tgbot/startup/extend/push_notice_msg.py index 459d2ccb6..bc72cc24c 100644 --- a/plugins/tgbot/startup/extend/push_notice_msg.py +++ b/plugins/tgbot/startup/extend/push_notice_msg.py @@ -52,9 +52,9 @@ def send_msg(bot, tag='ad', trigger_time=300): # https://t.me/gjgzs2022 | 22/m # 高价收量 👑 集团收量 ❤️ 流量变现/支付宝代付 ❤️ 微信代付/实名认证/过人脸🕵️‍♀️各种账号处理✅ | 28/m - # https://zhaoziyuan.la/ | web | 15/m | 2m | next,9/15 + # https://zhaoziyuan.pw/ | web | 15/m | 2m | next,9/15 | @baleite # 腾云机场 |9/m - # 🚀鲲鹏VPN | 13/m + # 🚀鲲鹏VPN | 13/m | next,10/10 keyboard = [ [ types.InlineKeyboardButton( diff --git a/scripts/install.sh b/scripts/install.sh index e3c8077ee..c1635a95a 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -28,6 +28,9 @@ elif grep -Eqi "openSUSE" /etc/*-release; then zypper install cron wget curl zip unzip elif grep -Eqi "FreeBSD" /etc/*-release; then OSNAME='freebsd' +elif grep -Eq "EulerOS" /etc/*-release || grep -Eq "openEuler" /etc/*-release; then + OSNAME='euler' + yum install -y wget curl zip unzip tar crontabs elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then OSNAME='rhel' yum install -y wget curl zip unzip tar crontabs @@ -64,10 +67,10 @@ fi # HTTP_PREFIX="https://ghproxy.com/" # fi -cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" LOCAL_ADDR=common -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then LOCAL_ADDR=cn HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/scripts/install/centos.sh b/scripts/install/centos.sh index 92c73b967..84c7e076e 100755 --- a/scripts/install/centos.sh +++ b/scripts/install/centos.sh @@ -13,6 +13,13 @@ VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk - setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config +SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'` +if [ "$SSH_PORT" == "" ];then + SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1` + SSH_PORT=${SSH_PORT_LINE/"Port "/""} +fi +echo "SSH PORT:${SSH_PORT}" + yum install -y wget lsof crontabs yum install -y python3-devel yum install -y python3-pip @@ -25,32 +32,37 @@ yum install -y mysql-devel yum install -y expect -if [ -f /usr/sbin/iptables ];then +# if [ -f /usr/sbin/iptables ];then - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT - iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT - service iptables save +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT +# service iptables save - iptables_status=`service iptables status | grep 'not running'` - if [ "${iptables_status}" == '' ];then - service iptables restart - fi +# iptables_status=`service iptables status | grep 'not running'` +# if [ "${iptables_status}" == '' ];then +# service iptables restart +# fi - #安装时不开启 - service iptables stop -fi +# #安装时不开启 +# service iptables stop +# fi -if [ ! -f /usr/sbin/iptables ];then +if [ ! -f /usr/sbin/firewalld ];then yum install firewalld -y systemctl enable firewalld #取消服务锁定 systemctl unmask firewalld systemctl start firewalld - firewall-cmd --permanent --zone=public --add-port=22/tcp + if [ "$SSH_PORT" != "" ];then + firewall-cmd --permanent --zone=public --add-port=${SSH_PORT}/tcp + else + firewall-cmd --permanent --zone=public --add-port=22/tcp + fi + 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 diff --git a/scripts/install/debian.sh b/scripts/install/debian.sh index 1785d824c..d7dc4eae6 100644 --- a/scripts/install/debian.sh +++ b/scripts/install/debian.sh @@ -17,6 +17,11 @@ if [ "$__GET_BIT" == "32" ];then apt install -y rustc fi +if [ "$VERSION_ID" == "10" ];then + apt install -y rustc +fi + + # synchronize time first apt-get install ntpdate -y NTPHOST='time.nist.gov' diff --git a/scripts/install/euler.sh b/scripts/install/euler.sh new file mode 100755 index 000000000..f535ab5df --- /dev/null +++ b/scripts/install/euler.sh @@ -0,0 +1,152 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH +LANG=en_US.UTF-8 + +if [ ! -f /usr/bin/applydeltarpm ];then + yum -y provides '*/applydeltarpm' + yum -y install deltarpm +fi + +VERSION_ID=`cat /etc/*-release | grep VERSION_ID | awk -F = '{print $2}' | awk -F "\"" '{print $2}'` + +setenforce 0 +sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config + +SSH_PORT=`netstat -ntpl|grep sshd|grep -v grep | sed -n "1,1p" | awk '{print $4}' | awk -F : '{print $2}'` +if [ "$SSH_PORT" == "" ];then + SSH_PORT_LINE=`cat /etc/ssh/sshd_config | grep "Port \d*" | tail -1` + SSH_PORT=${SSH_PORT_LINE/"Port "/""} +fi +echo "SSH PORT:${SSH_PORT}" + +yum install -y wget lsof crontabs +yum install -y python3-devel +yum install -y python3-pip +yum install -y python-devel +yum install -y vixie-cron +yum install -y curl-devel +yum install -y libmcrypt +yum install -y libmcrypt-devel +yum install -y mysql-devel +yum install -y expect + + +# if [ -f /usr/sbin/iptables ];then + +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT +# iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 888 -j ACCEPT +# service iptables save + +# iptables_status=`service iptables status | grep 'not running'` +# if [ "${iptables_status}" == '' ];then +# service iptables restart +# fi + +# #安装时不开启 +# service iptables stop +# fi + +if [ ! -f /usr/sbin/firewalld ];then + yum install firewalld -y + systemctl enable firewalld + #取消服务锁定 + systemctl unmask firewalld + systemctl start firewalld + + if [ "$SSH_PORT" != "" ];then + firewall-cmd --permanent --zone=public --add-port=${SSH_PORT}/tcp + else + firewall-cmd --permanent --zone=public --add-port=22/tcp + fi + + 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 + + + sed -i 's#AllowZoneDrifting=yes#AllowZoneDrifting=no#g' /etc/firewalld/firewalld.conf + firewall-cmd --reload + #安装时不开启 + systemctl stop firewalld +fi + +yum groupinstall -y "Development Tools" +yum install -y epel-release + +yum install -y oniguruma oniguruma-devel +#centos8 stream | use dnf +if [ "$?" != "0" ];then + yum install -y dnf dnf-plugins-core + dnf config-manager --set-enabled powertools + yum install -y oniguruma oniguruma-devel + dnf upgrade -y libmodulemd +fi + + +yum install -y libtirpc libtirpc-devel +yum install -y rpcgen +yum install -y openldap openldap-devel +yum install -y bison re2c +yum install -y cmake3 +yum install -y autoconf +yum install -y make cmake gcc gcc-c++ + +yum install -y libmemcached libmemcached-devel +yum install -y curl curl-devel +yum install -y zlib zlib-devel +yum install -y libzip libzip-devel +yum install -y pcre pcre-devel +yum install -y icu libicu-devel +yum install -y freetype freetype-devel +yum install -y openssl openssl-devel +yum install -y libxml2 libxml2-devel +yum install -y graphviz +yum install -y sqlite-devel +yum install -y oniguruma oniguruma-devel +yum install -y ImageMagick ImageMagick-devel + + +yum install -y libzstd-devel +yum install -y libevent libevent-devel unzip zip +# yum install -y python-imaging +yum install -y libicu-devel bzip2-devel pcre pcre-devel + +yum install -y gd gd-devel +yum install -y libjpeg-devel libpng-devel libwebp libwebp-devel + +yum install -y net-tools +yum install -y ncurses-devel +yum install -y libXpm-devel +yum install -y libargon2-devel + + +for yumPack in flex file libtool libtool-libs kernel-devel patch wget glib2 glib2-devel tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel libidn libidn-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel libcap diffutils ca-certificates net-tools psmisc git-core c-ares-devel libicu-devel libxslt libxslt-devel zip unzip glibc.i686 libstdc++.so.6 cairo-devel ncurses-devel libaio-devel perl perl-devel perl-Data-Dumper expat-devel readline-devel; +do yum -y install $yumPack;done + + +if [ "$VERSION_ID" -eq "8" ];then + dnf upgrade -y libmodulemd +fi + +if [ "$VERSION_ID" -eq "9" ];then + yum install -y patchelf + dnf --enablerepo=crb install -y libtirpc-devel + dnf --enablerepo=crb install -y libmemcached libmemcached-devel + dnf --enablerepo=crb install -y libtool libtool-libs + dnf --enablerepo=crb install -y gnutls-devel + dnf --enablerepo=crb install -y mysql-devel + + dnf --enablerepo=crb install -y libvpx-devel libXpm-devel libwebp libwebp-devel + dnf --enablerepo=crb install -y libjpeg-devel libpng-devel + dnf --enablerepo=crb install -y oniguruma oniguruma-devel + dnf --enablerepo=crb install -y libzip libzip-devel + # yum remove -y chardet +fi + + +cd /www/server/mdserver-web/scripts && bash lib.sh +chmod 755 /www/server/mdserver-web/data + diff --git a/scripts/install_dev.sh b/scripts/install_dev.sh index 04a99033e..c46f17b5e 100755 --- a/scripts/install_dev.sh +++ b/scripts/install_dev.sh @@ -32,6 +32,9 @@ elif grep -Eq "openSUSE" /etc/*-release; then zypper refresh elif grep -Eq "FreeBSD" /etc/*-release; then OSNAME='freebsd' +elif grep -Eq "EulerOS" /etc/*-release || grep -Eq "openEuler" /etc/*-release; then + OSNAME='euler' + yum install -y wget curl zip unzip tar crontabs elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then OSNAME='rhel' yum install -y wget zip unzip @@ -68,10 +71,10 @@ fi # HTTP_PREFIX="https://ghproxy.com/" # fi -cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" LOCAL_ADDR=common -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then LOCAL_ADDR=cn HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/scripts/lib.sh b/scripts/lib.sh index b9dd41c5b..4224a01a4 100755 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -64,11 +64,10 @@ fi # LOCAL_ADDR=cn # HTTP_PREFIX="https://ghproxy.com/" # fi - -cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" LOCAL_ADDR=common -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then LOCAL_ADDR=cn HTTP_PREFIX="https://ghproxy.com/" fi diff --git a/scripts/update.sh b/scripts/update.sh index bd20683a7..2d646237d 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -25,6 +25,8 @@ if [ ${_os} == "Darwin" ]; then elif grep -Eqi "openSUSE" /etc/*-release; then OSNAME='opensuse' zypper refresh +elif grep -Eq "EulerOS" /etc/*-release || grep -Eq "openEuler" /etc/*-release; then + OSNAME='euler' elif grep -Eqi "FreeBSD" /etc/*-release; then OSNAME='freebsd' elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then @@ -55,15 +57,14 @@ else fi -# cn=$(curl -fsSL -m 10 http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" LOCAL_ADDR=common -ping -c 1 github.com > /dev/null 2>&1 -if [ "$?" != "0" ];then +cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then LOCAL_ADDR=cn - HTTP_PREFIX="https://ghproxy.com/" + HTTP_PREFIX="https://ghproxy.com/" fi - +echo "local:${LOCAL_ADDR}" CP_CMD=/usr/bin/cp if [ -f /bin/cp ];then diff --git a/scripts/update/euler.sh b/scripts/update/euler.sh new file mode 100755 index 000000000..746c6dd79 --- /dev/null +++ b/scripts/update/euler.sh @@ -0,0 +1,58 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH +export LANG=en_US.UTF-8 + + +if [ -f /etc/motd ];then + echo "welcome to mdserver-web panel" > /etc/motd +fi + +sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config + +yum install -y curl-devel libmcrypt libmcrypt-devel python3-devel + + +cd /www/server/mdserver-web/scripts && bash lib.sh +chmod 755 /www/server/mdserver-web/data + +if [ -f /etc/rc.d/init.d/mw ];then + bash /etc/rc.d/init.d/mw stop && rm -rf /www/server/mdserver-web/scripts/init.d/mw && rm -rf /etc/rc.d/init.d/mw +fi + +echo -e "stop mw" +isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'` + +port=7200 +if [ -f /www/server/mdserver-web/data/port.pl ]; then + port=$(cat /www/server/mdserver-web/data/port.pl) +fi + +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 && bash cli.sh start +isStart=`ps -ef|grep 'gunicorn -c setting.py app:app' |grep -v grep|awk '{print $2}'` +n=0 +while [[ ! -f /etc/rc.d/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 +echo -e "start mw success" \ No newline at end of file diff --git a/scripts/update_dev.sh b/scripts/update_dev.sh index 2ba251abc..be166efb2 100755 --- a/scripts/update_dev.sh +++ b/scripts/update_dev.sh @@ -25,6 +25,8 @@ if [ ${_os} == "Darwin" ]; then elif grep -Eqi "openSUSE" /etc/*-release; then OSNAME='opensuse' zypper refresh +elif grep -Eq "EulerOS" /etc/*-release || grep -Eq "openEuler" /etc/*-release; then + OSNAME='euler' elif grep -Eqi "FreeBSD" /etc/*-release; then OSNAME='freebsd' elif grep -Eqi "CentOS" /etc/issue || grep -Eqi "CentOS" /etc/*-release; then @@ -61,15 +63,15 @@ fi # LOCAL_ADDR=cn # HTTP_PREFIX="https://ghproxy.com/" # fi - -cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") HTTP_PREFIX="https://" LOCAL_ADDR=common -if [ ! -z "$cn" ];then +cn=$(curl -fsSL -m 10 -s http://ipinfo.io/json | grep "\"country\": \"CN\"") +if [ ! -z "$cn" ] || [ "$?" != "0" ] ;then LOCAL_ADDR=cn HTTP_PREFIX="https://ghproxy.com/" fi +echo "local:${LOCAL_ADDR}" CP_CMD=/usr/bin/cp if [ -f /bin/cp ];then