mirror of
https://github.com/flucont/btcloud.git
synced 2025-11-28 01:06:01 +08:00
update
This commit is contained in:
@@ -179,22 +179,27 @@ class CleanViteJs extends Command
|
||||
$flag = true;
|
||||
}
|
||||
|
||||
if(strpos($file, '"商用SSL证书"')!==false){ //site-ssl
|
||||
$code = $this->getExtendFunction($file, '"商用SSL证书"', '{', '}');
|
||||
$file = str_replace($code, '', $file);
|
||||
$code = $this->getExtendFunction($file, '"测试证书"', '{', '}');
|
||||
if(strpos($file, 'label:"商用SSL证书"')!==false){ //site-ssl
|
||||
$code = $this->getExtendFunction($file, 'label:"商用SSL证书"', '{', '}');
|
||||
$file = str_replace($code, '', $file);
|
||||
$code = $this->getExtendFunction($file, 'label:"测试证书"', '{', '}');
|
||||
if($code){
|
||||
$file = str_replace($code, '', $file);
|
||||
}
|
||||
$code = $this->getExtendFunction($file, 'label:"宝塔证书"', '{', '}');
|
||||
if($code){
|
||||
$file = str_replace($code, '', $file);
|
||||
}
|
||||
$code = $this->getExtendCode($file, '"购买商业证书"', 2);
|
||||
if($code){
|
||||
$code2 = str_replace('"busSslList"', '"letsEncryptList"', $code);
|
||||
$code2 = str_replace($this->getExtendFunction($code, '"购买商业证书"'), '', $code2);
|
||||
$file = str_replace($code, $code2, $file);
|
||||
}
|
||||
$file = preg_replace('!(\w+)\("sslCertificate"\)!', '$1("EncryptCertificate")', $file);
|
||||
$flag = true;
|
||||
}
|
||||
if(strpos($file, '"busSslList"')!==false && strpos($filepath, '/useStore')){ //site-ssl
|
||||
$file = str_replace('"busSslList"', '"currentCertInfo"', $file);
|
||||
if(strpos($file, '"btSslList"')!==false && strpos($filepath, '/useStore')){ //site-ssl
|
||||
$file = str_replace('"btSslList"', '"currentCertInfo"', $file);
|
||||
$flag = true;
|
||||
}
|
||||
|
||||
@@ -235,6 +240,12 @@ class CleanViteJs extends Command
|
||||
$flag = true;
|
||||
}
|
||||
|
||||
if(strpos($file, 'path:"register"')!==false){ //domain
|
||||
$code = $this->getExtendCode($file, 'path:"register"');
|
||||
$file = str_replace($code.',', '', $file);
|
||||
$flag = true;
|
||||
}
|
||||
|
||||
for($i=0;$i<5;$i++){
|
||||
$code = $this->getExtendCode($file, ',"需求反馈"', 1, '[', ']');
|
||||
if($code){
|
||||
@@ -253,7 +264,7 @@ class CleanViteJs extends Command
|
||||
$flag = true;
|
||||
}
|
||||
$code = $this->getExtendCode($file, '(" 需求反馈 ",-1)', 1, '[', ']');
|
||||
if($code && strpos($filepath, 'vue_vue_type_') === false){
|
||||
if($code){
|
||||
$file = str_replace($code, '[]', $file);
|
||||
$flag = true;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
Linux_Version="11.1.0"
|
||||
Linux_Version="11.2.0"
|
||||
Windows_Version="8.2.2"
|
||||
Aapanel_Version="7.0.25"
|
||||
Btm_Version="2.3.2"
|
||||
Btm_Version="2.3.3"
|
||||
|
||||
FILES=(
|
||||
public/install/src/panel6.zip
|
||||
|
||||
@@ -75,7 +75,7 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:340px;
|
||||
<script src="{$cdnpublic}bootstrap-table/1.19.1/extensions/page-jump-to/bootstrap-table-page-jump-to.min.js"></script>
|
||||
<script src="/static/js/custom.js"></script>
|
||||
<script>
|
||||
|
||||
var skip_plugins = ['firewall', 'php_filter', 'enterprise_backup', 'tamper_drive', 'KylinOperatingSystem', 'KingdeeApusicDistributedCache', 'BorlandCacheServer', 'GBase8s', 'KingdeeApusicLoadBalancer', 'BorlandWebServer'];
|
||||
function download_version(name, version, status){
|
||||
if(status == true){
|
||||
var confirm = layer.confirm('是否确定重新下载'+version+'版本插件包?', {
|
||||
@@ -159,7 +159,7 @@ function download_item(){
|
||||
return;
|
||||
}
|
||||
var plugin = $.preDownload[0];
|
||||
if(plugin.name == 'firewall' || plugin.name == 'php_filter' || plugin.name == 'enterprise_backup' || plugin.name == 'tamper_drive'){
|
||||
if(skip_plugins.indexOf(plugin.name) != -1){
|
||||
$.preDownload.shift();
|
||||
download_item();
|
||||
return;
|
||||
|
||||
@@ -430,6 +430,9 @@ EOF
|
||||
if [ -f $monitor_path/sqlite_server/PluginLoader.so ]; then
|
||||
rm -f $monitor_path/sqlite_server/PluginLoader.so
|
||||
fi
|
||||
if [ -f $monitor_path/hook_import/PluginLoader.so ]; then
|
||||
rm -f $monitor_path/hook_import/PluginLoader.so
|
||||
fi
|
||||
}
|
||||
|
||||
Start_Monitor(){
|
||||
|
||||
@@ -237,6 +237,23 @@ Get_Pack_Manager(){
|
||||
}
|
||||
Set_Repo_Url(){
|
||||
if [ "${PM}"="apt-get" ];then
|
||||
|
||||
if [ -f "/etc/os-release" ];then
|
||||
. /etc/os-release
|
||||
OS_V=${VERSION_ID%%.*}
|
||||
if [ "${ID}" == "debian" ] && [ "${OS_V}" = "10" ];then
|
||||
apt-get update -y
|
||||
if [ "$?" != "0" ];then
|
||||
echo "deb https://mirrors.aliyun.com/debian-archive/debian/ buster main contrib non-free" > /etc/apt/sources.list
|
||||
echo "deb-src https://mirrors.aliyun.com/debian-archive/debian/ buster main contrib non-free" >> /etc/apt/sources.list
|
||||
echo "deb https://mirrors.aliyun.com/debian-archive/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list
|
||||
echo "deb-src https://mirrors.aliyun.com/debian-archive/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list
|
||||
apt-get update -y
|
||||
fi
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
|
||||
Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
|
||||
VELINUX_CHECK=$(grep veLinux /etc/os-release)
|
||||
@@ -261,7 +278,7 @@ Set_Repo_Url(){
|
||||
NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $1}')
|
||||
TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $2 * 1000}'|cut -d '.' -f 1)
|
||||
|
||||
if { [ "${NODE_STATUS}" != "200" ] && [ "${NODE_STATUS}" != "301" ]; } || [ "${TIME_TOTAL}" -ge "150" ] || [ "${SOURCE_URL_CHECK}" ]; then
|
||||
if { [ "${NODE_STATUS}" != "200" ] && [ "${NODE_STATUS}" != "301" ]; } || [ "${TIME_TOTAL}" -ge "300" ] || [ "${SOURCE_URL_CHECK}" ]; then
|
||||
\cp -rpa /etc/apt/sources.list /etc/apt/sources.list.btbackup
|
||||
apt_lists=(mirrors.cloud.tencent.com mirrors.163.com repo.huaweicloud.com mirrors.tuna.tsinghua.edu.cn mirrors.aliyun.com mirrors.ustc.edu.cn )
|
||||
for list in ${apt_lists[@]};
|
||||
@@ -474,6 +491,13 @@ get_node_url(){
|
||||
CN_CHECK=$(curl -sS --connect-timeout 10 -m 10 https://api.bt.cn/api/isCN)
|
||||
if [ "${CN_CHECK}" == "True" ];then
|
||||
nodes=(https://dg2.bt.cn https://download.bt.cn https://ctcc1-node.bt.cn https://cmcc1-node.bt.cn https://ctcc2-node.bt.cn https://hk1-node.bt.cn);
|
||||
else
|
||||
PING6_CHECK=$(ping6 -c 2 -W 2 download.bt.cn &> /dev/null && echo "yes" || echo "no")
|
||||
if [ "${PING6_CHECK}" == "yes" ];then
|
||||
nodes=(https://dg2.bt.cn https://download.bt.cn https://cf1-node.aapanel.com);
|
||||
else
|
||||
nodes=(https://cf1-node.aapanel.com https://download.bt.cn https://na1-node.bt.cn https://jp1-node.bt.cn https://dg2.bt.cn);
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -489,7 +513,11 @@ get_node_url(){
|
||||
touch $tmp_file2
|
||||
for node in ${nodes[@]};
|
||||
do
|
||||
NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/net_test|xargs)
|
||||
if [ "${node}" == "https://cf1-node.aapanel.com" ];then
|
||||
NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/1net_test|xargs)
|
||||
else
|
||||
NODE_CHECK=$(curl --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/net_test|xargs)
|
||||
fi
|
||||
RES=$(echo ${NODE_CHECK}|awk '{print $1}')
|
||||
NODE_STATUS=$(echo ${NODE_CHECK}|awk '{print $2}')
|
||||
TIME_TOTAL=$(echo ${NODE_CHECK}|awk '{print $3 * 1000 - 500 }'|cut -d '.' -f 1)
|
||||
@@ -603,7 +631,7 @@ Install_RPM_Pack(){
|
||||
|
||||
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
|
||||
#yum remove -y python-requests python3-requests python-greenlet python3-greenlet
|
||||
yumPacks="libcurl-devel wget tar gcc make zip unzip openssl openssl-devel gcc libxml2 libxml2-devel libxslt* zlib zlib-devel libjpeg-devel libpng-devel libwebp libwebp-devel freetype freetype-devel lsof pcre pcre-devel vixie-cron crontabs icu libicu-devel c-ares libffi-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel qrencode at mariadb rsyslog net-tools"
|
||||
yumPacks="libcurl-devel wget tar gcc make zip unzip openssl openssl-devel gcc libxml2 libxml2-devel libxslt* zlib zlib-devel libjpeg-devel libpng-devel libwebp libwebp-devel freetype freetype-devel lsof pcre pcre-devel vixie-cron crontabs icu libicu-devel c-ares libffi-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel qrencode at mariadb rsyslog net-tools firewalld"
|
||||
yum install -y ${yumPacks}
|
||||
|
||||
for yumPack in ${yumPacks}
|
||||
@@ -665,7 +693,7 @@ Install_Deb_Pack(){
|
||||
apt-get install curl -y
|
||||
fi
|
||||
|
||||
debPacks="wget curl libcurl4-openssl-dev gcc make zip unzip tar openssl libssl-dev gcc libxml2 libxml2-dev zlib1g zlib1g-dev libjpeg-dev libpng-dev lsof libpcre3 libpcre3-dev cron net-tools swig build-essential libffi-dev libbz2-dev libncurses-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libdb++-dev libpcap-dev xz-utils git qrencode sqlite3 at mariadb-client rsyslog net-tools";
|
||||
debPacks="wget curl libcurl4-openssl-dev gcc make zip unzip tar openssl libssl-dev gcc libxml2 libxml2-dev zlib1g zlib1g-dev libjpeg-dev libpng-dev lsof libpcre3 libpcre3-dev cron net-tools swig build-essential libffi-dev libbz2-dev libncurses-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libdb++-dev libpcap-dev xz-utils git qrencode sqlite3 at mariadb-client rsyslog net-tools ufw";
|
||||
apt-get install -y $debPacks --force-yes
|
||||
|
||||
for debPack in ${debPacks}
|
||||
@@ -709,6 +737,10 @@ Get_Versions(){
|
||||
os_type="el"
|
||||
os_version="9"
|
||||
pyenv_tt="true"
|
||||
elif [ "${ID}" == "alinux" ] && [[ "${OS_V}" =~ ^(4)$ ]];then
|
||||
os_type="alinux"
|
||||
os_version="4"
|
||||
pyenv_tt="true"
|
||||
fi
|
||||
if [ "${pyenv_tt}" ];then
|
||||
return
|
||||
@@ -779,6 +811,15 @@ Get_Versions(){
|
||||
fi
|
||||
}
|
||||
Install_Python_Lib(){
|
||||
|
||||
|
||||
if [ -f "/www/server/panel/pyenv/bin/python3.7" ];then
|
||||
python_file_date=$(date -r /www/server/panel/pyenv/bin/python3.7 +"%Y")
|
||||
if [ "${python_file_date}" -lt "2021" ];then
|
||||
rm -rf /www/server/panel/pyenv
|
||||
fi
|
||||
fi
|
||||
|
||||
curl -Ss --connect-timeout 3 -m 60 $download_Url/install/pip_select.sh|bash
|
||||
pyenv_path="/www/server/panel"
|
||||
if [ -f $pyenv_path/pyenv/bin/python ];then
|
||||
@@ -1073,7 +1114,11 @@ Install_Bt(){
|
||||
echo "${panelPort}" > ${setup_path}/server/panel/data/port.pl
|
||||
wget -O /etc/init.d/bt ${download_Url}/install/src/bt7.init -T 15
|
||||
wget -O /www/server/panel/init.sh ${download_Url}/install/src/bt7.init -T 15
|
||||
wget -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softListtls10.conf
|
||||
if [ -f "/www/server/panel/config/default_soft_list.conf" ];then
|
||||
\cp -rpa /www/server/panel/config/default_soft_list.conf /www/server/panel/data/softList.conf
|
||||
else
|
||||
wget -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softListtls10.conf
|
||||
fi
|
||||
|
||||
rm -rf /www/server/panel/plugin/webssh/
|
||||
rm -f /www/server/panel/class/*.so
|
||||
@@ -1161,8 +1206,12 @@ Set_Bt_Panel(){
|
||||
echo "证书开启成功!"
|
||||
echo "========================================"
|
||||
fi
|
||||
# btpip install Flask-SQLAlchemy==2.5.1 SQLAlchemy==1.3.24
|
||||
/etc/init.d/bt stop
|
||||
sleep 5
|
||||
if [ ! -f "/www/server/panel/data/port.pl" ];then
|
||||
echo "8888" > /www/server/panel/data/port.pl
|
||||
fi
|
||||
/etc/init.d/bt start
|
||||
sleep 5
|
||||
isStart=$(ps aux |grep 'BT-Panel'|grep -v grep|awk '{print $2}')
|
||||
@@ -1189,7 +1238,7 @@ Set_Bt_Panel(){
|
||||
Set_Firewall(){
|
||||
sshPort=$(cat /etc/ssh/sshd_config | grep 'Port '|awk '{print $2}')
|
||||
if [ "${PM}" = "apt-get" ]; then
|
||||
apt-get install -y ufw
|
||||
#apt-get install -y ufw
|
||||
if [ -f "/usr/sbin/ufw" ];then
|
||||
ufw allow 20/tcp
|
||||
ufw allow 21/tcp
|
||||
@@ -1229,7 +1278,7 @@ Set_Firewall(){
|
||||
else
|
||||
AliyunCheck=$(cat /etc/redhat-release|grep "Aliyun Linux")
|
||||
[ "${AliyunCheck}" ] && return
|
||||
yum install firewalld -y
|
||||
#yum install firewalld -y
|
||||
[ "${Centos8Check}" ] && yum reinstall python3-six -y
|
||||
systemctl enable firewalld
|
||||
systemctl start firewalld
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
148
public/install/update/update_prep_script.sh
Normal file
148
public/install/update/update_prep_script.sh
Normal file
@@ -0,0 +1,148 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
# 宝塔面板更新预准备脚本
|
||||
# 功能:在面板更新时,提前准备,避免面板更新失败
|
||||
# 说明:接收两个参数:1.更新的面板版本号 2.更新的版本是否为稳定版 3.执行时机(prepare, after)
|
||||
# prepare: 在下载面板文件之前就运行的内容
|
||||
# after: 在替换文件之后,运行重启之前执行的内容
|
||||
# 支持:CentOS/RHEL、Ubuntu、Debian系统
|
||||
#===============================================================================
|
||||
|
||||
UPDATE_VERSION="" # 版本号, 形如: 11.2.3
|
||||
UPDATE_VER_MAJOR="" # 主版本号 -> 11
|
||||
UPDATE_VER_MINOR="" # 次版本号 -> 2
|
||||
UPDATE_VER_MICRO="" # 小版本号 -> 3
|
||||
IS_STABLE=false # 默认不是稳定版而是正式版本
|
||||
OPPORTUNITY="prepare"
|
||||
|
||||
PANEL_PATH="/www/server/panel"
|
||||
|
||||
# 输出成功信息, 必须输出 "BT-Panel Update Ready" 才证明预处理成功
|
||||
function success() {
|
||||
local message=$1
|
||||
if [ -n "$message" ]; then
|
||||
echo "$message"
|
||||
fi
|
||||
echo "BT-Panel Update Ready"
|
||||
}
|
||||
|
||||
# 获取当前版本号
|
||||
function get_now_version() {
|
||||
local common_file="$PANEL_PATH/class/common.py"
|
||||
if [ ! -f "$common_file" ]; then
|
||||
echo "" # 文件不存在时返回空字符串
|
||||
return 1
|
||||
fi
|
||||
# 形如:g.version = '11.2.0'
|
||||
local version_str=$(grep -E '^\s+g.version\s*=\s*.*$' "$PANEL_PATH/class/common.py" | cut -d "=" -f2 )
|
||||
# 形如:'11.2.0'
|
||||
local version=$(echo "$version_str" | sed -n "s/.*['\"]\(.*\)['\"].*/\1/p" )
|
||||
echo "$version"
|
||||
return 0
|
||||
}
|
||||
|
||||
# 解析参数
|
||||
function parse_arguments() {
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: 请指定接下来的更新版本号"
|
||||
exit 1
|
||||
fi
|
||||
if echo "$1" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
|
||||
:
|
||||
else
|
||||
echo "Error: 请指定正确的版本号"
|
||||
exit 1
|
||||
fi
|
||||
UPDATE_VERSION=$1
|
||||
UPDATE_VER_MAJOR=$(echo $UPDATE_VERSION | cut -d. -f1)
|
||||
UPDATE_VER_MINOR=$(echo $UPDATE_VERSION | cut -d. -f2)
|
||||
UPDATE_VER_MICRO=$(echo $UPDATE_VERSION | cut -d. -f3)
|
||||
case "$2" in
|
||||
1|True|true) # 稳定版
|
||||
IS_STABLE=true
|
||||
;;
|
||||
0|False|false) # 非稳定版
|
||||
IS_STABLE=false
|
||||
;;
|
||||
*)
|
||||
IS_STABLE=false
|
||||
;;
|
||||
esac
|
||||
case "$3" in
|
||||
prepare)
|
||||
OPPORTUNITY="prepare"
|
||||
;;
|
||||
after)
|
||||
OPPORTUNITY="after"
|
||||
;;
|
||||
*)
|
||||
OPPORTUNITY="prepare"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 默认处理,什么都不做
|
||||
function nothing_do() {
|
||||
local version=$1
|
||||
# 输出成功信息
|
||||
success "已完成[BT-Panel-$version]处理"
|
||||
}
|
||||
|
||||
function replace_bt_command() {
|
||||
local init_path="${PANEL_PATH}/init.sh"
|
||||
if [ -f "$init_path" ]; then
|
||||
\cp -a "$init_path" /etc/init.d/bt
|
||||
chmod +x /etc/init.d/bt
|
||||
else
|
||||
echo "Error: $init_path 文件不存在"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function prepare_main() {
|
||||
echo "开始处理预更新..."
|
||||
local now_version=$(get_now_version)
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "当前版本:$now_version, 目标版本:$UPDATE_VERSION"
|
||||
else
|
||||
echo "获取当前版本失败"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$UPDATE_VER_MAJOR.$UPDATE_VER_MINOR.$UPDATE_VER_MICRO" in
|
||||
11.3.*)
|
||||
nothing_do $UPDATE_VERSION
|
||||
;;
|
||||
* )
|
||||
nothing_do $UPDATE_VERSION
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function after_main() {
|
||||
echo "启动预检测..."
|
||||
case "$UPDATE_VER_MAJOR.$UPDATE_VER_MINOR.$UPDATE_VER_MICRO" in
|
||||
11.3.*)
|
||||
replace_bt_command
|
||||
success "已完成[BT-Panel-$UPDATE_VERSION]启动检查处理"
|
||||
;;
|
||||
* )
|
||||
nothing_do $UPDATE_VERSION
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 主函数
|
||||
function main() {
|
||||
if [ "$OPPORTUNITY" = "prepare" ]; then
|
||||
prepare_main
|
||||
elif [ "$OPPORTUNITY" = "after" ]; then
|
||||
after_main
|
||||
fi
|
||||
}
|
||||
|
||||
# 主函数入口
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
parse_arguments $@
|
||||
main
|
||||
fi
|
||||
@@ -281,6 +281,7 @@ echo "==========================================="
|
||||
echo "正在更新面板文件..............."
|
||||
sleep 1
|
||||
echo "更新完成!"
|
||||
echo "如在终端中执行此命令,请手动刷新面板页面"
|
||||
echo "==========================================="
|
||||
|
||||
chattr -i /etc/init.d/bt
|
||||
|
||||
@@ -290,14 +290,14 @@ Install_Python_Lib(){
|
||||
}
|
||||
|
||||
Install_Monitor(){
|
||||
version="1.0.2"
|
||||
version="2.3.0"
|
||||
file_name="bt-monitor"
|
||||
agent_src="bt-monitor.zip"
|
||||
|
||||
cd ~
|
||||
version=`curl -sf ${Btapi_Url}/bt_monitor/latest_version |awk -F '\"version\"' '{print $2}'|awk -F ':' '{print $2}'|awk -F '"' '{print $2}'`
|
||||
if [ -z $version ]; then
|
||||
version="1.0.2"
|
||||
version="2.3.0"
|
||||
fi
|
||||
new_dir="/www/server/new_btmonitor"
|
||||
if [ ! -d "$new_dir" ];then
|
||||
@@ -342,6 +342,9 @@ Install_Monitor(){
|
||||
if [ -f $monitor_path/sqlite_server/PluginLoader.so ]; then
|
||||
rm -f $monitor_path/sqlite_server/PluginLoader.so
|
||||
fi
|
||||
if [ -f $monitor_path/hook_import/PluginLoader.so ]; then
|
||||
rm -f $monitor_path/hook_import/PluginLoader.so
|
||||
fi
|
||||
}
|
||||
|
||||
Service_Add(){
|
||||
|
||||
@@ -91,25 +91,71 @@ install_python(){
|
||||
pyenv_path="/www/server/panel"
|
||||
python_bin=$pyenv_path/pyenv/bin/python
|
||||
if [ -f $pyenv_path/pyenv/bin/python ];then
|
||||
is_err=$($pyenv_path/pyenv/bin/python3.7 -V 2>&1|grep 'Could not find platform')
|
||||
if [ "$is_err" = "" ];then
|
||||
is_ssl=$($python_bin -c "import ssl" 2>&1|grep cannot)
|
||||
$pyenv_path/pyenv/bin/python3.7 -V
|
||||
if [ $? -eq 0 ] && [ -z "${is_ssl}" ];then
|
||||
chmod -R 700 $pyenv_path/pyenv/bin
|
||||
is_package=$($python_bin -m psutil 2>&1|grep package)
|
||||
if [ "$is_package" = "" ];then
|
||||
wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip.txt -T 5
|
||||
wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip-3.7.16.txt -T 15
|
||||
$pyenv_path/pyenv/bin/pip install -U pip
|
||||
$pyenv_path/pyenv/bin/pip install -U setuptools
|
||||
$pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
|
||||
$pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
|
||||
fi
|
||||
source $pyenv_path/pyenv/bin/activate
|
||||
chmod -R 700 $pyenv_path/pyenv/bin
|
||||
return
|
||||
else
|
||||
rm -rf $pyenv_path/pyenv
|
||||
fi
|
||||
fi
|
||||
|
||||
is_loongarch64=$(uname -a|grep loongarch64)
|
||||
if [ "$is_loongarch64" != "" ] && [ -f "/usr/bin/yum" ];then
|
||||
yumPacks="python3-devel python3-pip python3-psutil python3-gevent python3-pyOpenSSL python3-paramiko python3-flask python3-rsa python3-requests python3-six python3-websocket-client"
|
||||
yum install -y ${yumPacks}
|
||||
for yumPack in ${yumPacks}
|
||||
do
|
||||
rpmPack=$(rpm -q ${yumPack})
|
||||
packCheck=$(echo ${rpmPack}|grep not)
|
||||
if [ "${packCheck}" ]; then
|
||||
yum install ${yumPack} -y
|
||||
fi
|
||||
done
|
||||
|
||||
pip3 install -U pip
|
||||
pip3 install Pillow psutil pyinotify pycryptodome upyun oss2 pymysql qrcode qiniu redis pymongo Cython configparser cos-python-sdk-v5 supervisor gevent-websocket pyopenssl
|
||||
pip3 install flask==1.1.4
|
||||
pip3 install Pillow -U
|
||||
|
||||
pyenv_bin=/www/server/panel/pyenv/bin
|
||||
mkdir -p $pyenv_bin
|
||||
ln -sf /usr/local/bin/pip3 $pyenv_bin/pip
|
||||
ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3
|
||||
ln -sf /usr/local/bin/pip3 $pyenv_bin/pip3.7
|
||||
|
||||
if [ -f "/usr/bin/python3.7" ];then
|
||||
ln -sf /usr/bin/python3.7 $pyenv_bin/python
|
||||
ln -sf /usr/bin/python3.7 $pyenv_bin/python3
|
||||
ln -sf /usr/bin/python3.7 $pyenv_bin/python3.7
|
||||
elif [ -f "/usr/bin/python3.6" ]; then
|
||||
ln -sf /usr/bin/python3.6 $pyenv_bin/python
|
||||
ln -sf /usr/bin/python3.6 $pyenv_bin/python3
|
||||
ln -sf /usr/bin/python3.6 $pyenv_bin/python3.7
|
||||
fi
|
||||
|
||||
echo > $pyenv_bin/activate
|
||||
|
||||
return
|
||||
fi
|
||||
|
||||
install_pack
|
||||
py_version="3.7.9"
|
||||
py_version="3.7.16"
|
||||
mkdir -p $pyenv_path
|
||||
echo "True" > /www/disk.pl
|
||||
if [ ! -w /www/disk.pl ];then
|
||||
Red_Error "ERROR: Install python env fielded." "ERROR: /www目录无法写入,请检查目录/用户/磁盘权限!"
|
||||
fi
|
||||
os_type='el'
|
||||
os_version='7'
|
||||
is_export_openssl=0
|
||||
@@ -119,42 +165,48 @@ install_python(){
|
||||
echo "OS: $os_type - $os_version"
|
||||
is_aarch64=$(uname -a|grep aarch64)
|
||||
if [ "$is_aarch64" != "" ];then
|
||||
os_version="aarch64"
|
||||
is64bit="aarch64"
|
||||
fi
|
||||
up_plugin=1
|
||||
|
||||
if [ -f "/www/server/panel/pymake.pl" ];then
|
||||
os_version=""
|
||||
rm -f /www/server/panel/pymake.pl
|
||||
fi
|
||||
|
||||
fi
|
||||
echo "==============================================="
|
||||
echo "正在下载面板运行环境,请稍等..............."
|
||||
echo "==============================================="
|
||||
if [ "${os_version}" != "" ];then
|
||||
pyenv_file="/www/pyenv.tar.gz"
|
||||
wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 10
|
||||
wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 20
|
||||
if [ "$?" != "0" ];then
|
||||
get_node_url $download_Url
|
||||
wget -O $pyenv_file $download_Url/install/pyenv/pyenv-${os_type}${os_version}-x${is64bit}.tar.gz -T 20
|
||||
fi
|
||||
tmp_size=$(du -b $pyenv_file|awk '{print $1}')
|
||||
if [ $tmp_size -lt 703460 ];then
|
||||
rm -f $pyenv_file
|
||||
echo "ERROR: Download python env fielded."
|
||||
else
|
||||
if [ $tmp_size -gt 703460 ];then
|
||||
echo "Install python env..."
|
||||
tar zxvf $pyenv_file -C $pyenv_path/ &> /dev/null
|
||||
tar zxvf $pyenv_file -C $pyenv_path/ > /dev/null
|
||||
chmod -R 700 $pyenv_path/pyenv/bin
|
||||
if [ ! -f $pyenv_path/pyenv/bin/python ];then
|
||||
rm -f $pyenv_file
|
||||
Red_Error "ERROR: Install python env fielded."
|
||||
fi
|
||||
is_err=$($pyenv_path/pyenv/bin/python3.7 -V 2>&1|grep 'Could not find platform')
|
||||
if [ "$is_err" = "" ];then
|
||||
rm -f $pyenv_file
|
||||
ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
|
||||
ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
|
||||
sync_python_lib
|
||||
source $pyenv_path/pyenv/bin/activate
|
||||
return
|
||||
if [ -f $pyenv_path/pyenv/bin/python ];then
|
||||
$pyenv_path/pyenv/bin/python3.7 -V
|
||||
if [ $? -eq 0 ];then
|
||||
rm -f $pyenv_file
|
||||
ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
|
||||
ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
|
||||
source $pyenv_path/pyenv/bin/activate
|
||||
return
|
||||
else
|
||||
rm -f $pyenv_file
|
||||
rm -rf $pyenv_path/pyenv
|
||||
fi
|
||||
else
|
||||
rm -f $pyenv_file
|
||||
rm -rf $pyenv_path/pyenv
|
||||
fi
|
||||
fi
|
||||
rm -f $pyenv_file
|
||||
echo "预编译环境下载失败,开始编译安装Python..."
|
||||
fi
|
||||
if [ -f /usr/local/openssl/lib/libssl.so ];then
|
||||
export LDFLAGS="-L/usr/local/openssl/lib"
|
||||
@@ -166,11 +218,11 @@ install_python(){
|
||||
cd /www
|
||||
python_src='/www/python_src.tar.xz'
|
||||
python_src_path="/www/Python-${py_version}"
|
||||
wget -O $python_src $download_Url/src/Python-${py_version}.tar.xz -T 5
|
||||
wget -O $python_src $download_Url/src/Python-${py_version}.tar.xz -T 15
|
||||
tmp_size=$(du -b $python_src|awk '{print $1}')
|
||||
if [ $tmp_size -lt 10703460 ];then
|
||||
rm -f $python_src
|
||||
Red_Error "ERROR: Download python source code fielded."
|
||||
Red_Error "ERROR: Download python source code fielded." "ERROR: 下载宝塔运行环境失败,请尝试重新安装!"
|
||||
fi
|
||||
tar xvf $python_src
|
||||
rm -f $python_src
|
||||
@@ -180,22 +232,45 @@ install_python(){
|
||||
make install
|
||||
if [ ! -f $pyenv_path/pyenv/bin/python3.7 ];then
|
||||
rm -rf $python_src_path
|
||||
Red_Error "ERROR: Make python env fielded."
|
||||
Red_Error "ERROR: Make python env fielded." "ERROR: 编译宝塔运行环境失败!"
|
||||
fi
|
||||
cd ~
|
||||
rm -rf $python_src_path
|
||||
wget -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -T 5
|
||||
wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip.txt -T 5
|
||||
wget -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/pip-3.7.16.txt -T 5
|
||||
ln -sf $pyenv_path/pyenv/bin/pip3.7 $pyenv_path/pyenv/bin/pip
|
||||
ln -sf $pyenv_path/pyenv/bin/python3.7 $pyenv_path/pyenv/bin/python
|
||||
ln -sf $pyenv_path/pyenv/bin/pip3.7 /usr/bin/btpip
|
||||
ln -sf $pyenv_path/pyenv/bin/python3.7 /usr/bin/btpython
|
||||
chmod -R 700 $pyenv_path/pyenv/bin
|
||||
$pyenv_path/pyenv/bin/pip install -U pip
|
||||
$pyenv_path/pyenv/bin/pip install -U setuptools
|
||||
$pyenv_path/pyenv/bin/pip install -U setuptools==65.5.0
|
||||
$pyenv_path/pyenv/bin/pip install -U wheel==0.34.2
|
||||
$pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.txt
|
||||
sync_python_lib
|
||||
|
||||
wget -O pip-packs.txt $download_Url/install/pyenv/pip-packs.txt
|
||||
echo "正在后台安装pip依赖请稍等.........."
|
||||
PIP_PACKS=$(cat pip-packs.txt)
|
||||
for P_PACK in ${PIP_PACKS};
|
||||
do
|
||||
btpip show ${P_PACK} > /dev/null 2>&1
|
||||
if [ "$?" == "1" ];then
|
||||
btpip install ${P_PACK}
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f pip-packs.txt
|
||||
|
||||
source $pyenv_path/pyenv/bin/activate
|
||||
|
||||
btpip install psutil
|
||||
btpip install gevent
|
||||
|
||||
is_gevent=$($python_bin -m gevent 2>&1|grep -oE package)
|
||||
is_psutil=$($python_bin -m psutil 2>&1|grep -oE package)
|
||||
if [ "${is_gevent}" != "${is_psutil}" ];then
|
||||
Red_Error "ERROR: psutil/gevent install failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
sync_python_lib(){
|
||||
@@ -337,9 +412,29 @@ update_panel(){
|
||||
|
||||
chattr -i /etc/init.d/bt
|
||||
chmod +x /etc/init.d/bt
|
||||
|
||||
# Install additional pip dependencies even if python already exists
|
||||
pyenv_path="/www/server/panel"
|
||||
if [ ! -f "/www/server/panel/pyenv/n.pl" ];then
|
||||
btpip install docxtpl==0.16.7
|
||||
$pyenv_path/pyenv/bin/pip3 install pymongo
|
||||
$pyenv_path/pyenv/bin/pip3 install psycopg2-binary
|
||||
$pyenv_path/pyenv/bin/pip3 install flask -U
|
||||
$pyenv_path/pyenv/bin/pip3 install flask-sock
|
||||
$pyenv_path/pyenv/bin/pip3 install -I gevent
|
||||
btpip install simple-websocket==0.10.0
|
||||
btpip install natsort
|
||||
btpip uninstall enum34 -y
|
||||
btpip install geoip2==4.7.0
|
||||
btpip install brotli
|
||||
btpip install PyMySQL
|
||||
fi
|
||||
btpip install -I pyOpenSSl 2>/dev/null
|
||||
# if [ $up_plugin = 1 ];then
|
||||
# $pyenv_bin/python /www/server/panel/tools.py update_to6
|
||||
# fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
update_start(){
|
||||
|
||||
@@ -42,6 +42,7 @@ Route::group('api', function () {
|
||||
Route::get('/wpanel/get_version', 'api/get_version_win');
|
||||
Route::get('/panel/get_panel_version', 'api/get_panel_version');
|
||||
Route::any('/panel/get_panel_version_v2', 'api/get_panel_version_v2');
|
||||
Route::any('/panel/get_panel_version_v3', 'api/get_panel_version_v2');
|
||||
Route::get('/SetupCount', 'api/setup_count');
|
||||
Route::any('/panel/updateLinux', 'api/check_update');
|
||||
Route::any('/wpanel/updateWindows', 'api/check_update_win');
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
安装包下载链接:http://download.bt.cn/install/src/bt-monitor-版本号.zip
|
||||
|
||||
- 删除core/include/c_loader/PluginLoader.so,sqlite_server/PluginLoader.so,将btmonitor/PluginLoader.py复制到这个文件夹
|
||||
- 删除core/include/c_loader/PluginLoader.so,hook_import/PluginLoader.so,将btmonitor/PluginLoader.py复制到这个文件夹
|
||||
|
||||
- 批量解密源码:执行 php think decrypt all <源码根目录>
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
#coding: utf-8
|
||||
import os,sys,json
|
||||
import core.include.public as public
|
||||
|
||||
#执行模块方法(模块名,方法名,参数)
|
||||
def module_run(module_name, def_name, def_args):
|
||||
if not module_name or not def_name: return public.returnMsg(False,'模块名称和模块方法名称不能为空!')
|
||||
if not path_check(module_name) or not path_check(def_name): return public.returnMsg(False,'模块名或方法名不能包含特殊符号!')
|
||||
if not module_name or not def_name: return returnMsg(False,'模块名称和模块方法名称不能为空!')
|
||||
if not path_check(module_name) or not path_check(def_name): return returnMsg(False,'模块名或方法名不能包含特殊符号!')
|
||||
|
||||
panel_path = public.get_panel_path()
|
||||
panel_path = get_panel_path()
|
||||
filename = "{}/modules/{}Module/{}Module.py".format(panel_path,module_name,module_name)
|
||||
if not os.path.exists(filename):
|
||||
filename = "{}/modules/{}Module/main.py".format(panel_path,module_name)
|
||||
@@ -16,32 +15,32 @@ def module_run(module_name, def_name, def_args):
|
||||
if not os.path.exists(filename):
|
||||
filename = "{}/plugin/{}/{}Plugin.py".format(panel_path,module_name,module_name)
|
||||
if not os.path.exists(filename):
|
||||
return public.returnMsg(False,'指定模块或插件不存在')
|
||||
return returnMsg(False,'指定模块或插件不存在')
|
||||
|
||||
_obj = public.get_script_object(filename)
|
||||
if not _obj: return public.returnMsg(False,'模块加载失败: %s' % module_name)
|
||||
_obj = get_script_object(filename)
|
||||
if not _obj: return returnMsg(False,'模块加载失败: %s' % module_name)
|
||||
if hasattr(_obj, "items") and hasattr(_obj, "setdefault"):
|
||||
return _obj
|
||||
|
||||
class_name = "main"
|
||||
if not hasattr(_obj, class_name):
|
||||
return public.returnMsg(False,'找不到入口类: %s' % class_name)
|
||||
return returnMsg(False,'找不到入口类: %s' % class_name)
|
||||
|
||||
class_obj = getattr(_obj,class_name, None)
|
||||
if not class_obj:
|
||||
return public.returnMsg(False,'获取入口类失败' % module_name)
|
||||
return returnMsg(False,'获取入口类失败' % module_name)
|
||||
|
||||
try:
|
||||
class_func = class_obj()
|
||||
except:
|
||||
return public.returnMsg(False,'模块入口实例化失败' % module_name)
|
||||
return returnMsg(False,'模块入口实例化失败' % module_name)
|
||||
|
||||
if not hasattr(class_func, def_name):
|
||||
return public.returnMsg(False,'在[%s]模块中找不到[%s]方法' % (class_name,def_name))
|
||||
return returnMsg(False,'在[%s]模块中找不到[%s]方法' % (class_name,def_name))
|
||||
|
||||
def_func = getattr(class_func, def_name, None)
|
||||
if not def_func:
|
||||
return public.returnMsg(False,'获取方法失败')
|
||||
return returnMsg(False,'获取方法失败')
|
||||
|
||||
if 'module_get_object' in def_args:
|
||||
return def_func
|
||||
@@ -51,9 +50,49 @@ def module_run(module_name, def_name, def_args):
|
||||
|
||||
#获取指定模块对象(文件全路径)
|
||||
def get_module(filename):
|
||||
if not filename: return public.returnMsg(False,'模块路径不能为空!')
|
||||
if "./" in filename: return public.returnMsg(False,'模块路径不能为相对路径')
|
||||
return public.get_script_object(filename)
|
||||
if not filename: return returnMsg(False,'模块路径不能为空!')
|
||||
if "./" in filename: return returnMsg(False,'模块路径不能为相对路径')
|
||||
return get_script_object(filename)
|
||||
|
||||
def get_panel_path():
|
||||
return '/www/server/bt-monitor'
|
||||
|
||||
def returnMsg(status,msg,args = ()):
|
||||
return {'status':status,'msg':msg}
|
||||
|
||||
def get_script_object(filename):
|
||||
_obj = sys.modules.get(filename,None)
|
||||
if _obj: return _obj
|
||||
from types import ModuleType
|
||||
_obj = sys.modules.setdefault(filename, ModuleType(filename))
|
||||
_code = readFile(filename)
|
||||
_code_object = compile(_code,filename, 'exec')
|
||||
_obj.__file__ = filename
|
||||
_obj.__package__ = ''
|
||||
exec(_code_object, _obj.__dict__)
|
||||
return _obj
|
||||
|
||||
def readFile(filename,mode = 'r'):
|
||||
import os
|
||||
if not os.path.exists(filename): return False
|
||||
fp = None
|
||||
try:
|
||||
fp = open(filename, mode)
|
||||
f_body = fp.read()
|
||||
except Exception as ex:
|
||||
if sys.version_info[0] != 2:
|
||||
try:
|
||||
fp = open(filename, mode,encoding="utf-8")
|
||||
f_body = fp.read()
|
||||
except:
|
||||
fp = open(filename, mode,encoding="GBK")
|
||||
f_body = fp.read()
|
||||
else:
|
||||
return False
|
||||
finally:
|
||||
if fp and not fp.closed:
|
||||
fp.close()
|
||||
return f_body
|
||||
|
||||
#检查路径是否合法
|
||||
def path_check(path):
|
||||
|
||||
217
wiki/files/linux/PluginLoader.py.old
Normal file
217
wiki/files/linux/PluginLoader.py.old
Normal file
@@ -0,0 +1,217 @@
|
||||
#coding: utf-8
|
||||
import public,os,sys,json
|
||||
|
||||
#获取插件列表(0/1)
|
||||
def get_plugin_list(force = 0):
|
||||
api_root_url = 'https://api.bt.cn'
|
||||
api_url = api_root_url+ '/panel/get_plugin_list'
|
||||
cache_file = 'data/plugin_list.json'
|
||||
|
||||
if force==0 and os.path.exists(cache_file):
|
||||
jsonData = public.readFile(cache_file)
|
||||
softList = json.loads(jsonData)
|
||||
else:
|
||||
try:
|
||||
jsonData = public.HttpGet(api_url)
|
||||
except Exception as ex:
|
||||
raise public.error_conn_cloud(str(ex))
|
||||
softList = json.loads(jsonData)
|
||||
if type(softList)!=dict or 'list' not in softList:
|
||||
if type(softList)==str:
|
||||
raise Exception(softList)
|
||||
else:
|
||||
raise Exception('云端插件列表获取失败')
|
||||
public.writeFile(cache_file, jsonData)
|
||||
return softList
|
||||
|
||||
#获取授权状态() 返回:0.免费版 1.专业版 2.企业版 -1.获取失败
|
||||
def get_auth_state():
|
||||
try:
|
||||
softList = get_plugin_list()
|
||||
if softList['ltd'] > -1:
|
||||
return 2
|
||||
elif softList['pro'] > -1:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
except:
|
||||
return -1
|
||||
|
||||
#执行插件方法(插件名,方法名,参数)
|
||||
def plugin_run(plugin_name, def_name, args):
|
||||
if not plugin_name or not def_name: return public.returnMsg(False,'插件名称和插件方法名称不能为空!')
|
||||
if not path_check(plugin_name) or not path_check(def_name): return public.returnMsg(False,'插件名或方法名不能包含特殊符号!')
|
||||
p_path = public.get_plugin_path(plugin_name)
|
||||
if not os.path.exists(p_path + '/index.php') and not os.path.exists(p_path + '/%s_main.py' % plugin_name): return public.returnMsg(False,'插件不存在!')
|
||||
|
||||
is_php = os.path.exists(p_path + '/index.php')
|
||||
if not is_php:
|
||||
public.package_path_append(p_path)
|
||||
plugin_main = __import__(plugin_name + '_main')
|
||||
try:
|
||||
if sys.version_info[0] == 2:
|
||||
reload(plugin_main)
|
||||
else:
|
||||
from imp import reload
|
||||
reload(plugin_main)
|
||||
except:
|
||||
pass
|
||||
plu = eval('plugin_main.' + plugin_name + '_main()')
|
||||
if not hasattr(plu, def_name):
|
||||
return public.returnMsg(False,'在[%s]插件中找不到[%s]方法' % (plugin_name,def_name))
|
||||
|
||||
if 'plugin_get_object' in args and args.plugin_get_object == 1:
|
||||
if not is_php:
|
||||
return getattr(plu, def_name)
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
if not is_php:
|
||||
data = eval('plu.' + def_name + '(args)')
|
||||
else:
|
||||
import panelPHP
|
||||
args.s = def_name
|
||||
args.name = plugin_name
|
||||
data = panelPHP.panelPHP(plugin_name).exec_php_script(args)
|
||||
return data
|
||||
|
||||
#执行模块方法(模块名,方法名,参数)
|
||||
def module_run(mod_name, def_name, args):
|
||||
if not mod_name or not def_name: return public.returnMsg(False,'模块名称和模块方法名称不能为空!')
|
||||
if not path_check(mod_name) or not path_check(def_name): return public.returnMsg(False,'模块名或方法名不能包含特殊符号!')
|
||||
|
||||
if 'model_index' in args:
|
||||
if args.model_index:
|
||||
mod_file = "{}/{}Model/{}Model.py".format(public.get_class_path(),args.model_index,mod_name)
|
||||
else:
|
||||
mod_file = "{}/projectModel/{}Model.py".format(public.get_class_path(),mod_name)
|
||||
else:
|
||||
module_list = get_module_list()
|
||||
for module_dir in module_list:
|
||||
mod_file = "{}/{}/{}Model.py".format(public.get_class_path(),module_dir,mod_name)
|
||||
if os.path.exists(mod_file): break
|
||||
|
||||
if not os.path.exists(mod_file):
|
||||
return public.returnMsg(False,'模块[%s]不存在' % mod_name)
|
||||
|
||||
def_object = public.get_script_object(mod_file)
|
||||
if not def_object: return public.returnMsg(False,'模块[%s]不存在!' % mod_name)
|
||||
try:
|
||||
run_object = getattr(def_object.main(),def_name,None)
|
||||
except:
|
||||
return public.returnMsg(False,'模块入口实例化失败' % mod_name)
|
||||
if not run_object: return public.returnMsg(False,'在[%s]模块中找不到[%s]方法' % (mod_name,def_name))
|
||||
if 'module_get_object' in args and args.module_get_object == 1:
|
||||
return run_object
|
||||
result = run_object(args)
|
||||
return result
|
||||
|
||||
#获取模块文件夹列表
|
||||
def get_module_list():
|
||||
list = []
|
||||
class_path = public.get_class_path()
|
||||
f_list = os.listdir(class_path)
|
||||
for fname in f_list:
|
||||
f_path = class_path+'/'+fname
|
||||
if os.path.isdir(f_path) and len(fname) > 6 and fname.find('.') == -1 and fname.find('Model') != -1:
|
||||
list.append(fname)
|
||||
return list
|
||||
|
||||
#检查路径是否合法
|
||||
def path_check(path):
|
||||
list = ["./","..",",",";",":","?","'","\"","<",">","|","\\","\n","\r","\t","\b","\a","\f","\v","*","%","&","$","#","@","!","~","`","^","(",")","+","=","{","}","[","]"]
|
||||
for i in path:
|
||||
if i in list:
|
||||
return False
|
||||
return True
|
||||
|
||||
#数据加密
|
||||
def db_encrypt(data):
|
||||
try:
|
||||
key = __get_db_sgin()
|
||||
iv = __get_db_iv()
|
||||
str_arr = data.split('\n')
|
||||
res_str = ''
|
||||
for data in str_arr:
|
||||
if not data: continue
|
||||
res_str += __aes_encrypt(data, key, iv)
|
||||
except:
|
||||
res_str = data
|
||||
result = {
|
||||
'status' : True,
|
||||
'msg' : res_str
|
||||
}
|
||||
return result
|
||||
|
||||
#数据解密
|
||||
def db_decrypt(data):
|
||||
try:
|
||||
key = __get_db_sgin()
|
||||
iv = __get_db_iv()
|
||||
str_arr = data.split('\n')
|
||||
res_str = ''
|
||||
for data in str_arr:
|
||||
if not data: continue
|
||||
res_str += __aes_decrypt(data, key, iv)
|
||||
except:
|
||||
res_str = data
|
||||
result = {
|
||||
'status' : True,
|
||||
'msg' : res_str
|
||||
}
|
||||
return result
|
||||
|
||||
def __get_db_sgin():
|
||||
keystr = '3gP7+k_7lSNg3$+Fj!PKW+6$KYgHtw#R'
|
||||
key = ''
|
||||
for i in range(31):
|
||||
if i & 1 == 0:
|
||||
key += keystr[i]
|
||||
return key
|
||||
|
||||
def __get_db_iv():
|
||||
div_file = "{}/data/div.pl".format(public.get_panel_path())
|
||||
if not os.path.exists(div_file):
|
||||
str = public.GetRandomString(16)
|
||||
str = __aes_encrypt_module(str)
|
||||
div = public.get_div(str)
|
||||
public.WriteFile(div_file, div)
|
||||
if os.path.exists(div_file):
|
||||
div = public.ReadFile(div_file)
|
||||
div = __aes_decrypt_module(div)
|
||||
else:
|
||||
keystr = '4jHCpBOFzL4*piTn^-4IHBhj-OL!fGlB'
|
||||
div = ''
|
||||
for i in range(31):
|
||||
if i & 1 == 0:
|
||||
div += keystr[i]
|
||||
return div
|
||||
|
||||
def __aes_encrypt_module(data):
|
||||
key = 'Z2B87NEAS2BkxTrh'
|
||||
iv = 'WwadH66EGWpeeTT6'
|
||||
return __aes_encrypt(data, key, iv)
|
||||
|
||||
def __aes_decrypt_module(data):
|
||||
key = 'Z2B87NEAS2BkxTrh'
|
||||
iv = 'WwadH66EGWpeeTT6'
|
||||
return __aes_decrypt(data, key, iv)
|
||||
|
||||
def __aes_decrypt(data, key, iv):
|
||||
from Crypto.Cipher import AES
|
||||
import base64
|
||||
encodebytes = base64.decodebytes(data.encode('utf-8'))
|
||||
aes = AES.new(key.encode('utf-8'), AES.MODE_CBC, iv.encode('utf-8'))
|
||||
de_text = aes.decrypt(encodebytes)
|
||||
unpad = lambda s: s[0:-s[-1]]
|
||||
de_text = unpad(de_text)
|
||||
return de_text.decode('utf-8')
|
||||
|
||||
def __aes_encrypt(data, key, iv):
|
||||
from Crypto.Cipher import AES
|
||||
import base64
|
||||
data = (lambda s: s + (16 - len(s) % 16) * chr(16 - len(s) % 16).encode('utf-8'))(data.encode('utf-8'))
|
||||
aes = AES.new(key.encode('utf8'), AES.MODE_CBC, iv.encode('utf8'))
|
||||
encryptedbytes = aes.encrypt(data)
|
||||
en_text = base64.b64encode(encryptedbytes)
|
||||
return en_text.decode('utf-8')
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
- 全局搜索替换 https://api.bt.cn => http://www.example.com
|
||||
|
||||
- 全局搜索替换 https://www.bt.cn/api/ => http://www.example.com/api/(需排除clearModel.py、scanningModel.py、ipsModel.py、js文件)
|
||||
- 全局搜索替换 https://www.bt.cn/api/ => http://www.example.com/api/(需排除clearModel.py、scanningModel.py、ipsModel.py、domainMod.py、js文件)
|
||||
|
||||
- 全局搜索替换 http://www.bt.cn/api/ => http://www.example.com/api/(需排除js文件)
|
||||
|
||||
@@ -96,6 +96,8 @@
|
||||
|
||||
- script/local_fix.sh 文件,${D_NODE_URL}替换成www.example.com
|
||||
|
||||
- script/upgrade_panel_optimized.py 文件,def get_home_node(url): 下面加上return url
|
||||
|
||||
- tools.py 文件,u_input == 16下面的public.get_url()替换成public.GetConfigValue('home')
|
||||
|
||||
- install/install_soft.sh 在. 执行之前加入以下代码
|
||||
@@ -113,11 +115,11 @@
|
||||
|
||||
"update_software_list": self.update_software_list,
|
||||
|
||||
"get_view_title_file": self.get_view_title_file,
|
||||
"refresh_domain_cache": self.refresh_domain_cache,
|
||||
|
||||
PluginLoader.daemon_panel()
|
||||
|
||||
check_node_status()
|
||||
self.check_node_status()
|
||||
|
||||
self.upload_send_num()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user