diff --git a/README.md b/README.md
index fa1da5e..70990d0 100644
--- a/README.md
+++ b/README.md
@@ -1,64 +1,66 @@
-# 宝塔面板第三方云端
-这是一个用php开发的宝塔面板第三方云端站点程序。
-
-你可以使用此程序搭建属于自己的宝塔面板第三方云端,实现最新版宝塔面板私有化部署,不与宝塔官方接口通信,满足隐私安全合规需求。同时还可以去除面板强制绑定账号,DIY面板功能等。
-
-网站后台管理可一键同步宝塔官方的插件列表与增量更新插件包,还有云端使用记录、IP黑白名单、操作日志、定时任务等功能。
-
-本项目自带的宝塔安装包和更新包是8.0.x最新版,已修改适配此第三方云端,并且全开源,无so等加密文件。
-
-觉得该项目不错的可以给个Star~
-
-## 声明
-
-1.此项目只能以自用为目的,不得侵犯堡塔公司及其他第三方的知识产权和其他合法权利。
-
-2.搭建使用此项目必须有一定的编程和Linux运维基础,纯小白不建议使用。
-
-## 环境要求
-
-* `PHP` >= 7.4
-* `MySQL` >= 5.6
-* `fileinfo`扩展
-* `ZipArchive`扩展
-
-## 部署方法
-
-- [下载最新版的Release包](https://github.com/flucont/btcloud/releases)
-- 如果是下载的源码包,需要执行 `composer install --no-dev` 安装依赖,如果是下载的Release包,则不需要
-- 设置网站运行目录为`public`
-- 设置伪静态为`ThinkPHP`
-- 访问网站,会自动跳转到安装页面,根据提示安装完成
-
-## 使用方法
-
-- 在`批量替换工具`,执行页面显示的命令,可将bt安装包、更新包和脚本文件里面的`http://www.example.com`批量替换成当前网站的网址。
-- 在`系统基本设置`修改宝塔面板接口设置。你需要准备一个使用官方最新脚本安装并绑定账号的宝塔面板,用于获取最新插件列表及插件包。并根据界面提示安装好专用插件。
-- 在`定时任务设置`执行所显示的命令从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。当然你也可以去插件列表,一个一个点击下载。
-- 访问网站`/download`查看使用此第三方云端的一键安装脚本。
-
-## 更新方法
-
-- [下载最新版的Release包](https://github.com/flucont/btcloud/releases)
-- 上传覆盖除data文件夹以外的全部文件
-- 后台使用批量替换工具->获取最新插件列表->修改Linux面板等版本号
-
-## 其他
-
-- [Linux面板官方更新包修改记录](./wiki/update.md)
-
-- [Windows面板官方更新包修改记录](./wiki/updatewin.md)
-
-- [宝塔云监控安装包修改记录](./wiki/btmonitor.md)
-
-- 宝塔面板官方版与此第三方云端版对比:
-
- | | 官方版 | 此第三方云端版 |
- | ---------- | ------------------------------------------------------------ | -------------------------------------------------- |
- | 版本更新 | 支持 | 支持 |
- | 面板广告 | 有广告 | 无广告 |
- | 是否全开源 | 没有全开源 | 全开源 |
- | 资源占用 | 各种统计上报等任务,资源占用略高 | 去除了很多无用的定时任务,资源占较少 |
- | 兼容性 | 由于编译的so文件有系统架构限制,兼容的系统仅限已编译的so对应的系统架构 | 由于全开源,没有已编译的so文件,因此无系统架构限制 |
-
-
+# 宝塔面板第三方云端
+这是一个用php开发的宝塔面板第三方云端站点程序。
+
+你可以使用此程序搭建属于自己的宝塔面板第三方云端,实现最新版宝塔面板私有化部署,不与宝塔官方接口通信,满足隐私安全合规需求。同时还可以去除面板强制绑定账号,DIY面板功能等。
+
+网站后台管理可一键同步宝塔官方的插件列表与增量更新插件包,还有云端使用记录、IP黑白名单、操作日志、定时任务等功能。
+
+本项目自带 宝塔Linux面板、宝塔Windows面板、aaPanel面板、宝塔云监控 的最新版安装包和更新包,已修改适配此第三方云端,并且全开源,无so等加密文件。
+
+觉得该项目不错的可以给个Star~
+
+## 声明
+
+1.此项目只能以自用为目的,不得侵犯堡塔公司及其他第三方的知识产权和其他合法权利。
+
+2.搭建使用此项目必须有一定的编程和Linux运维基础,纯小白不建议使用。
+
+## 环境要求
+
+* `PHP` >= 7.4
+* `MySQL` >= 5.6
+* `fileinfo`扩展
+* `ZipArchive`扩展
+
+## 部署方法
+
+- [下载最新版的Release包](https://github.com/flucont/btcloud/releases)
+- 如果是下载的源码包,需要执行 `composer install --no-dev` 安装依赖,如果是下载的Release包,则不需要
+- 设置网站运行目录为`public`
+- 设置伪静态为`ThinkPHP`
+- 访问网站,会自动跳转到安装页面,根据提示安装完成
+
+## 使用方法
+
+- 在`批量替换工具`,执行页面显示的命令,可将bt安装包、更新包和脚本文件里面的`http://www.example.com`批量替换成当前网站的网址。
+- 在`系统基本设置`修改宝塔面板接口设置。你需要准备一个使用官方最新脚本安装并绑定账号的宝塔面板,用于获取最新插件列表及插件包。并根据界面提示安装好专用插件。
+- 在`定时任务设置`执行所显示的命令从宝塔官方获取最新的插件列表并批量下载插件包(增量更新)。当然你也可以去插件列表,一个一个点击下载。
+- 访问网站`/download`查看使用此第三方云端的一键安装脚本。
+
+## 更新方法
+
+- [下载最新版的Release包](https://github.com/flucont/btcloud/releases)
+- 上传覆盖除data文件夹以外的全部文件
+- 后台使用批量替换工具->获取最新插件列表->修改软件版本设置里面的版本号
+
+## 其他
+
+- [Linux面板官方更新包修改记录](./wiki/update.md)
+
+- [Windows面板官方更新包修改记录](./wiki/updatewin.md)
+
+- [aaPanel面板官方更新包修改记录](./wiki/aapanel.md)
+
+- [宝塔云监控安装包修改记录](./wiki/btmonitor.md)
+
+- 宝塔面板官方版与此第三方云端版对比:
+
+ | | 官方版 | 此第三方云端版 |
+ | ---------- | ------------------------------------------------------------ | -------------------------------------------------- |
+ | 版本更新 | 支持 | 支持 |
+ | 面板广告 | 有广告 | 无广告 |
+ | 是否全开源 | 没有全开源 | 全开源 |
+ | 资源占用 | 各种统计上报等任务,资源占用略高 | 去除了很多无用的定时任务,资源占较少 |
+ | 兼容性 | 由于编译的so文件有系统架构限制,兼容的系统仅限已编译的so对应的系统架构 | 由于全开源,没有已编译的so文件,因此无系统架构限制 |
+
+
diff --git a/app/command/CleanViteJs.php b/app/command/CleanViteJs.php
index b356113..63ac1c8 100644
--- a/app/command/CleanViteJs.php
+++ b/app/command/CleanViteJs.php
@@ -236,6 +236,58 @@ class CleanViteJs extends Command
$file = str_replace('暂无搜索结果,提交需求反馈', '暂无搜索结果', $file);
$flag = true;
}
+
+ if(strpos($file, 'getReceiveCoupon()')!==false){ //aapanel-优惠券
+ $code = $this->getExtendCode($file, 'getReceiveCoupon()');
+ $file = str_replace($code, '{}', $file);
+ $flag = true;
+ }
+
+ if(strpos($file, '"Site.DelSite.index_1"')!==false){ //aapanel-site
+ $code = $this->getExtendCode($file, '"Site.DelSite.index_10"', 3, '(', ')');
+ if($code){
+ $code = $this->getExtendFunction($file, $code);
+ $file = str_replace($code, '', $file);
+ $file = preg_replace('@\w+\.value!==\w+\.value\+\w+\.value@', '!1', $file);
+ $file = preg_replace('@null==\w+\.value\|\|null==\w+\.value@', '!1', $file);
+ $file = str_replace('disabled:!0', 'disabled:!1', $file);
+ $flag = true;
+ }
+ }
+
+ if(strpos($file, '"Component.Confirm.index_4"')!==false){ //aapanel-public
+ $code = $this->getExtendCode($file, '"Component.Confirm.index_4"', 2, '(', ')');
+ if($code){
+ $code = $this->getExtendFunction($file, $code);
+ $file = str_replace($code, '', $file);
+ $file = preg_replace('@\w+\.value===\w+\.value\+\w+\.value@', '!0', $file);
+ $flag = true;
+ }
+ $code = $this->getExtendCode($file, '"Component.Confirm.index_1"', 1, '(', ')');
+ if($code){
+ $code = $this->getExtendFunction($file, $code);
+ $file = str_replace($code, '', $file);
+ $file = preg_replace('@\w+\.value===\w+\.value\?@', '!0?', $file);
+ $flag = true;
+ }
+ }
+
+ if(strpos($file, '"Component.Feedback.index_7"')!==false){ //aapanel-需求反馈
+ $code = $this->getExtendCode($file, '"Component.Feedback.index_7"', 2);
+ if($code){
+ $code = $this->getExtendFunction($file, $code);
+ $file = str_replace($code, '', $file);
+ $flag = true;
+ }
+ }
+
+ if(strpos($file, '"Soft.index_16"')!==false){ //aapanel-soft
+ $code = $this->getExtendCode($file, '"Soft.index_16"', 2);
+ if($code){
+ $file = str_replace($code, '{}', $file);
+ $flag = true;
+ }
+ }
if(!$flag) return;
if(file_put_contents($filepath, $file)){
diff --git a/app/command/DecryptFile.php b/app/command/DecryptFile.php
index f6c0b06..19bbb1c 100644
--- a/app/command/DecryptFile.php
+++ b/app/command/DecryptFile.php
@@ -45,37 +45,34 @@ class DecryptFile extends Command
$output->writeln($e->getMessage());
}
}elseif($type == 'module'){
- try{
- $res = Plugins::decode_module_file($file);
- if($res == 2){
- $output->writeln('文件解密失败!');
- }elseif($res == 1){
- $output->writeln('文件解密成功!');
- }
- }catch(\Exception $e){
- $output->writeln($e->getMessage());
- }
+ $this->decode_module_file($output, $file);
}elseif($type == 'classdir'){
$file = rtrim($file, '/');
- if(!file_exists($file.'/common.py')){
+ if(file_exists($file.'/common.py')){
+ $class_v = 1;
+ }elseif(file_exists($file.'/common_v2.py')){
+ $class_v = 2;
+ }else{
$output->writeln('当前路径非宝塔面板class目录');
return;
}
- $dirs = glob($file.'/*Model');
+ $dirs = glob($file.'/*Model'.($class_v == 2 ? 'V2' : ''));
foreach($dirs as $dir){
if(!is_dir($dir))continue;
$files = glob($dir.'/*Model.py');
- foreach($files as $file){
- try{
- $res = Plugins::decode_module_file($file);
- if($res == 2){
- $output->writeln('文件解密失败:'.$file);
- }elseif($res == 1){
- $output->writeln('文件解密成功:'.$file);
- }
- }catch(\Exception $e){
- $output->writeln($e->getMessage().':'.$file);
- }
+ foreach($files as $filepath){
+ $this->decode_module_file($output, $filepath);
+ }
+ }
+ if($class_v == 2){
+ $filepath = $file.'/wp_toolkit/core.py';
+ if(file_exists($filepath)){
+ $this->decode_module_file($output, $filepath);
+ }
+ }else{
+ $filepath = $file.'/public/authorization.py';
+ if(file_exists($filepath)){
+ $this->decode_module_file($output, $filepath);
}
}
}elseif($type == 'all'){
@@ -95,21 +92,24 @@ class DecryptFile extends Command
$this->scan_all_file($input, $output, $filepath);
}
elseif(substr($filepath, -3) == '.py') {
- try{
- $res = Plugins::decode_module_file($filepath);
- if($res == 2){
- $output->writeln('文件解密失败:'.$filepath);
- }elseif($res == 1){
- $output->writeln('文件解密成功:'.$filepath);
- }
- }catch(\Exception $e){
- $output->writeln($e->getMessage().':'.$filepath);
- }
+ $this->decode_module_file($output, $filepath);
}
}
}
closedir($dir);
}
+ private function decode_module_file(Output $output, $filepath){
+ try{
+ $res = Plugins::decode_module_file($filepath);
+ if($res == 2){
+ $output->writeln('文件解密失败:'.$filepath);
+ }elseif($res == 1){
+ $output->writeln('文件解密成功:'.$filepath);
+ }
+ }catch(\Exception $e){
+ $output->writeln($e->getMessage().':'.$filepath);
+ }
+ }
}
diff --git a/app/common.php b/app/common.php
index 5a6bebc..a834f12 100644
--- a/app/common.php
+++ b/app/common.php
@@ -3,7 +3,13 @@
use think\facade\Db;
function get_data_dir($os = 'Linux'){
- return app()->getRootPath().'data/'.($os == 'Windows' ? 'win/' : '');
+ if($os == 'en'){
+ return app()->getRootPath().'data/en/';
+ }elseif($os == 'Windows'){
+ return app()->getRootPath().'data/win/';
+ }else{
+ return app()->getRootPath().'data/';
+ }
}
diff --git a/app/controller/Admin.php b/app/controller/Admin.php
index b0f393e..b1d82df 100644
--- a/app/controller/Admin.php
+++ b/app/controller/Admin.php
@@ -151,7 +151,7 @@ class Admin extends BaseController
if($result && isset($result['username'])){
return json(['code'=>0, 'msg'=>'面板连接测试成功!']);
}else{
- return json(['code'=>-1, 'msg'=>'面板连接测试成功,但未安装专用插件']);
+ return json(['code'=>-1, 'msg'=>'面板连接测试成功,但未安装专用插件/未登录账号']);
}
}else{
return json(['code'=>-1, 'msg'=>isset($result['msg'])?$result['msg']:'面板地址无法连接']);
@@ -185,6 +185,19 @@ class Admin extends BaseController
return view();
}
+ public function pluginsen(){
+ $typelist = [];
+ $json_arr = Plugins::get_plugin_list('en');
+ if($json_arr){
+ foreach($json_arr['type'] as $type){
+ if($type['title'] == '一键部署') continue;
+ $typelist[$type['id']] = $type['title'];
+ }
+ }
+ View::assign('typelist', $typelist);
+ return view();
+ }
+
public function plugins_data(){
$type = input('post.type/d');
$keyword = input('post.keyword', null, 'trim');
@@ -226,7 +239,7 @@ class Admin extends BaseController
'name' => $plugin['name'],
'title' => $plugin['title'],
'type' => $plugin['type'],
- 'typename' => $typelist[$plugin['type']],
+ 'typename' => isset($typelist[$plugin['type']]) ? $typelist[$plugin['type']] : '未知',
'desc' => str_replace('target="_blank"','target="_blank" rel="noopener noreferrer"',$plugin['ps']),
'price' => $plugin['price'],
'author' => isset($plugin['author']) ? $plugin['author'] : '官方',
diff --git a/app/controller/Api.php b/app/controller/Api.php
index 963533c..d4b3660 100644
--- a/app/controller/Api.php
+++ b/app/controller/Api.php
@@ -36,6 +36,20 @@ class Api extends BaseController
return json($json_arr);
}
+ //获取插件列表(aapanel)
+ public function get_plugin_list_en(){
+ if(!$this->checklist()) return json('你的服务器被禁止使用此云端');
+ $record = Db::name('record')->where('ip',$this->clientip)->find();
+ if($record){
+ Db::name('record')->where('id',$record['id'])->update(['usetime'=>date("Y-m-d H:i:s")]);
+ }else{
+ Db::name('record')->insert(['ip'=>$this->clientip, 'addtime'=>date("Y-m-d H:i:s"), 'usetime'=>date("Y-m-d H:i:s")]);
+ }
+ $json_arr = Plugins::get_plugin_list('en');
+ if(!$json_arr) return json((object)[]);
+ return json($json_arr);
+ }
+
//下载插件包
public function download_plugin(){
$plugin_name = input('post.name');
@@ -58,6 +72,26 @@ class Api extends BaseController
}
}
+ //下载插件包aapanel
+ public function download_plugin_en(){
+ $plugin_name = input('post.name');
+ $version = input('post.version');
+ if(!$plugin_name || !$version){
+ return '参数不能为空';
+ }
+ if(!preg_match('/^[a-zA-Z0-9_]+$/', $plugin_name) || !preg_match('/^[0-9.]+$/', $version)){
+ return '参数不正确';
+ }
+ if(!$this->checklist()) return '你的服务器被禁止使用此云端';
+ $filepath = get_data_dir('en').'plugins/package/'.$plugin_name.'-'.$version.'.zip';
+ if(file_exists($filepath)){
+ $filename = $plugin_name.'.zip';
+ $this->output_file($filepath, $filename);
+ }else{
+ return '云端不存在该插件包';
+ }
+ }
+
//下载插件主文件
public function download_plugin_main(){
$plugin_name = input('post.name');
@@ -92,7 +126,10 @@ class Api extends BaseController
public function download_plugin_other(){
$fname = input('get.fname');
if(!$fname){
- return json(['status'=>false, 'msg'=>'参数不能为空']);
+ $fname = input('get.filename');
+ if(!$fname){
+ return json(['status'=>false, 'msg'=>'参数不能为空']);
+ }
}
if(strpos(dirname($fname),'.')!==false)return json(['status'=>false, 'msg'=>'参数不正确']);
if(!$this->checklist()) return json(['status'=>false, 'msg'=>'你的服务器被禁止使用此云端']);
@@ -139,6 +176,11 @@ class Api extends BaseController
return $version;
}
+ public function get_version_en(){
+ $version = config_get('new_version_en');
+ return $version;
+ }
+
public function get_panel_version(){
$version = config_get('new_version');
$file = app()->getRootPath().'public/install/update/LinuxPanel-'.$version.'.zip';
@@ -205,6 +247,28 @@ class Api extends BaseController
return json($data);
}
+ //检测更新(aapanel)
+ public function check_update_en(){
+ $version = config_get('new_version_en');
+ $down_url = request()->root(true).'/install/update/LinuxPanel_EN-'.$version.'.zip';
+ $data = [
+ 'force' => false,
+ 'version' => $version,
+ 'downUrl' => $down_url,
+ 'updateMsg' => config_get('update_msg_en'),
+ 'uptime' => config_get('update_date_en'),
+ 'is_beta' => 0,
+ 'btb' => '',
+ 'beta' => [
+ 'version' => $version,
+ 'downUrl' => $down_url,
+ 'updateMsg' => config_get('update_msg_en'),
+ 'uptime' => config_get('update_date_en'),
+ ]
+ ];
+ return json($data);
+ }
+
//宝塔云监控获取最新版本
public function btm_latest_version(){
$data = [
@@ -410,6 +474,18 @@ class Api extends BaseController
return json(['page'=>"
11/0从1-1000条共计0条数据
", 'data'=>[]]);
}
+ public function nps_check(){
+ return json(['err_no'=>0, 'success'=>true, 'res'=>true, 'nonce'=>time()]);
+ }
+
+ public function nps_questions(){
+ return json(['err_no'=>0, 'success'=>true, 'res'=>[], 'nonce'=>time()]);
+ }
+
+ public function nps_submit(){
+ return json(['err_no'=>0, 'success'=>true, 'res'=>'Success', 'nonce'=>time()]);
+ }
+
//获取所有蜘蛛IP列表
public function btwaf_getspiders(){
try{
diff --git a/app/lib/BtPlugins.php b/app/lib/BtPlugins.php
index 6a32c0d..37e2b0e 100644
--- a/app/lib/BtPlugins.php
+++ b/app/lib/BtPlugins.php
@@ -15,7 +15,10 @@ class BtPlugins
public function __construct($os){
$this->os = $os;
- if($os == 'Windows'){
+ if($os == 'en'){
+ $bt_url = config_get('enbt_url');
+ $bt_key = config_get('enbt_key');
+ }elseif($os == 'Windows'){
$bt_url = config_get('wbt_url');
$bt_key = config_get('wbt_key');
}else{
@@ -157,9 +160,9 @@ class BtPlugins
$de_text = '';
foreach($data_arr as $data){
$data = trim($data);
- if(!empty($data) && strlen($data)!=24){
+ if(!empty($data)){
$tmp = openssl_decrypt($data, 'aes-128-cbc', $key, 0, $iv);
- if($tmp) $de_text .= $tmp;
+ if($tmp !== false) $de_text .= $tmp;
}
}
if(!empty($de_text) && strpos($de_text, 'import ')!==false){
@@ -202,6 +205,8 @@ class BtPlugins
$data = str_replace('\'http://www.bt.cn/api/Auth', 'public.GetConfigValue(\'home\')+\'/api/Auth', $data);
$data = str_replace('\'https://www.bt.cn/api/Auth', 'public.GetConfigValue(\'home\')+\'/api/Auth', $data);
+ $data = str_replace('\'https://brandnew.aapanel.com/api/panel/getSoftList', 'public.OfficialApiBase()+\'/api/panel/getSoftList', $data);
+
file_put_contents($main_filepath, $data);
}
diff --git a/app/lib/Plugins.php b/app/lib/Plugins.php
index ede17f7..487b139 100644
--- a/app/lib/Plugins.php
+++ b/app/lib/Plugins.php
@@ -17,7 +17,13 @@ class Plugins
}
private static function is_third($os){
- $type = $os == 'Windows' ? config_get('wbt_type') : config_get('bt_type');
+ if($os == 'en'){
+ $type = config_get('enbt_type');
+ }elseif($os == 'Windows'){
+ $type = config_get('wbt_type');
+ }else{
+ $type = config_get('bt_type');
+ }
return $type == 1;
}
@@ -31,23 +37,44 @@ class Plugins
//保存插件列表
private static function save_plugin_list($data, $os){
$data['ip'] = '127.0.0.1';
- $data['serverid'] = '';
- $data['beta'] = 0;
- $data['uid'] = 1;
- $data['skey'] = '';
- $list = [];
- foreach($data['list'] as $plugin){
+ if($os == 'en'){
+ $data['serverId'] = '';
+ $data['aln'] = self::get_aln();
+ $data['pro'] = 0;
+ $data['pro_authorization_sn'] = '0';
+ if(!empty($data['authorization_map'])){
+ foreach($data['authorization_map'] as $code => &$plugin){
+ if($code != '0' && isset($plugin['end_time'])) $plugin['end_time'] = 0;
+ }
+ }
+ if(isset($data['expansions']['mail'])){
+ $data['expansions']['mail']['total'] = 2000000;
+ $data['expansions']['mail']['available'] = 2000000;
+ }
+ }else{
+ $data['serverid'] = '';
+ $data['aln'] = self::get_aln();
+ $data['beta'] = 0;
+ $data['uid'] = 1;
+ $data['skey'] = '';
+ $data['ltd'] = strtotime('+10 year');
+ }
+ foreach($data['list'] as &$plugin){
if(isset($plugin['endtime'])) $plugin['endtime'] = 0;
- $list[] = $plugin;
}
- $data['list'] = $list;
- $data['ltd'] = strtotime('+10 year');
$json_file = get_data_dir($os).'config/plugin_list.json';
if(!file_put_contents($json_file, json_encode($data))){
throw new Exception('保存插件列表失败,文件无写入权限');
}
}
+ //多账号数量
+ private static function get_aln($count = '9999'){
+ $key = 'FB8upo8XMgP5by54';
+ $iv = 'lOrrq3lNEURZNdK7';
+ return openssl_encrypt($count, 'aes-128-cbc', $key, 0, $iv);
+ }
+
//获取插件列表
public static function get_plugin_list($os = 'Linux'){
$json_file = get_data_dir($os).'config/plugin_list.json';
@@ -106,7 +133,7 @@ class Plugins
$data = trim($data);
if(!empty($data)){
$tmp = openssl_decrypt($data, 'aes-128-cbc', $key, 0, $iv);
- if($tmp) $de_text .= $tmp;
+ if($tmp !== false) $de_text .= $tmp;
}
}
if(!empty($de_text) && strpos($de_text, 'import ')!==false){
diff --git a/app/lib/ThirdPlugins.php b/app/lib/ThirdPlugins.php
index a6f47d0..5c116a2 100644
--- a/app/lib/ThirdPlugins.php
+++ b/app/lib/ThirdPlugins.php
@@ -13,7 +13,13 @@ class ThirdPlugins
public function __construct($os)
{
$this->os = $os;
- $url = $os == 'Windows' ? config_get('wbt_surl') : config_get('bt_surl');
+ if($os == 'en'){
+ $url = config_get('enbt_surl');
+ }elseif($os == 'Windows'){
+ $url = config_get('wbt_surl');
+ }else{
+ $url = config_get('bt_surl');
+ }
if(!$url) throw new Exception('请先配置好第三方云端首页URL');
$this->url = $url;
}
@@ -21,7 +27,13 @@ class ThirdPlugins
//获取插件列表
public function get_plugin_list()
{
- $url = $this->os == 'Windows' ? $this->url . 'api/wpanel/get_soft_list' : $this->url . 'api/panel/get_soft_list';
+ if($this->os == 'en'){
+ $url = $this->url . 'api/panel/get_plugin_list_en';
+ }elseif($this->os == 'Windows'){
+ $url = $this->url . 'api/wpanel/get_plugin_list';
+ }else{
+ $url = $this->url . 'api/panel/get_plugin_list';
+ }
$res = $this->curl($url);
$result = json_decode($res, true);
if($result && isset($result['list']) && isset($result['type'])){
diff --git a/app/script/convert.sh b/app/script/convert.sh
index 261dcdc..d5ccaa5 100644
--- a/app/script/convert.sh
+++ b/app/script/convert.sh
@@ -2,6 +2,7 @@
Linux_Version="9.3.0"
Windows_Version="8.2.1"
+Aapanel_Version="7.0.13"
Btm_Version="2.3.0"
FILES=(
@@ -17,6 +18,11 @@ public/win/panel/data/setup.py
public/install/src/bt-monitor-${Btm_Version}.zip
public/install/install_btmonitor.sh
public/install/update_btmonitor.sh
+public/install/src/panel_7_en.zip
+public/install/update/LinuxPanel_EN-${Aapanel_Version}.zip
+public/install/install_7.0_en.sh
+public/install/install_pro_en.sh
+public/install/update_7.x_en.sh
)
DIR=$1
diff --git a/app/view/admin/layout.html b/app/view/admin/layout.html
index 468b6ff..a361c12 100644
--- a/app/view/admin/layout.html
+++ b/app/view/admin/layout.html
@@ -34,11 +34,12 @@
后台首页
-
+
插件列表
diff --git a/app/view/admin/pluginsen.html b/app/view/admin/pluginsen.html
new file mode 100644
index 0000000..52d327c
--- /dev/null
+++ b/app/view/admin/pluginsen.html
@@ -0,0 +1,276 @@
+{extend name="admin/layout" /}
+{block name="title"}插件列表{/block}
+{block name="main"}
+
+
+
+
+
+
+
“版本与状态”一列中,红色的按钮代表本地不存在该版本插件包,需要点击下载;绿色的按钮代表已存在。
+
官方插件包本地存储路径是/data/en/plugins/package/软件标识-版本号.zip,第三方插件包路径是/data/plugins/other/other/,对于部分包含二次验证的插件可以自行修改。
+
+
+
+
+
+
+
+
+
+
+
+{/block}
\ No newline at end of file
diff --git a/app/view/admin/set.html b/app/view/admin/set.html
index bd11a53..c1c82fb 100644
--- a/app/view/admin/set.html
+++ b/app/view/admin/set.html
@@ -49,8 +49,6 @@
-
-
Windows面板版本设置
@@ -76,6 +74,8 @@
+
+
云监控版本设置
@@ -99,6 +99,31 @@
+
{elseif $mod=='api'}
@@ -175,6 +200,43 @@
+
+
+
aaPanel面板接口设置
+
+
+
+
+
{elseif $mod=='task'}
@@ -222,6 +293,10 @@ $("select[name='wbt_type']").change(function(){
(批量下载不包含所有第三方插件,第三方插件需要去手动下载。)
+
+
+ (批量下载不包含所有第三方插件,第三方插件需要去手动下载。)
+
@@ -376,6 +451,51 @@ $(document).ready(function(){
}
});
})
+ $("#testbturl3").click(function(){
+ var enbt_type = $("select[name=enbt_type]").val();
+ if(enbt_type == '1'){
+ var enbt_surl = $("input[name=enbt_surl]").val();
+ if(enbt_surl == ''){
+ layer.alert('第三方云端URL不能为空');return;
+ }
+ if(enbt_surl.indexOf('http://')==-1 && enbt_surl.indexOf('https://')==-1){
+ layer.alert('第三方云端URL不正确');return;
+ }
+ var postdata = {bt_type:enbt_type, bt_surl:enbt_surl};
+ }else{
+ var enbt_url = $("input[name=enbt_url]").val();
+ var enbt_key = $("input[name=enbt_key]").val();
+ if(enbt_url == ''){
+ layer.alert('宝塔面板URL不能为空');return;
+ }
+ if(enbt_url.indexOf('http://')==-1 && enbt_url.indexOf('https://')==-1){
+ layer.alert('宝塔面板URL不正确');return;
+ }
+ if(enbt_key == ''){
+ layer.alert('宝塔面板接口密钥不能为空');return;
+ }
+ var postdata = {bt_type:enbt_type, bt_url:enbt_url, bt_key:enbt_key};
+ }
+ var ii = layer.load(2, {shade:[0.1,'#fff']});
+ $.ajax({
+ type : 'POST',
+ url : '/admin/testbturl',
+ data : postdata,
+ dataType : 'json',
+ success : function(data) {
+ layer.close(ii);
+ if(data.code == 0){
+ layer.msg(data.msg, {icon: 1, time:1000})
+ }else{
+ layer.alert(data.msg, {icon: 2})
+ }
+ },
+ error:function(data){
+ layer.close(ii);
+ layer.msg('服务器错误');
+ }
+ });
+ })
})
function saveSetting(obj){
var ii = layer.load(2, {shade:[0.1,'#fff']});
diff --git a/app/view/index/download.html b/app/view/index/download.html
index 32b8e67..66c743f 100644
--- a/app/view/index/download.html
+++ b/app/view/index/download.html
@@ -43,7 +43,7 @@
-
+ {if config_get('new_version_win')}
-
+ {/if}
- {if config_get('new_version_btm')}
-
+ {if config_get('new_version_btm') || config_get('new_version_en')}
+ {if config_get('new_version_win')}
-
+
{/if}
+ {if config_get('new_version_en')}
+
+

+
+
+
+
aaPanel {:config_get('new_version_en')}
+
宝塔面板国际版
+
+
+
+
{/if}
{/if}
@@ -121,6 +135,7 @@
+ {if config_get('new_version_win')}
@@ -140,7 +155,7 @@
注意:仅支持Windows Server 2008 R2/2012/2016/2019/2022,64位系统(中文简体),且未安装其它环境
-
+ {/if}
{if config_get('new_version_btm')}
{/if}
+ {if config_get('new_version_en')}
+
+
+
+
aaPanel {:config_get('new_version_en')} install script
+
+
+
It is recommended that you use Ubuntu22.04 to install aaPanel
+
+
+
Instarll script
+
+
URL={$siteurl}/script/install_pro_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO $URL ;else wget -O install_pro_en.sh $URL;fi;bash install_pro_en.sh
+
复制
+
+
+
+
Upgrade script
+
+
curl {$siteurl}/install/update_7.x_en.sh|bash
+
复制
+
+
+
+
{/if}
@@ -236,6 +276,10 @@
scrollTop('#instal-monitor');
});
+ $('#goInstallAaPanel').click(function () {
+ scrollTop('#instal-aapanel');
+ });
+
function GetRequest() {
var url = location.search;
//获取url中"?"符后的字串
diff --git a/install.sql b/install.sql
index 14af54f..fd7bd57 100644
--- a/install.sql
+++ b/install.sql
@@ -18,6 +18,9 @@ INSERT INTO `cloud_config` (`key`, `value`) VALUES
('new_version_win', '8.2.1'),
('update_msg_win', '暂无更新日志'),
('update_date_win', '2024-12-06'),
+('new_version_en', '7.0.13'),
+('update_msg_en', '暂无更新日志'),
+('update_date_en', '2024-11-17'),
('new_version_btm', '2.3.0'),
('update_msg_btm', '暂无更新日志'),
('update_date_btm', '2024-04-24'),
diff --git a/public/install/install_6.0.sh b/public/install/install_6.0.sh
index ea899c5..8ddbc57 100644
--- a/public/install/install_6.0.sh
+++ b/public/install/install_6.0.sh
@@ -931,7 +931,7 @@ Install_Bt(){
echo "True" > /www/server/panel/data/not_workorder.pl
fi
if [ ! -f /www/server/panel/data/userInfo.json ]; then
- echo "{\"uid\":1,\"username\":\"Administrator\",\"address\":\"127.0.0.1\",\"serverid\":\"1\",\"access_key\":\"test\",\"secret_key\":\"123456\",\"ukey\":\"123456\",\"state\":1}" > /www/server/panel/data/userInfo.json
+ echo "{\"uid\":1,\"username\":\"Administrator\",\"address\":\"127.0.0.1\",\"access_key\":\"test\",\"secret_key\":\"123456\",\"ukey\":\"123456\",\"state\":1}" > /www/server/panel/data/userInfo.json
fi
if [ ! -f /www/server/panel/data/panel_nps.pl ]; then
echo "" > /www/server/panel/data/panel_nps.pl
diff --git a/public/install/install_7.0_en.sh b/public/install/install_7.0_en.sh
new file mode 100644
index 0000000..cda8056
--- /dev/null
+++ b/public/install/install_7.0_en.sh
@@ -0,0 +1,2027 @@
+#!/bin/bash
+PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
+export PATH
+LANG=en_US.UTF-8
+
+Btapi_Url='http://www.example.com'
+Check_Api=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/SetupCount)
+if [ "$Check_Api" != 'ok' ];then
+ Red_Error "The BT cloud could not be connected, so the installation process has been aborted!";
+fi
+
+if [ $(whoami) != "root" ]; then
+ # echo "Please use the [root] user to execute the aapanel installation script!"
+ echo -e "Non-root install, please try the following solutions: \n 1.Please switch to [root] user install \n 2.Try executing the following install commands: \n sudo bash $0 $@"
+ exit 1
+fi
+
+is64bit=$(getconf LONG_BIT)
+if [ "${is64bit}" != '64' ]; then
+ Red_Error "Sorry, aaPanel does not support 32-bit systems"
+fi
+
+HOSTNAME_CHECK=$(cat /etc/hostname)
+if [ -z "${HOSTNAME_CHECK}" ];then
+ echo "hostname is empty. Already set as aaPanel"
+ echo "aaPanel" > /etc/hostname
+ hostnamectl set-hostname aaPanel
+fi
+
+if [ -f "/etc/SUSE-brand" ];then
+ openSUSE_check=$(cat /etc/SUSE-brand |grep openSUSE)
+ if [ "${openSUSE_check}" ];then
+ echo "Error: openSUSE not supported, Recommended that you use:"
+ echo "Debian 11/12, Ubuntu 20/22/24, Rocky/Alma 8, Rocky/Alma/Centos 9"
+ exit 1
+ fi
+fi
+
+cd ~
+setup_path="/www"
+python_bin=$setup_path/server/panel/pyenv/bin/python
+cpu_cpunt=$(cat /proc/cpuinfo | grep ^processor | wc -l)
+panelPort=$(expr $RANDOM % 55535 + 10000)
+if [ "$1" ]; then
+ IDC_CODE=$1
+fi
+
+Command_Exists() {
+ command -v "$@" >/dev/null 2>&1
+}
+
+GetSysInfo() {
+ if [ -s "/etc/redhat-release" ]; then
+ SYS_VERSION=$(cat /etc/redhat-release)
+ elif [ -s "/etc/issue" ]; then
+ SYS_VERSION=$(cat /etc/issue)
+ fi
+ SYS_INFO=$(uname -a)
+ SYS_BIT=$(getconf LONG_BIT)
+ MEM_TOTAL=$(free -m | grep Mem | awk '{print $2}')
+ CPU_INFO=$(getconf _NPROCESSORS_ONLN)
+
+ echo -e ${SYS_VERSION}
+ echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO}
+ echo -e ${SYS_INFO}
+ echo -e "Please screenshot above error message and post forum forum.aapanel.com or send email: kern@aapanel.com for help"
+}
+
+
+Replace_symbol(){
+# 更换符号为__
+ text="${text#"${text%%[![:space:]]*}"}"
+ text=${text%% }
+ text=${text// /__}
+ text=${text//\(/__}
+ text=${text//\)/__}
+ text=${text//\"/__}
+ text=${text//\“/__}
+ text=${text//\”/__}
+ text=${text//\(/__}
+ text=${text//\)/__}
+ text=${text//\!/__}
+ text=${text//\!/__}
+ text=${text//:/__}
+ text=${text//:/__}
+ text=${text//,/__}
+ text=${text//,/__}
+ text=${text//。/__}
+ text=${text//\$/__}
+ text=${text//\{/__}
+ text=${text//\}/__}
+ text=${text//\[/__}
+ text=${text//\]/__}
+ text=${text//./__}
+ text=${text//-/__}
+ text=${text//>/__}
+ text=${text//=/__}
+ text=${text//\//__}
+ text=${text//\'/__}
+
+}
+
+Red_Error() {
+ echo '================================================='
+ printf '\033[1;31;40m%b\033[0m\n' "$@"
+ GetSysInfo
+
+ if [[ "$@" == "" ]]; then
+ url_err_msg="aaPanel_install_failed"
+ else
+ text="$@"
+ Replace_symbol
+
+ url_err_msg="${text}"
+ #echo "url_err_msg:$url_err_msg"
+ fi
+ exit 1
+}
+
+if [ -f "/etc/redhat-release" ]; then
+ Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos6Check}" ]; then
+ Red_Error "Sorry, Centos6 does not support installing aaPanel"
+ fi
+ Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
+ Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos7Check}" ] || [ "${Centos8Check}" ];then
+ echo "Centos 7/8 provider no longer maintained, Recommended that you use:"
+ echo "Debian 11/12, Ubuntu 20/22/24, Rocky/Alma 8, Rocky/Alma/Centos 9"
+ echo "Press Ctrl+C to cancel or Wait 10 seconds before install"
+ sleep 10
+ fi
+fi
+
+if [ -f "/etc/issue" ]; then
+ UbuntuCheck=$(cat /etc/issue | grep Ubuntu | awk '{print $2}' | cut -f 1 -d '.')
+ if [[ ! -z "${UbuntuCheck}" ]] && [[ "${UbuntuCheck}" =~ ^[0-9]+$ ]] && [[ "${UbuntuCheck}" -lt "18" ]]; then
+ Red_Error "Ubuntu ${UbuntuCheck} is not supported to the aaPanel, it is recommended to replace the Ubuntu 20/22/24 to install"
+ fi
+
+ DebianCheck=$(cat /etc/issue | grep Debian | awk '{print $3}' | cut -f 1 -d '.')
+ if [[ ! -z "${DebianCheck}" ]] && [[ "${DebianCheck}" =~ ^[0-9]+$ ]] && [[ "${DebianCheck}" -lt "10" ]]; then
+ Red_Error "Debian ${DebianCheck} is not supported to the aaPanel, it is recommended to replace the Debian 11/12 to install"
+ fi
+fi
+
+Check_Disk_Space() {
+ # Get the available space of the partition where the /www directory is located (in kb)
+ if [ -d "/www" ]; then
+ available_kb=$(df -k /www | awk 'NR==2 {print $4}')
+ else
+ available_kb=$(df -k / | awk 'NR==2 {print $4}')
+ fi
+
+ # 1GB = 1024MB = 1024*1024KB
+ available_gb=$((available_kb / 1024 / 1024))
+ echo "Available disk space on the install partition: "$available_gb" G"
+
+ # Determine if available space is less than 1 gb
+ if [ "$available_gb" -lt 1 ]; then
+ echo -e "\033[31m The available space is less than 1G.\033[0m"
+ echo -e "\033[31m It is recommended to clean or upgrade the server space before upgrading.\033[0m"
+ Red_Error "Error: The available space is less than 1G"
+ fi
+
+}
+
+Lock_Clear() {
+ if [ -f "/etc/bt_crack.pl" ]; then
+ chattr -R -ia /www
+ chattr -ia /etc/init.d/bt
+ \cp -rpa /www/backup/panel/vhost/* /www/server/panel/vhost/
+ mv /www/server/panel/BTPanel/__init__.bak /www/server/panel/BTPanel/__init__.py
+ rm -f /etc/bt_crack.pl
+ fi
+}
+Install_Check() {
+ if [ "${INSTALL_FORCE}" ]; then
+ return
+ fi
+ echo -e "----------------------------------------------------"
+ echo -e "Web service is already installed,installing aaPanel may affect existing sites."
+ echo -e "----------------------------------------------------"
+ echo -e "Enter [yes] to force installation"
+ read -p "Enter yes to force installation: " yes
+ if [ "$yes" != "yes" ]; then
+ echo -e "------------"
+ echo "Installation canceled"
+ exit
+ fi
+ INSTALL_FORCE="true"
+}
+System_Check() {
+ MYSQLD_CHECK=$(ps -ef | grep mysqld | grep -v grep | grep -v /www/server/mysql)
+ PHP_CHECK=$(ps -ef | grep php-fpm | grep master | grep -v /www/server/php)
+ NGINX_CHECK=$(ps -ef | grep nginx | grep master | grep -v /www/server/nginx)
+ HTTPD_CHECK=$(ps -ef | grep -E 'httpd|apache' | grep -v /www/server/apache | grep -v grep)
+ if [ "${PHP_CHECK}" ] || [ "${MYSQLD_CHECK}" ] || [ "${NGINX_CHECK}" ] || [ "${HTTPD_CHECK}" ]; then
+ Install_Check
+ fi
+}
+Set_Ssl() {
+ SET_SSL=true
+
+ if [ "${SSL_PL}" ];then
+ SET_SSL=""
+ fi
+}
+
+Get_Pack_Manager() {
+ if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
+ PM="yum"
+ elif [ -f "/usr/bin/apt-get" ] && [ -f "/usr/bin/dpkg" ]; then
+ PM="apt-get"
+ fi
+}
+
+Auto_Swap() {
+ swap=$(free | grep Swap | awk '{print $2}')
+ if [ "${swap}" -gt 1 ]; then
+ echo "Swap total sizse: $swap"
+ return
+ fi
+ if [ ! -d /www ]; then
+ mkdir /www
+ fi
+ swapFile="/www/swap"
+ dd if=/dev/zero of=$swapFile bs=1M count=1025
+ mkswap -f $swapFile
+ swapon $swapFile
+ echo "$swapFile swap swap defaults 0 0" >>/etc/fstab
+ swap=$(free | grep Swap | awk '{print $2}')
+ if [ $swap -gt 1 ]; then
+ echo "Swap total sizse: $swap"
+ return
+ fi
+
+ sed -i "/\/www\/swap/d" /etc/fstab
+ rm -f $swapFile
+}
+Service_Add() {
+ if Command_Exists systemctl ; then
+ wget --no-check-certificate -O /usr/lib/systemd/system/btpanel.service ${download_Url}/init/systemd/btpanel.service -t 5 -T 20
+ systemctl daemon-reload
+ systemctl enable btpanel
+
+ else
+ if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ]; then
+ chkconfig --add bt
+ chkconfig --level 2345 bt on
+ elif [ "${PM}" == "apt-get" ]; then
+ update-rc.d bt defaults
+ fi
+ fi
+}
+
+Set_Centos7_Repo(){
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "[^#]mirror.centos.org")
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ echo "Centos7 official repository source has been discontinued , Replacement in progress."
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ fi
+
+ MIRROR_CHECK22=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "mirrorlist.centos.org"|grep -v '^#')
+ if [ "${MIRROR_CHECK22}" ] && [ "${is64bit}" == "64" ];then
+ echo "Centos7 official repository source has been discontinued , Replacement in progress."
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ \cp -rpa /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bt_bak
+cat > /etc/yum.repos.d/CentOS-Base.repo << EOF
+
+# CentOS-Base.repo
+
+[base]
+name=CentOS-\$releasever - Base
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=os&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/os/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#released updates
+[updates]
+name=CentOS-\$releasever - Updates
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=updates&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/updates/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that may be useful
+[extras]
+name=CentOS-\$releasever - Extras
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=extras&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/extras/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that extend functionality of existing packages
+[centosplus]
+name=CentOS-\$releasever - Plus
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=centosplus&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/centosplus/\$basearch/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+EOF
+
+ fi
+
+ ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
+ Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
+ if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
+ return
+ fi
+
+ yum install unzip -y
+ if [ "$?" != "0" ] ;then
+ TAR_CHECK=$(which tar)
+ if [ "$?" == "0" ] ;then
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ if [ -z "${download_Url}" ];then
+ download_Url="https://node.aapanel.com"
+ fi
+ curl -Ssk --connect-timeout 20 -m 60 -O ${download_Url}/src/el7repo.tar.gz
+ if [ -f "/usr/bin/wget" ] && [ ! -s "el7repo.tar.gz" ];then
+ wget --no-check-certificate -O el7repo.tar.gz ${download_Url}/src/el7repo.tar.gz -t 3 -T 20
+ fi
+ rm -f /etc/yum.repos.d/*.repo
+ tar -xvzf el7repo.tar.gz -C /etc/yum.repos.d/
+ rm -f el7repo.tar.gz
+ fi
+ fi
+
+}
+
+Set_Centos8_Repo(){
+ HUAWEI_CHECK=$(cat /etc/motd |grep "Huawei Cloud")
+ if [ "${HUAWEI_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ rm -f /etc/yum.repos.d/epel.repo
+ rm -f /etc/yum.repos.d/epel-*
+ fi
+ ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
+ if [ "${ALIYUN_CHECK}" ] && [ "${is64bit}" == "64" ] && [ ! -f "/etc/yum.repos.d/Centos-vault-8.5.2111.repo" ];then
+ rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
+ wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
+ wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
+ sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
+ sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
+ fi
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo |grep "[^#]mirror.centos.org")
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ fi
+
+ yum install unzip tar -y
+ if [ "$?" != "0" ] ;then
+ if [ -z "${download_Url}" ];then
+ download_Url="https://node.aapanel.com"
+ fi
+ if [ ! -f "/usr/bin/tar" ] ;then
+ curl -Ss --connect-timeout 20 -m 60 -O ${download_Url}/src/tar-1.30-5.el8.x86_64.rpm
+ if [ -f "/usr/bin/wget" ] && [ ! -s "tar-1.30-5.el8.x86_64.rpm" ];then
+ wget --no-check-certificate -O tar-1.30-5.el8.x86_64.rpm ${download_Url}/src/tar-1.30-5.el8.x86_64.rpm -t 3 -T 20
+ fi
+ # yum install tar-1.30-5.el8.x86_64.rpm -y
+ rpm -ivh tar-1.30-5.el8.x86_64.rpm
+ rm -f tar-1.30-5.el8.x86_64.rpm
+ fi
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ curl -Ss --connect-timeout 20 -m 60 -O ${download_Url}/src/el8repo.tar.gz
+ if [ -f "/usr/bin/wget" ] && [ ! -s "el8repo.tar.gz" ];then
+ wget --no-check-certificate -O el8repo.tar.gz ${download_Url}/src/el8repo.tar.gz -t 3 -T 20
+ fi
+ rm -f /etc/yum.repos.d/*.repo
+ tar -xvzf el8repo.tar.gz -C /etc/yum.repos.d/
+ rm -f el8repo.tar.gz
+ fi
+
+}
+
+Bored_waiting(){
+ w_time="$wait_time"
+ msg="$wait_msg"
+ progress="."
+ for ((i=0; i<${w_time}; i++))
+ do
+ printf "$msg %-10s %d\r" "$progress" "$((i+1))"
+ sleep 1
+
+ if [ "$progress" == ".........." ]; then
+ progress="."
+ else
+ progress+="."
+ fi
+ done
+ printf "$msg %-10s %d\r" ".........." "$w_time"
+ #echo ""
+}
+
+Check_apt_status(){
+
+ MAX_RETRIES=30
+ retries=0
+
+ while [ $retries -lt $MAX_RETRIES ]; do
+ output=$(ps aux| grep -E '(apt|apt-get)\s' 2>&1)
+ check_output=$(echo "$output" | grep -E '(apt|apt-get)\s')
+
+ #If check_output is empty, terminate the loop
+ if [ -z "$check_output" ]; then
+ break
+ fi
+
+ retries=$((retries + 1))
+
+ echo "apt-get is in use, it will automatically exit after ${retries}/${MAX_RETRIES} times, try again after 10 seconds..."
+ echo "$check_output"
+ wait_msg="Please wait"
+ wait_time="10"
+ Bored_waiting
+
+ done
+
+ if [ $retries -ge $MAX_RETRIES ]; then
+ Red_Error "ERROR: apt-get command exceeds the maximum wait times: ${MAX_RETRIES}." "Do not use the apt/apt-get command or install software during installation, please try to reinstall!"
+ fi
+
+}
+
+get_node_url() {
+
+ download_Url='https://node.aapanel.com'
+
+ if [ ! -f /bin/curl ]; then
+ if [ "${PM}" = "yum" ]; then
+ yum install curl -y
+ elif [ "${PM}" = "apt-get" ]; then
+ apt-get install curl -y
+ fi
+ fi
+
+ if [ -f "/www/node.pl" ];then
+ download_Url=$(cat /www/node.pl)
+ echo "Download node: $download_Url";
+ echo '---------------------------------------------';
+ return
+ fi
+
+ # echo '---------------------------------------------';
+ # echo "Selected download node...";
+ # nodes=(https://node.aapanel.com);
+
+ # if [ "$1" ];then
+ # nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
+ # fi
+ # tmp_file1=/dev/shm/net_test1.pl
+ # tmp_file2=/dev/shm/net_test2.pl
+
+ # [ -f "${tmp_file1}" ] && rm -f ${tmp_file1}
+
+ # [ -f "${tmp_file2}" ] && rm -f ${tmp_file2}
+
+ # touch $tmp_file1
+ # touch $tmp_file2
+ # for node in ${nodes[@]}; do
+ # NODE_CHECK=$(curl -k --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/net_test|xargs)
+ # 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)
+ # if [ "${NODE_STATUS}" == "200" ]; then
+ # if [ $TIME_TOTAL -lt 100 ]; then
+ # if [ $RES -ge 1500 ]; then
+ # echo "$RES $node" >>$tmp_file1
+ # fi
+ # else
+ # if [ $RES -ge 1500 ]; then
+ # echo "$TIME_TOTAL $node" >>$tmp_file2
+ # fi
+ # fi
+
+ # i=$(($i + 1))
+ # if [ $TIME_TOTAL -lt 100 ]; then
+ # if [ $RES -ge 3000 ]; then
+ # break
+ # fi
+ # fi
+
+ # fi
+ # done
+
+ # NODE_URL=$(cat $tmp_file1 | sort -r -g -t " " -k 1 | head -n 1 | awk '{print $2}')
+ # if [ -z "$NODE_URL" ]; then
+ # NODE_URL=$(cat $tmp_file2 | sort -g -t " " -k 1 | head -n 1 | awk '{print $2}')
+ # if [ -z "$NODE_URL" ]; then
+ # NODE_URL='https://node.aapanel.com'
+ # fi
+ # fi
+
+ # rm -f $tmp_file1
+ # rm -f $tmp_file2
+ # download_Url=$NODE_URL
+ # echo "Download node: $download_Url"
+ # echo '---------------------------------------------'
+
+}
+Remove_Package() {
+ local PackageNmae=$1
+ if [ "${PM}" == "yum" ]; then
+ isPackage=$(rpm -q ${PackageNmae} | grep "not installed")
+ if [ -z "${isPackage}" ]; then
+ yum remove ${PackageNmae} -y
+ fi
+ elif [ "${PM}" == "apt-get" ]; then
+ isPackage=$(dpkg -l | grep ${PackageNmae})
+ if [ "${PackageNmae}" ]; then
+ apt-get remove ${PackageNmae} -y
+ fi
+ fi
+}
+Install_RPM_Pack() {
+ yumPath=/etc/yum.conf
+ Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
+ CentOS_Stream_8=$(cat /etc/redhat-release | grep 'CentOS Stream release 8' | grep -iE 'centos|Red Hat')
+ if [ "${Centos8Check}" ] || [ "${CentOS_Stream_8}" ];then
+ Set_Centos8_Repo
+ fi
+ Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos7Check}" ];then
+ Set_Centos7_Repo
+ fi
+
+ isExc=$(cat $yumPath | grep httpd)
+ if [ "$isExc" = "" ]; then
+ echo "exclude=httpd nginx php mysql mairadb python-psutil python2-psutil" >>$yumPath
+ fi
+
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el8") ];then
+ yum config-manager --set-enabled powertools
+ yum config-manager --set-enabled PowerTools
+ fi
+
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el9") ];then
+ dnf config-manager --set-enabled crb -y
+ fi
+
+ #yumBaseUrl=$(cat /etc/yum.repos.d/CentOS-Base.repo|grep baseurl=http|cut -d '=' -f 2|cut -d '$' -f 1|head -n 1)
+ #[ "${yumBaseUrl}" ] && checkYumRepo=$(curl --connect-timeout 5 --head -s -o /dev/null -w %{http_code} ${yumBaseUrl})
+ #if [ "${checkYumRepo}" != "200" ];then
+ # curl -Ss --connect-timeout 3 -m 60 http://node.aapanel.com/install/yumRepo_select.sh|bash
+ #fi
+
+ #尝试同步时间(从bt.cn)
+ # echo 'Synchronizing system time...'
+ # getBtTime=$(curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/index/get_time)
+ # if [ "${getBtTime}" ];then
+ # date -s "$(date -d @$getBtTime +"%Y-%m-%d %H:%M:%S")"
+ # fi
+
+ #if [ -z "${Centos8Check}" ]; then
+ # yum install ntp -y
+ # rm -rf /etc/localtime
+ # ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+ #尝试同步国际时间(从ntp服务器)
+ # ntpdate 0.asia.pool.ntp.org
+ # setenforce 0
+ #fi
+ setenforce 0
+ startTime=$(date +%s)
+
+ 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 firewalld ipset libpq-devel ca-certificates sudo at mariadb rsyslog autoconf xfsprogs quota"
+ 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
+ if [ -f "/usr/bin/dnf" ]; then
+ dnf install -y redhat-rpm-config
+ fi
+
+ ALI_OS=$(cat /etc/redhat-release | grep "Alibaba Cloud Linux release 3")
+ if [ -z "${ALI_OS}" ]; then
+ yum install epel-release -y
+ fi
+}
+Install_Deb_Pack() {
+ Check_apt_status
+
+ ln -sf bash /bin/sh
+
+ UBUNTU_22=$(cat /etc/issue|grep "Ubuntu 22")
+ UBUNTU_24=$(cat /etc/issue|grep "Ubuntu 24")
+ if [ "${UBUNTU_22}" ] || [ "${UBUNTU_24}" ];then
+ apt-get remove needrestart -y
+ fi
+ apt-get update -y
+ apt-get install bash -y
+ if [ -f "/usr/bin/bash" ];then
+ ln -sf /usr/bin/bash /bin/sh
+ fi
+
+ FNOS_CHECK=$(grep fnOS /etc/issue)
+ if [ "${FNOS_CHECK}" ];then
+ apt-get install libc6 -y --allow-change-held-packages
+ apt-get install libc6-dev -y --allow-change-held-packages
+ fi
+
+ apt-get install ruby -y
+ apt-get install lsb-release -y
+ #apt-get install ntp ntpdate -y
+ #/etc/init.d/ntp stop
+ #update-rc.d ntp remove
+ #cat >>~/.profile</var/spool/cron/crontabs/root
+ chmod 600 /var/spool/cron/crontabs/root
+ fi
+ fi
+}
+
+Ubuntu_20_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb http://archive.ubuntu.com/ubuntu focal main restricted
+# deb-src http://archive.ubuntu.com/ubuntu focal main restricted
+
+deb http://ubuntu.mirror.constant.com focal main restricted
+# deb-src http://ubuntu.mirror.constant.com focal main restricted
+
+deb http://archive.ubuntu.com/ubuntu focal-updates main restricted
+# deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted
+
+deb http://ubuntu.mirror.constant.com focal-updates main restricted
+# deb-src http://ubuntu.mirror.constant.com focal-updates main restricted
+
+deb http://archive.ubuntu.com/ubuntu focal universe
+# deb-src http://archive.ubuntu.com/ubuntu focal universe
+deb http://archive.ubuntu.com/ubuntu focal-updates universe
+# deb-src http://archive.ubuntu.com/ubuntu focal-updates universe
+
+deb http://ubuntu.mirror.constant.com focal universe
+# deb-src http://ubuntu.mirror.constant.com focal universe
+deb http://ubuntu.mirror.constant.com focal-updates universe
+# deb-src http://ubuntu.mirror.constant.com focal-updates universe
+
+deb http://archive.ubuntu.com/ubuntu focal multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal multiverse
+deb http://archive.ubuntu.com/ubuntu focal-updates multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal-updates multiverse
+
+deb http://ubuntu.mirror.constant.com focal multiverse
+# deb-src http://ubuntu.mirror.constant.com focal multiverse
+deb http://ubuntu.mirror.constant.com focal-updates multiverse
+# deb-src http://ubuntu.mirror.constant.com focal-updates multiverse
+
+deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
+
+deb http://ubuntu.mirror.constant.com focal-backports main restricted universe multiverse
+# deb-src http://ubuntu.mirror.constant.com focal-backports main restricted universe multiverse
+
+deb http://archive.ubuntu.com/ubuntu focal-security main restricted
+# deb-src http://archive.ubuntu.com/ubuntu focal-security main restricted
+deb http://archive.ubuntu.com/ubuntu focal-security universe
+# deb-src http://archive.ubuntu.com/ubuntu focal-security universe
+deb http://archive.ubuntu.com/ubuntu focal-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal-security multiverse
+
+deb http://ubuntu.mirror.constant.com focal-security main restricted
+# deb-src http://ubuntu.mirror.constant.com focal-security main restricted
+deb http://ubuntu.mirror.constant.com focal-security universe
+# deb-src http://ubuntu.mirror.constant.com focal-security universe
+deb http://ubuntu.mirror.constant.com focal-security multiverse
+# deb-src http://ubuntu.mirror.constant.com focal-security multiverse
+
+EOF
+
+}
+
+Ubuntu_22_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb http://archive.ubuntu.com/ubuntu jammy main restricted
+# deb-src http://archive.ubuntu.com/ubuntu jammy main restricted
+
+deb http://ubuntu.mirror.constant.com jammy main restricted
+# deb-src http://ubuntu.mirror.constant.com jammy main restricted
+
+deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted
+# deb-src http://archive.ubuntu.com/ubuntu jammy-updates main restricted
+
+deb http://ubuntu.mirror.constant.com jammy-updates main restricted
+# deb-src http://ubuntu.mirror.constant.com jammy-updates main restricted
+
+deb http://archive.ubuntu.com/ubuntu jammy universe
+# deb-src http://archive.ubuntu.com/ubuntu jammy universe
+deb http://archive.ubuntu.com/ubuntu jammy-updates universe
+# deb-src http://archive.ubuntu.com/ubuntu jammy-updates universe
+
+deb http://ubuntu.mirror.constant.com jammy universe
+# deb-src http://ubuntu.mirror.constant.com jammy universe
+deb http://ubuntu.mirror.constant.com jammy-updates universe
+# deb-src http://ubuntu.mirror.constant.com jammy-updates universe
+
+deb http://archive.ubuntu.com/ubuntu jammy multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy multiverse
+deb http://archive.ubuntu.com/ubuntu jammy-updates multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy-updates multiverse
+
+deb http://ubuntu.mirror.constant.com jammy multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy multiverse
+deb http://ubuntu.mirror.constant.com jammy-updates multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy-updates multiverse
+
+deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
+
+deb http://ubuntu.mirror.constant.com jammy-backports main restricted universe multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy-backports main restricted universe multiverse
+
+deb http://archive.ubuntu.com/ubuntu jammy-security main restricted
+# deb-src http://archive.ubuntu.com/ubuntu jammy-security main restricted
+deb http://archive.ubuntu.com/ubuntu jammy-security universe
+# deb-src http://archive.ubuntu.com/ubuntu jammy-security universe
+deb http://archive.ubuntu.com/ubuntu jammy-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy-security multiverse
+
+deb http://ubuntu.mirror.constant.com jammy-security main restricted
+# deb-src http://ubuntu.mirror.constant.com jammy-security main restricted
+deb http://ubuntu.mirror.constant.com jammy-security universe
+# deb-src http://ubuntu.mirror.constant.com jammy-security universe
+deb http://ubuntu.mirror.constant.com jammy-security multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy-security multiverse
+
+EOF
+
+}
+
+
+Ubuntu_24_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb http://archive.ubuntu.com/ubuntu noble main restricted
+# deb-src http://archive.ubuntu.com/ubuntu noble main restricted
+
+deb http://ubuntu.mirror.constant.com noble main restricted
+# deb-src http://ubuntu.mirror.constant.com noble main restricted
+
+deb http://archive.ubuntu.com/ubuntu noble-updates main restricted
+# deb-src http://archive.ubuntu.com/ubuntu noble-updates main restricted
+
+deb http://ubuntu.mirror.constant.com noble-updates main restricted
+# deb-src http://ubuntu.mirror.constant.com noble-updates main restricted
+
+deb http://archive.ubuntu.com/ubuntu noble universe
+# deb-src http://archive.ubuntu.com/ubuntu noble universe
+deb http://archive.ubuntu.com/ubuntu noble-updates universe
+# deb-src http://archive.ubuntu.com/ubuntu noble-updates universe
+
+deb http://ubuntu.mirror.constant.com noble universe
+# deb-src http://ubuntu.mirror.constant.com noble universe
+deb http://ubuntu.mirror.constant.com noble-updates universe
+# deb-src http://ubuntu.mirror.constant.com noble-updates universe
+
+deb http://archive.ubuntu.com/ubuntu noble multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble multiverse
+deb http://archive.ubuntu.com/ubuntu noble-updates multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble-updates multiverse
+
+deb http://ubuntu.mirror.constant.com noble multiverse
+# deb-src http://ubuntu.mirror.constant.com noble multiverse
+deb http://ubuntu.mirror.constant.com noble-updates multiverse
+# deb-src http://ubuntu.mirror.constant.com noble-updates multiverse
+
+deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
+
+deb http://ubuntu.mirror.constant.com noble-backports main restricted universe multiverse
+# deb-src http://ubuntu.mirror.constant.com noble-backports main restricted universe multiverse
+
+deb http://archive.ubuntu.com/ubuntu noble-security main restricted
+# deb-src http://archive.ubuntu.com/ubuntu noble-security main restricted
+deb http://archive.ubuntu.com/ubuntu noble-security universe
+# deb-src http://archive.ubuntu.com/ubuntu noble-security universe
+deb http://archive.ubuntu.com/ubuntu noble-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble-security multiverse
+
+deb http://ubuntu.mirror.constant.com noble-security main restricted
+# deb-src http://ubuntu.mirror.constant.com noble-security main restricted
+deb http://ubuntu.mirror.constant.com noble-security universe
+# deb-src http://ubuntu.mirror.constant.com noble-security universe
+deb http://ubuntu.mirror.constant.com noble-security multiverse
+# deb-src http://ubuntu.mirror.constant.com noble-security multiverse
+
+EOF
+
+}
+
+Debian_11_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb https://deb.debian.org/debian bullseye main contrib non-free
+deb-src https://deb.debian.org/debian bullseye main contrib non-free
+
+deb https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
+deb-src https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
+
+deb https://deb.debian.org/debian bullseye-updates main contrib non-free
+deb-src https://deb.debian.org/debian bullseye-updates main contrib non-free
+
+#deb https://deb.debian.org/debian bullseye-backports main contrib non-free
+#deb-src https://deb.debian.org/debian bullseye-backports main contrib non-free
+
+deb https://debian.mirror.constant.com bullseye main contrib non-free
+deb-src https://debian.mirror.constant.com bullseye main contrib non-free
+
+EOF
+
+}
+
+
+Debian_12_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb https://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
+deb-src https://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
+
+deb https://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
+deb-src https://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
+
+deb https://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
+deb-src https://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
+
+#deb https://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
+#deb-src https://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
+
+deb https://debian.mirror.constant.com bookworm main contrib non-free non-free-firmware
+deb-src https://debian.mirror.constant.com bookworm main contrib non-free non-free-firmware
+
+EOF
+
+}
+
+
+Change_sources () {
+ if [ -s /etc/os-release ] && [ -s /etc/issue ]; then
+ . /etc/os-release
+ echo "detected OS: $ID - $VERSION_ID"
+
+ UD_os_version=$(cat /etc/issue | grep Ubuntu | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ OS_v=Ubuntu
+ if [ "${UD_os_version}" = "" ]; then
+ OS_v=Debian
+ UD_os_version=$(cat /etc/issue | grep Debian | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '[0-9]+')
+ if [ "${UD_os_version}" = "" ]; then
+ UD_os_version=$(cat /etc/issue | grep Debian | grep -Eo '[0-9]+')
+ fi
+ fi
+ echo "detected OS version: $OS_v $UD_os_version"
+
+ if [ $ID == "debian" ] && [ $OS_v == "Debian" ]; then
+ if [ $VERSION_ID == "11" ] && [ $UD_os_version == "11" ]; then
+ Debian_11_sources
+ elif [ $VERSION_ID == "12" ] && [ $UD_os_version == "12" ]; then
+ Debian_12_sources
+ else
+ echo -e "\033[31mSorry: $OS_v $UD_os_version This system does not support changing apt source, please try to change it yourself. \033[0m"
+ Change_apt_sources="no"
+ fi
+
+ elif [ $ID == "ubuntu" ] && [ $OS_v == "Ubuntu" ]; then
+ if [ `echo "$VERSION_ID" | cut -b-2 ` == "20" ] && [ $UD_os_version == "20" ]; then
+ Ubuntu_20_sources
+ elif [ `echo "$VERSION_ID" | cut -b-2 ` == "22" ] && [ $UD_os_version == "22" ]; then
+ Ubuntu_22_sources
+ elif [ `echo "$VERSION_ID" | cut -b-2 ` == "24" ] && [ $UD_os_version == "24" ]; then
+ Ubuntu_24_sources
+ else
+ echo -e "\033[31mSorry: $OS_v $UD_os_version This system does not support changing apt source, please try to change it yourself. \033[0m"
+ Change_apt_sources="no"
+ fi
+ else
+ echo -e "\033[31mSorry: $OS_v $UD_os_version This system does not support changing apt source, please try to change it yourself. \033[0m"
+ Change_apt_sources="no"
+ fi
+
+ fi
+}
+
+Check_Change_official_sources () {
+ if [ -s /etc/apt/sources.list ]; then
+ ubuntu_sources=$(grep "\.ubuntu\.com" /etc/apt/sources.list | grep -v '^#' | grep -v "security\.ubuntu\.com")
+ debian_sources=$(grep "\.debian\.org" /etc/apt/sources.list | grep -v '^#' | grep -v "security\.debian\.org")
+
+ if [ "$ubuntu_sources" = "" ] && [ "$debian_sources" = "" ]; then
+ while [ "$yes2" != 'yes' ] && [ "$yes2" != 'no' ]; do
+ read -p "Found that apt source cannot be used. Do need to change it to the official source? [yes/no] " yes2
+ done
+ if [ "$yes2" = "yes" ]; then
+
+ Backup_sources_time=$(date +%Y_%m_%d_%H_%M_%S)
+ cp -arpf /etc/apt/sources.list /etc/apt/sources.list_aapanel_${Backup_sources_time}
+ echo -e "The sources.list file has been backup. The backup file name is:\033[31m /etc/apt/sources.list_aapanel_${Backup_sources_time} \033[0m"
+
+ Change_sources
+
+ if [ "${Change_apt_sources}" != "no" ]; then
+ Install_Deb_Pack
+ fi
+
+ fi
+ fi
+ fi
+}
+
+
+Check_Install_Sys_Packs() {
+ echo "Checking necessary dependency system packages"
+ # Define functions for installation packages
+ install_package() {
+ local package=$1
+ if [ "${PM}" = "yum" ]; then
+ yum install "$package" -y
+ elif [ "${PM}" = "apt-get" ]; then
+ dpkg --configure -a
+ apt-get update
+ apt-get install "$package" -y
+ fi
+ }
+
+ # Define a function to install and verify
+ install_and_verify() {
+ local package_name=$1
+ local command_name=$2
+
+ # First try installing directly
+ if ! Command_Exists "$command_name"; then
+ install_package "$package_name"
+ fi
+
+ # try change official sources
+ if [ ! -f "/usr/bin/$command_name" ] && [ ! -f "/bin/$command_name" ] && ! Command_Exists "$command_name"; then
+ Check_Change_official_sources
+ fi
+
+ # Check again, if it is still missing, an error message will be reported.
+ if [ ! -f "/usr/bin/$command_name" ] && [ ! -f "/bin/$command_name" ] && ! Command_Exists "$command_name"; then
+ echo -e "\033[31mERROR: "$command_name" command does not exist, try the following solutions:\033[0m"
+ echo -e "1. Use command reinstall dependent packages: \033[31m ${PM} reinstall -y $package_name \033[0m"
+ echo -e "2. Check if system source is available? Try changing available system sources"
+ echo -e "After solving the above problems, please try to reinstall!"
+ if [ -s /etc/apt/sources.list ]; then
+ Vive_source=$(grep -v '^#' /etc/apt/sources.list | grep -Ev "^\s*$|security\.ubuntu\.com|security\.debian\.org" | head -n 1)
+ Vive_source="apt source: $Vive_source"
+ # echo "$Vive_source"
+ fi
+ Red_Error "Error: $command_name command not found, please install $package_name command. $Vive_source"
+ fi
+ }
+
+ # Install and check unzip
+ install_and_verify "unzip" "unzip"
+
+ # Install and check tar
+ install_and_verify "tar" "tar"
+
+ # Install and check wget
+ install_and_verify "wget" "wget"
+}
+
+Get_Versions() {
+ redhat_version_file="/etc/redhat-release"
+ deb_version_file="/etc/issue"
+
+ if [[ $(grep "Amazon Linux" /etc/os-release) ]]; then
+ os_type="Amazon-"
+ os_version=$(cat /etc/os-release | grep "Amazon Linux" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ yum install cronie -y
+ return
+ fi
+
+ if [[ $(grep OpenCloudOS /etc/os-release) ]]; then
+ os_type="OpenCloudOS-"
+ os_version=$(cat /etc/os-release | grep OpenCloudOS | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [[ $os_version == "7" ]]; then
+ os_type="el"
+ os_version="7"
+ fi
+ return
+ fi
+
+ if [[ $(grep "Linux Mint" $deb_version_file) ]]; then
+ os_version=$(cat $deb_version_file | grep "Linux Mint" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_version=$(cat $deb_version_file | grep "Linux Mint" | grep -Eo '[0-9]+')
+ fi
+ # Linux-Mint 使用 ubuntu pyenv
+ os_type='ubuntu'
+ if [[ "$os_version" =~ "21" ]]; then
+ os_version="22"
+ echo "$os_version"
+ fi
+ if [[ "$os_version" =~ "20" ]]; then
+ os_version="20"
+ echo "$os_version"
+ fi
+ return
+ fi
+
+ if [[ $(grep openEuler /etc/os-release) ]]; then
+ os_type="openEuler-"
+ os_version=$(cat /etc/os-release | grep openEuler | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep AlmaLinux /etc/os-release) ]]; then
+ os_type="Alma-"
+ os_version=$(cat /etc/os-release | grep AlmaLinux | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep Rocky /etc/os-release) ]]; then
+ os_type="Rocky-"
+ os_version=$(cat /etc/os-release | grep Rocky | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep Anolis /etc/os-release) ]] && [[ $(grep VERSION /etc/os-release|grep 8.8) ]];then
+ if [ -f "/usr/bin/yum" ];then
+ os_type="anolis"
+ os_version="8"
+ return
+ fi
+ fi
+
+ if [ -s $redhat_version_file ]; then
+ os_type='el'
+ if [[ $(grep 'Alibaba Cloud Linux (Aliyun Linux) release 2' $redhat_version_file) ]]; then
+ os_version="7"
+ return
+ fi
+
+ is_aliyunos=$(cat $redhat_version_file | grep Aliyun)
+ if [ "$is_aliyunos" != "" ]; then
+ return
+ fi
+
+ if [[ $(grep "Red Hat" $redhat_version_file) ]]; then
+ os_type='el'
+ os_version=$(cat $redhat_version_file | grep "Red Hat" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]')
+ return
+ fi
+
+ if [[ $(grep "Alibaba Cloud Linux release 3 " /etc/redhat-release) ]]; then
+ os_type="ali-linux-"
+ os_version="3"
+ return
+ fi
+
+ if [[ $(grep "Alibaba Cloud" /etc/redhat-release) ]] && [[ $(grep al8 /etc/os-release) ]];then
+ os_type="ali-linux-"
+ os_version="al8"
+ return
+ fi
+
+ if [[ $(grep TencentOS /etc/redhat-release) ]]; then
+ os_type="TencentOS-"
+ os_version=$(cat /etc/redhat-release | grep TencentOS | grep -Eo '([0-9]+\.)+[0-9]+')
+ if [[ $os_version == "2.4" ]]; then
+ os_type="el"
+ os_version="7"
+ elif [[ $os_version == "3.1" ]]; then
+ os_version="3.1"
+ fi
+ return
+ fi
+
+ os_version=$(cat $redhat_version_file | grep CentOS | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]')
+ if [ "${os_version}" = "5" ]; then
+ os_version=""
+ fi
+ if [ -z "${os_version}" ]; then
+ os_version=$(cat /etc/redhat-release | grep Stream | grep -oE "8|9")
+ fi
+ else
+ os_type='ubuntu'
+ os_version=$(cat $deb_version_file | grep Ubuntu | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_type='debian'
+ os_version=$(cat $deb_version_file | grep Debian | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_version=$(cat $deb_version_file | grep Debian | grep -Eo '[0-9]+')
+ fi
+ if [ "${os_version}" = "8" ]; then
+ os_version=""
+ fi
+ if [ "${is64bit}" = '32' ]; then
+ os_version=""
+ fi
+ else
+ if [ "$os_version" = "14" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "12" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "19" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "21" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "20" ]; then
+ os_version2004=$(cat /etc/issue | grep 20.04)
+ if [ -z "${os_version2004}" ]; then
+ os_version=""
+ fi
+ fi
+ fi
+ fi
+}
+
+Install_Openssl111(){
+ Get_Versions
+ if [ -f "/www/server/panel/openssl_make.pl" ]; then
+ # 存在时编译
+ openssl_make="yes"
+ rm -f /www/server/panel/openssl_make.pl
+ fi
+
+ CPU_arch=$(uname -m)
+ if [ "${CPU_arch}" == "aarch64" ];then
+ CPU_arch="-aarch64"
+ elif [ "${CPU_arch}" == "x86_64" ];then
+ # x86_64 默认为空
+ CPU_arch=""
+ else
+ openssl_make="yes"
+ fi
+
+ if [[ $os_type = "el" ]] && [[ $os_version == "7" ]] && [[ $openssl_make != "yes" ]]; then
+ wget --no-check-certificate -O openssl111.tar.gz ${download_Url}/install/src/openssl111${CPU_arch}.tar.gz -t 5 -T 20
+ tmp_size=$(du -b openssl111.tar.gz | awk '{print $1}')
+ if [ $tmp_size -lt 5014046 ]; then
+ rm -f openssl111.tar.gz
+ Red_Error "ERROR: Download openssl111.tar.gz fielded."
+ fi
+ tar zxvf openssl111.tar.gz -C /usr/local/
+ rm -f openssl111.tar.gz
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ];then
+ Red_Error "/usr/local/openssl111/bin/openssl file does not exist!"
+ fi
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ else
+ if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
+ yum install -y perl lksctp-tools-devel
+ else
+ apt install -y perl
+ fi
+ opensslVersion="1.1.1o"
+ wget --no-check-certificate -O openssl-${opensslVersion}.tar.gz ${download_Url}/src/openssl-${opensslVersion}.tar.gz -t 5 -T 20
+ tmp_size=$(du -b openssl-${opensslVersion}.tar.gz | awk '{print $1}')
+ if [ $tmp_size -lt 9056386 ]; then
+ rm -f openssl-${opensslVersion}.tar.gz
+ Red_Error "ERROR: Download openssl-${opensslVersion}.tar.gz fielded."
+ fi
+ tar -zxvf openssl-${opensslVersion}.tar.gz
+ if [ ! -d "openssl-${opensslVersion}" ];then
+ Red_Error "Decompression failed openssl-${opensslVersion} Directory does not exist!"
+ fi
+ cd openssl-${opensslVersion}
+ ./config --prefix=/usr/local/openssl111 --openssldir=/usr/local/openssl111 enable-md2 enable-rc5 sctp zlib-dynamic shared -fPIC
+ make -j$cpu_cpunt
+ make install
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ];then
+ Red_Error "Compilation failed /usr/local/openssl111/bin/openssl file does not exist!"
+ fi
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ cd ..
+ rm -rf openssl-${opensslVersion} openssl-${opensslVersion}.tar.gz
+ fi
+ openssl111Check=$(/usr/local/openssl111/bin/openssl version|grep 1.1.1)
+ if [ -z "${openssl111Check}" ];then
+ Red_Error "openssl-1.1.1 install failed!"
+ fi
+}
+
+Update_Py_Lib(){
+# Need to use Werkzeug 2.2.3
+ mypip="/www/server/panel/pyenv/bin/pip3"
+ Werkzeug_path="/www/server/panel/script/Werkzeug-2.2.3-py3-none-any.whl"
+ pycountry_path="/www/server/panel/script/pycountry-24.6.1-py3-none-any.whl"
+ # pyOpenSSL_path="/www/server/panel/script/pyOpenSSL-23.1.1-py3-none-any.whl"
+
+ change_pip_package_list=$( $mypip list | grep -E "Werkzeug|lxml|pycountry" )
+ #change_pip_package_list=$( $mypip list | grep -E "Werkzeug|lxml" )
+
+ Werkzeug_v=$(echo "$change_pip_package_list" | grep Werkzeug | grep 2.2.3)
+ if [ "$Werkzeug_v" = "" ];then
+ echo "Update Werkzeug"
+ $mypip uninstall Werkzeug -y
+ $mypip install $Werkzeug_path
+
+ Werkzeug_v_2=$($mypip list |grep Werkzeug | grep 2.2.3)
+ if [ "$Werkzeug_v_2" = "" ];then
+ $mypip install Werkzeug==2.2.3
+ fi
+ fi
+
+ pycountry_v=$(echo "$change_pip_package_list" | grep pycountry)
+ if [ "$pycountry_v" = "" ];then
+ echo "Update pycountry"
+ $mypip install $pycountry_path
+ rm -f $pycountry_path
+
+ pycountry_v_2=$($mypip list |grep pycountry)
+ if [ "$pycountry_v_2" = "" ];then
+ $mypip install pycountry
+ fi
+ fi
+
+ # pyOpenSSL_v=$(echo "$change_pip_package_list" | grep pyOpenSSL | grep 23.1.1)
+ # if [ "$pyOpenSSL_v" = "" ];then
+ # echo "Update pyOpenSSL"
+ # $mypip uninstall pyOpenSSL cryptography -y
+ # $mypip install $pyOpenSSL_path cryptography==40.0.2
+
+ # pyOpenSSL_v_2=$($mypip list |grep pyOpenSSL | grep 23.1.1)
+ # if [ "$pyOpenSSL_v_2" = "" ];then
+ # $mypip install pyOpenSSL==23.1.1 cryptography==40.0.2
+ # fi
+ # fi
+
+ lxml_v=$(echo "$change_pip_package_list" | grep lxml | grep 5.2.1)
+ if [ "$lxml_v" != "" ];then
+ echo "Update lxml"
+ $mypip uninstall lxml -y
+ # bt 16 升级脚本时安装,安装时间久 这里不开,下面进行处理了
+ # echo "Please wait a moment to install lxml, it will take a long time."
+ # $mypip install lxml==5.0.0
+
+ # lxml_v_2=$($mypip list |grep lxml | grep 5.2.1)
+ # if [ "$lxml_v_2" = "" ];then
+ # $mypip install lxml==5.0.0
+ # fi
+ fi
+
+}
+
+Check_PIP_Packages(){
+
+ mypip="/www/server/panel/pyenv/bin/pip3"
+ show_pip_list_panel="/tmp/show_pip_list_panel.txt"
+
+ trusted_host="--trusted-host mirrors.tencent.com --trusted-host pypi.doubanio.com --trusted-host mirrors.aliyun.com --trusted-host pypi.tuna.tsinghua.edu.cn --trusted-host pypi.org"
+
+ echo "Check pip package, please wait..."
+
+ ${mypip} list | awk '{print $1}' > ${show_pip_list_panel}
+
+ check_pip_packs="/www/server/panel/check-pip-packs.txt"
+ if [ ! -s "${check_pip_packs}" ]; then
+ check_pip_packs="/tmp/check-pip-packs_3.12.txt"
+ wget --no-check-certificate -O ${check_pip_packs} ${download_Url}/install/pyenv/3.12/check-pip-packs_3.12.txt -t 5 -T 20
+ fi
+
+ Install_PIP_PACKS_File="/www/server/panel/requirements.txt"
+ if [ ! -s "${Install_PIP_PACKS_File}" ]; then
+ Install_PIP_PACKS_File="/tmp/pip_en_3.12.txt"
+ wget --no-check-certificate -O ${Install_PIP_PACKS_File} ${download_Url}/install/pyenv/3.12/pip_en_3.12.txt -t 5 -T 20
+ fi
+
+ PIP_PACKS=$(cat ${check_pip_packs} )
+ for ONE_PACK in ${PIP_PACKS};
+ do
+ Install_PIP_PACKS=`grep "^${ONE_PACK}==" ${Install_PIP_PACKS_File}`
+ if [ -z "${Install_PIP_PACKS}" ]; then
+ Install_PIP_PACKS=${ONE_PACK}
+ fi
+ Show_PIP_PACK=`grep "^${ONE_PACK}\$" ${show_pip_list_panel}`
+ # echo ${Show_PIP_PACK}
+ if [ -z "${Show_PIP_PACK}" ];then
+ if [[ "${ONE_PACK}" == "aliyun-python-sdk-kms" || "${ONE_PACK}" == "aliyun-python-sdk-core" || "${ONE_PACK}" == "aliyun-python-sdk-core-v3" || "${ONE_PACK}" == "qiniu" || "${ONE_PACK}" == "cos-python-sdk-v5" ]]; then
+ echo "Install packages: ${Install_PIP_PACKS}" >/dev/null 2>&1
+ else
+ echo "Install packages: ${Install_PIP_PACKS}"
+ fi
+
+ if [[ "${ONE_PACK}" == "Flask" ]]; then
+ ${mypip} uninstall Flask Werkzeug -y
+ ${mypip} install Flask==2.2.5 Werkzeug==2.2.3 ${trusted_host}
+ elif [[ "${ONE_PACK}" == "Werkzeug" ]]; then
+ ${mypip} install Werkzeug==2.2.3 ${trusted_host}
+ elif [[ "${ONE_PACK}" == "aliyun-python-sdk-kms" || "${ONE_PACK}" == "aliyun-python-sdk-core" || "${ONE_PACK}" == "aliyun-python-sdk-core-v3" || "${ONE_PACK}" == "qiniu" || "${ONE_PACK}" == "cos-python-sdk-v5" ]]; then
+ echo "${Install_PIP_PACKS} ..." >/dev/null 2>&1
+ else
+ ${mypip} install ${Install_PIP_PACKS} ${trusted_host}
+ fi
+ fi
+ done
+
+}
+
+Install_Python_Lib() {
+
+ # openssl 版本低于1.1.1 需要安装 如CentOS 7
+ OPENSSL_VER=$(openssl version|grep -oE '1.0|1.1.0')
+ if [ "${OPENSSL_VER}" ]; then
+
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ]; then
+ Install_Openssl111
+ else
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ openssl111Check=$(/usr/local/openssl111/bin/openssl version|grep 1.1.1)
+ if [ -z "${openssl111Check}" ];then
+ Install_Openssl111
+ fi
+ if [ ! -f "/etc/ld.so.conf.d/openssl111.conf" ] || [ ! -f "/etc/ld.so.conf.d/zopenssl111.conf" ]; then
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ fi
+ fi
+ Use_Openssl111="yes"
+ fi
+
+ curl -sSk --connect-timeout 5 -m 60 $download_Url/install/pip_select.sh | bash
+ pyenv_path="/www/server/panel"
+ if [ -f $pyenv_path/pyenv/bin/python ]; then
+ is_ssl=$($python_bin -c "import ssl" 2>&1 | grep cannot)
+ $pyenv_path/pyenv/bin/python3.12 -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 --no-check-certificate -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/3.12/pip_en_3.12.txt -t 5 -T 20
+ $pyenv_path/pyenv/bin/pip install -U pip
+ $pyenv_path/pyenv/bin/pip install -U setuptools
+ $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
+
+ py_version="3.12.3"
+ python_version="-3.12"
+ mkdir -p $pyenv_path
+ echo "True" >/www/disk.pl
+ if [ ! -w /www/disk.pl ]; then
+ Red_Error "ERROR: Install python env fielded." "ERROR: path [www] cannot be written, please check the directory/user/disk permissions!"
+ fi
+ os_type='el'
+ os_version='7'
+ is_export_openssl=0
+ Get_Versions
+ echo "OS: $os_type - $os_version"
+ is_aarch64=$(uname -m | grep aarch64)
+ if [ "$is_aarch64" != "" ]; then
+ is64bit="aarch64"
+ fi
+ if [ -f "/www/server/panel/pymake.pl" ]; then
+ os_version=""
+ rm -f /www/server/panel/pymake.pl
+ fi
+ if [ "${os_version}" != "" ]; then
+ pyenv_file="/www/pyenv.tar.gz"
+ wget --no-check-certificate -O $pyenv_file $download_Url/install/pyenv/3.12/pyenv-${os_type}${os_version}-x${is64bit}${python_version}.tar.gz -t 5 -T 20
+ if [ "$?" != "0" ];then
+ get_node_url $download_Url
+ wget --no-check-certificate -O $pyenv_file $download_Url/install/pyenv/3.12/pyenv-${os_type}${os_version}-x${is64bit}${python_version}.tar.gz -t 5 -T 20
+ fi
+ tmp_size=$(du -b $pyenv_file | awk '{print $1}')
+ if [ $tmp_size -lt 122271175 ]; then
+ rm -f $pyenv_file
+ echo "ERROR: Download python env fielded."
+ else
+ echo "Install python env..."
+ 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. Please try to reinstall"
+ fi
+ $pyenv_path/pyenv/bin/python3.12 -V
+ if [ $? -eq 0 ]; then
+ rm -f $pyenv_file
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 /usr/bin/btpip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 /usr/bin/btpython
+ source $pyenv_path/pyenv/bin/activate
+ return
+ else
+ rm -f $pyenv_file
+ rm -rf $pyenv_path/pyenv
+ fi
+ fi
+ fi
+
+ cd /www
+ python_src='/www/python_src.tar.xz'
+ python_src_path="/www/Python-${py_version}"
+ wget --no-check-certificate -O $python_src $download_Url/src/Python-${py_version}.tar.xz -t 5 -T 20
+ 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. Please try to reinstall OS_${os_type}_${os_version}."
+ fi
+ tar xvf $python_src
+ rm -f $python_src
+ cd $python_src_path
+ if [[ $Use_Openssl111 = "yes" ]]; then
+ # centos7 或者低openssl于1.1.1使用
+ export OPENSSL_DIR=/usr/local/openssl111
+ ./configure --prefix=$pyenv_path/pyenv \
+ LDFLAGS="-L$OPENSSL_DIR/lib" \
+ CPPFLAGS="-I$OPENSSL_DIR/include" \
+ --with-openssl=$OPENSSL_DIR
+ else
+ ./configure --prefix=$pyenv_path/pyenv
+ fi
+
+ make -j$cpu_cpunt
+ make install
+ if [ ! -f $pyenv_path/pyenv/bin/python3.12 ]; then
+ rm -rf $python_src_path
+ Red_Error "ERROR: Make python env fielded. Please try to reinstall"
+ fi
+ cd ~
+ rm -rf $python_src_path
+ wget --no-check-certificate -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -t 5 -T 20
+ wget --no-check-certificate -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/3.12/pip-3.12.3.txt -t 5 -T 20
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 $pyenv_path/pyenv/bin/pip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 $pyenv_path/pyenv/bin/python
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 /usr/bin/btpip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 /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 wheel==0.34.2
+ $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.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
+ Check_PIP_Packages
+ 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
+ fi
+}
+
+delete_useless_package() {
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-kms -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-core -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-core-v3 -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall qiniu -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall cos-python-sdk-v5 -y >/dev/null 2>&1
+}
+
+Install_Bt() {
+ if [ -f ${setup_path}/server/panel/data/port.pl ]; then
+ panelPort=$(cat ${setup_path}/server/panel/data/port.pl)
+ fi
+
+ if [ "${PANEL_PORT}" ];then
+ panelPort=$PANEL_PORT
+ fi
+
+ mkdir -p ${setup_path}/server/panel/logs
+ mkdir -p ${setup_path}/server/panel/vhost/apache
+ mkdir -p ${setup_path}/server/panel/vhost/nginx
+ mkdir -p ${setup_path}/server/panel/vhost/rewrite
+ mkdir -p ${setup_path}/server/panel/install
+ mkdir -p /www/server
+ mkdir -p /www/wwwroot
+ mkdir -p /www/wwwlogs
+ mkdir -p /www/backup/database
+ mkdir -p /www/backup/site
+
+ if [ ! -d "/etc/init.d" ];then
+ mkdir -p /etc/init.d
+ fi
+
+ if [ -f "/etc/init.d/bt" ]; then
+ /etc/init.d/bt stop
+ sleep 1
+ fi
+
+ panel_file="${setup_path}/panel.zip"
+ wget --no-check-certificate -O ${panel_file} ${Btapi_Url}/install/src/panel_7_en.zip -t 5 -T 20
+
+ tmp_size=$(du -b ${panel_file} | awk '{print $1}')
+ if [ $tmp_size -lt 10026905 ]; then
+ ls -lh ${panel_file}
+ rm -f ${panel_file}
+ Red_Error "ERROR: Failed to download panel, please try install again!"
+ fi
+
+ # wget --no-check-certificate -O /etc/init.d/bt ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ # wget --no-check-certificate -O /www/server/panel/init.sh ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ # wget --no-check-certificate -O /www/server/panel/install/public.sh ${download_Url}/install/public.sh -t 5 -T 20
+
+ if [ -f "${setup_path}/server/panel/data/default.db" ]; then
+ if [ -d "/${setup_path}/server/panel/old_data" ]; then
+ rm -rf ${setup_path}/server/panel/old_data
+ fi
+ mkdir -p ${setup_path}/server/panel/old_data
+ d_format=$(date +"%Y%m%d_%H%M%S")
+ \cp -arf ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/data/default_backup_${d_format}.db
+ mv -f ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/old_data/default.db
+ mv -f ${setup_path}/server/panel/data/system.db ${setup_path}/server/panel/old_data/system.db
+ mv -f ${setup_path}/server/panel/data/port.pl ${setup_path}/server/panel/old_data/port.pl
+ mv -f ${setup_path}/server/panel/data/admin_path.pl ${setup_path}/server/panel/old_data/admin_path.pl
+ fi
+
+ unzip -o ${panel_file} -d ${setup_path}/server/ >/dev/null
+
+ if [ -d "${setup_path}/server/panel/old_data" ]; then
+ mv -f ${setup_path}/server/panel/old_data/default.db ${setup_path}/server/panel/data/default.db
+ mv -f ${setup_path}/server/panel/old_data/system.db ${setup_path}/server/panel/data/system.db
+ mv -f ${setup_path}/server/panel/old_data/port.pl ${setup_path}/server/panel/data/port.pl
+ mv -f ${setup_path}/server/panel/old_data/admin_path.pl ${setup_path}/server/panel/data/admin_path.pl
+ if [ -d "/${setup_path}/server/panel/old_data" ]; then
+ rm -rf ${setup_path}/server/panel/old_data
+ fi
+ fi
+
+ if [ ! -f "${setup_path}/server/panel/tools.py" ] || [ ! -f "${setup_path}/server/panel/BT-Panel" ]; then
+ ls -lh ${setup_path}/server/panel/BT-* ${setup_path}/server/panel/tools.py
+ Red_Error "ERROR: tools.py BT-Panel file does not exist, please try install again!"
+ fi
+
+ Check_PIP_Packages
+ delete_useless_package
+ Update_Py_Lib
+ rm -f ${panel_file}
+ rm -f ${setup_path}/server/panel/class/*.pyc
+ rm -f ${setup_path}/server/panel/*.pyc
+
+ \cp -arpf /www/server/panel/init.sh /etc/init.d/bt
+ if [[ ! -s "/etc/init.d/bt" ]];then
+ rm -f /etc/init.d/bt
+ wget --no-check-certificate -O /etc/init.d/bt ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ wget --no-check-certificate -O /www/server/panel/init.sh ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ if [[ ! -s "/etc/init.d/bt" ]];then
+ Red_Error "ERROR: /etc/init.d/bt file content is 0kb "
+ fi
+ fi
+ chmod +x /etc/init.d/bt
+ chmod -R 600 ${setup_path}/server/panel
+ chmod -R 755 ${setup_path}/server/panel/webserver
+ chmod -R +x ${setup_path}/server/panel/script
+ ln -sf /etc/init.d/bt /usr/bin/bt
+ echo "${panelPort}" >${setup_path}/server/panel/data/port.pl
+ wget --no-check-certificate -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softList_en.conf -t 5 -T 20
+
+ rm -f /www/server/panel/class/*.so
+ if [ ! -f /www/server/panel/data/userInfo.json ]; then
+ echo "{\"id\":1,\"uid\":1,\"last_login_ip\":\"127.0.0.1\",\"username\":\"Administrator\",\"email\":\"admin@aapanel.com\",\"status\":1,\"token\":\"aaa.bbb.ccc\"}" > /www/server/panel/data/userInfo.json
+ fi
+}
+
+Use_self_signed_certificate() {
+ echo "Use Self-signed certificate"
+ rm -f /www/server/panel/ssl/*
+ SSL_path=/www/server/panel/ssl
+ # Create private key
+ openssl genrsa -out ${SSL_path}/privateKey.pem 2048
+
+ # Create a self-signed root certificate
+ openssl req -x509 -new -nodes -key ${SSL_path}/privateKey.pem -sha256 -days 3650 -out ${SSL_path}/certificate.pem \
+ -subj "/C=US/ST=State/L=City/O=aapanel.com/OU=aapanel.com/CN=*.aapanel.com" -nodes
+
+ # Use random password
+ # SSL_password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 16)
+
+ # Create PFX file
+ # openssl pkcs12 -export -out ${SSL_path}/baota_root.pfx -inkey ${SSL_path}/privateKey.pem -in ${SSL_path}/certificate.pem -passout pass:${SSL_password}
+
+ # Create password file
+ # echo "${SSL_password}" > ${SSL_path}/root_password.pl
+
+ echo "True" > /www/server/panel/data/ssl.pl
+ SET_SSL=true
+
+ if [ ! -s "${SSL_path}/privateKey.pem" ] || [ ! -s "${SSL_path}/certificate.pem" ]; then
+ SET_SSL=false
+ rm -f /www/server/panel/data/ssl.pl
+ echo "Self-signed certificate failed, panel SSl closed"
+ fi
+}
+
+Set_Bt_Panel() {
+ Run_User="www"
+ wwwUser=$(cat /etc/passwd|cut -d ":" -f 1|grep ^www$)
+ if [ "${wwwUser}" != "www" ];then
+ groupadd ${Run_User}
+ useradd -s /sbin/nologin -g ${Run_User} ${Run_User}
+ fi
+ chmod -R 700 /www/server/panel/pyenv/bin
+ # /www/server/panel/pyenv/bin/pip install cachelib
+ /www/server/panel/pyenv/bin/pip install python-telegram-bot==20.3
+ password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
+ if [ "$PANEL_PASSWORD" ];then
+ password=$PANEL_PASSWORD
+ fi
+ sleep 1
+ admin_auth="/www/server/panel/data/admin_path.pl"
+ if [ ! -f ${admin_auth} ]; then
+ auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
+ echo "/${auth_path}" >${admin_auth}
+ fi
+ if [ "${SAFE_PATH}" ];then
+ auth_path=$SAFE_PATH
+ echo "/${auth_path}" > ${admin_auth}
+ fi
+ auth_path=$(cat ${admin_auth})
+ # /www/server/panel/pyenv/bin/pip3 install pymongo
+ # /www/server/panel/pyenv/bin/pip3 install psycopg2-binary
+ # /www/server/panel/pyenv/bin/pip3 install flask -U
+ # /www/server/panel/pyenv/bin/pip3 install flask-sock
+ # /www/server/panel/pyenv/bin/pip3 install simple-websocket==0.10.0
+ check_pyOpenSSL=$(/www/server/panel/pyenv/bin/pip list|grep pyOpenSSL)
+ if [ -z "$check_pyOpenSSL" ]; then
+ /www/server/panel/pyenv/bin/pip install -I pyOpenSSl
+ fi
+ cd ${setup_path}/server/panel/
+ if [ "$SET_SSL" == true ]; then
+ # mkdir /www/server/panel/ssl
+ echo "SET ssl, please wait...."
+ ssl=$(/www/server/panel/pyenv/bin/python /www/server/panel/tools.py ssl)
+ echo ${ssl}
+ if [[ "${ssl}" -eq 1 ]];then
+ if [ -s "/www/server/panel/ssl/certificate.pem" ];then
+ check_certificate=$(openssl x509 -noout -modulus -in /www/server/panel/ssl/certificate.pem | openssl md5)
+ check_privateKey=$(openssl rsa -noout -modulus -in /www/server/panel/ssl/privateKey.pem | openssl md5)
+ if [ "${check_certificate}" != "${check_privateKey}" ];then
+ echo -e "The certificate and privateKey are not consistent, Use the built-in SSL certificate."
+ Use_self_signed_certificate
+ fi
+ else
+ Use_self_signed_certificate
+ fi
+ else
+ Use_self_signed_certificate
+ fi
+ echo "SET_SSL: $SET_SSL"
+ fi
+ /etc/init.d/bt start
+ $python_bin -m py_compile tools.py
+ $python_bin tools.py username
+ username=$($python_bin tools.py panel ${password})
+ if [ "$PANEL_USER" ];then
+ username=$PANEL_USER
+ fi
+ cd ~
+ echo "${password}" >${setup_path}/server/panel/default.pl
+ chmod 600 ${setup_path}/server/panel/default.pl
+ sleep 3
+ /etc/init.d/bt restart
+ sleep 5
+ isStart=$(ps aux | grep 'BT-Panel' | grep -v grep | awk '{print $2}')
+ if [ -z "${isStart}" ]; then
+ /etc/init.d/bt start
+ sleep 5
+ isStart=$(ps aux | grep 'BT-Panel' | grep -v grep | awk '{print $2}')
+ if [ -z "${isStart}" ]; then
+ Check_PIP_Packages
+ /etc/init.d/bt start
+ sleep 5
+ isStart=$(ps aux | grep 'BT-Panel' | grep -v grep | awk '{print $2}')
+ fi
+ fi
+
+ LOCAL_CURL=$(curl 127.0.0.1:$panelPort/login 2>&1 | grep -i html)
+ if [ -z "${isStart}" ] && [ -z "${LOCAL_CURL}" ]; then
+ /etc/init.d/bt 22
+ cd /www/server/panel/pyenv/bin
+ touch t.pl
+ ls -al python3.12 python3 python ${setup_path}/server/panel/BT-*
+ lsattr python3.12 python3 python
+ Red_Error "ERROR: The BT-Panel service startup failed."
+ fi
+
+ if [ "$PANEL_USER" ];then
+ cd ${setup_path}/server/panel/
+ btpython -c 'import tools;tools.set_panel_username("'$PANEL_USER'")'
+ cd ~
+ fi
+ if [ -f "/usr/bin/sqlite3" ] ;then
+ #sqlite3 /www/server/panel/data/db/panel.db "UPDATE config SET status = '1' WHERE id = '1';" > /dev/null 2>&1
+ sqlite3 /www/server/panel/data/default.db "UPDATE config SET status = '1' WHERE id = '1';" > /dev/null 2>&1
+ fi
+
+ touch /www/server/panel/install/i_mysql.pl
+
+}
+Set_Firewall() {
+ sshPort=$(cat /etc/ssh/sshd_config | grep 'Port ' | awk '{print $2}')
+ if [ "${PM}" = "apt-get" ]; then
+ if [ ! -f "/usr/bin/ufw" ] && [ ! -f "/bin/ufw" ] && ! Command_Exists "ufw"; then
+ apt-get install -y ufw
+ fi
+ if [ -f "/usr/sbin/ufw" ]; then
+ ufw allow 20/tcp >/dev/null 2>&1
+ ufw allow 21/tcp >/dev/null 2>&1
+ ufw allow 22/tcp >/dev/null 2>&1
+ ufw allow 80/tcp >/dev/null 2>&1
+ ufw allow 443/tcp >/dev/null 2>&1
+ ufw allow 888/tcp >/dev/null 2>&1
+ ufw allow 39000:40000/tcp >/dev/null 2>&1
+ ufw allow ${panelPort}/tcp >/dev/null 2>&1
+ ufw allow ${sshPort}/tcp >/dev/null 2>&1
+ ufw_status=$(ufw status)
+ echo y | ufw enable
+ ufw default deny
+ ufw reload
+ fi
+ else
+ if [ -f "/etc/init.d/iptables" ]; then
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+ 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 ${panelPort} -j ACCEPT
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${sshPort} -j ACCEPT
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 39000:40000 -j ACCEPT
+ #iptables -I INPUT -p tcp -m state --state NEW -m udp --dport 39000:40000 -j ACCEPT
+ iptables -A INPUT -p icmp --icmp-type any -j ACCEPT
+ iptables -A INPUT -s localhost -d localhost -j ACCEPT
+ iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
+ iptables -P INPUT DROP
+ service iptables save
+ sed -i "s#IPTABLES_MODULES=\"\"#IPTABLES_MODULES=\"ip_conntrack_netbios_ns ip_conntrack_ftp ip_nat_ftp\"#" /etc/sysconfig/iptables-config
+ iptables_status=$(service iptables status | grep 'not running')
+ if [ "${iptables_status}" == '' ]; then
+ service iptables restart
+ fi
+ else
+ AliyunCheck=$(cat /etc/redhat-release | grep "Aliyun Linux")
+ [ "${AliyunCheck}" ] && return
+ if [ ! -f "/usr/bin/firewall-cmd" ] && [ ! -f "/bin/firewall-cmd" ] && ! Command_Exists "firewall-cmd"; then
+ yum install firewalld -y
+ fi
+ [ "${Centos8Check}" ] && yum reinstall python3-six -y
+ systemctl enable firewalld
+ systemctl start firewalld
+ firewall-cmd --set-default-zone=public >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=20/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=21/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=22/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=80/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=443/tcp > /dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=${panelPort}/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=${sshPort}/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=39000-40000/tcp >/dev/null 2>&1
+ #firewall-cmd --permanent --zone=public --add-port=39000-40000/udp > /dev/null 2>&1
+ firewall-cmd --reload
+ fi
+ fi
+}
+Get_Ip_Address() {
+ getIpAddress=""
+ # getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://brandnew.aapanel.com/api/common/getClientIP)
+ getIpAddress=$(curl -sSk --connect-timeout 10 -m 60 https://www.aapanel.com/api/common/getClientIP)
+ # if [ -z "${getIpAddress}" ] || [ "${getIpAddress}" = "0.0.0.0" ]; then
+ # isHosts=$(cat /etc/hosts|grep 'www.bt.cn')
+ # if [ -z "${isHosts}" ];then
+ # echo "" >> /etc/hosts
+ # echo "103.224.251.67 www.bt.cn" >> /etc/hosts
+ # #getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://brandnew.aapanel.com/api/common/getClientIP)
+ # getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
+ # if [ -z "${getIpAddress}" ];then
+ # sed -i "/bt.cn/d" /etc/hosts
+ # fi
+ # fi
+ # fi
+
+ ipv4Check=$($python_bin -c "import re; print(re.match(r'^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$','${getIpAddress}'))")
+ if [ "${ipv4Check}" == "None" ]; then
+ ipv6Address=$(echo ${getIpAddress} | tr -d "[]")
+ ipv6Check=$($python_bin -c "import re; print(re.match(r'^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$','${ipv6Address}'))")
+ if [ "${ipv6Check}" == "None" ]; then
+ getIpAddress="SERVER_IP"
+ else
+ getIpAddress=$(echo "[$getIpAddress]")
+ echo "True" >${setup_path}/server/panel/data/ipv6.pl
+ sleep 1
+ /etc/init.d/bt restart
+ fi
+ fi
+
+ if [ "${getIpAddress}" != "SERVER_IP" ]; then
+ echo "${getIpAddress}" >${setup_path}/server/panel/data/iplist.txt
+ fi
+}
+Setup_Count() {
+ # curl -sSk --connect-timeout 10 -m 60 https://www.aapanel.com/api/setupCount/setupPanel?o=$1 >/dev/null 2>&1
+ # curl -sS --connect-timeout 10 -m 60 https://console.aapanel.com/Api/SetupCount?type=Linux > /dev/null 2>&1
+ if [ "$1" != "" ]; then
+ echo $1 >/www/server/panel/data/o.pl
+ cd /www/server/panel
+ $python_bin tools.py o
+ fi
+ echo /www >/var/bt_setupPath.conf
+}
+
+Install_Main() {
+
+ Check_Disk_Space
+ startTime=$(date +%s)
+ Lock_Clear
+ System_Check
+ Set_Ssl
+ Get_Pack_Manager
+ get_node_url
+
+ MEM_TOTAL=$(free -g | grep Mem | awk '{print $2}')
+ if [ "${MEM_TOTAL}" -le "1" ]; then
+ Auto_Swap
+ fi
+
+ if [ "${PM}" = "yum" ]; then
+ Install_RPM_Pack
+ elif [ "${PM}" = "apt-get" ]; then
+ Install_Deb_Pack
+ fi
+
+ Check_Install_Sys_Packs
+
+ Install_Python_Lib
+ Install_Bt
+
+ Set_Bt_Panel
+ Service_Add
+ Set_Firewall
+
+ Get_Ip_Address
+ Setup_Count ${IDC_CODE}
+}
+
+echo "
++----------------------------------------------------------------------
+| aaPanel FOR CentOS/Ubuntu/Debian
++----------------------------------------------------------------------
+| Copyright © 2015-2099 BT-SOFT(https://www.aapanel.com) All rights reserved.
++----------------------------------------------------------------------
+| The WebPanel URL will be https://SERVER_IP:$panelPort when installed.
++----------------------------------------------------------------------
+"
+
+while [ ${#} -gt 0 ]; do
+ case $1 in
+ -h|--help)
+ echo "Usage: [options]"
+ echo "Options:"
+ echo " -u, --user Set aaPanel user name"
+ echo " -p, --password Set aaPanel password"
+ echo " -P, --port Set aaPanel port"
+ echo " --safe-path Set aaPanel safe path"
+ exit 0
+ ;;
+ -u|--user)
+ PANEL_USER=$2
+ shift 1
+ ;;
+ -p|--password)
+ PANEL_PASSWORD=$2
+ shift 1
+ ;;
+ -P|--port)
+ PANEL_PORT=$2
+ shift 1
+ ;;
+ --safe-path)
+ SAFE_PATH=$2
+ shift 1
+ ;;
+ --ssl-disable)
+ SSL_PL="disable"
+ ;;
+ -y)
+ go="y"
+ ;;
+ *)
+ IDC_CODE=$1
+ ;;
+ esac
+ shift 1
+done
+while [ "$go" != 'y' ] && [ "$go" != 'n' ]; do
+ read -p "Do you want to install aaPanel to the $setup_path directory now?(y/n): " go
+done
+
+if [ "$go" == 'n' ]; then
+ exit
+fi
+
+Install_Main
+/etc/init.d/bt restart
+intenal_ip=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
+echo -e "=================================================================="
+echo -e "\033[32mCongratulations! Installed successfully!\033[0m"
+echo -e "=================================================================="
+if [[ "$SET_SSL" == "true" ]]; then
+ HTTP_S="https"
+else
+ HTTP_S="http"
+fi
+echo "aaPanel Internet Address: ${HTTP_S}://${getIpAddress}:${panelPort}$auth_path"
+echo "aaPanel Internal Address: ${HTTP_S}://${intenal_ip}:${panelPort}$auth_path"
+echo -e "username: $username"
+echo -e "password: $password"
+echo -e "\033[33mWarning:\033[0m"
+echo -e "\033[33mIf you cannot access the panel, \033[0m"
+echo -e "\033[33mrelease the following port ($panelPort|888|80|443|20|21) in the security group\033[0m"
+echo -e "=================================================================="
+
+endTime=$(date +%s)
+((outTime = ($endTime - $startTime) / 60))
+if [ "${outTime}" == "0" ];then
+ ((outTime=($endTime-$startTime)))
+ echo -e "Time consumed:\033[32m $outTime \033[0mseconds!"
+else
+ echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
+fi
+rm -f install_7.0_en.sh /tmp/pip_en_3.12.txt ${check_pip_packs} ${show_pip_list_panel}
diff --git a/public/install/install_pro_en.sh b/public/install/install_pro_en.sh
new file mode 100644
index 0000000..f9d0bea
--- /dev/null
+++ b/public/install/install_pro_en.sh
@@ -0,0 +1,2033 @@
+#!/bin/bash
+PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
+export PATH
+LANG=en_US.UTF-8
+
+Btapi_Url='http://www.example.com'
+Check_Api=$(curl -Ss --connect-timeout 5 -m 2 $Btapi_Url/api/SetupCount)
+if [ "$Check_Api" != 'ok' ];then
+ Red_Error "The BT cloud could not be connected, so the installation process has been aborted!";
+fi
+
+if [ $(whoami) != "root" ]; then
+ # echo "Please use the [root] user to execute the aapanel installation script!"
+ echo -e "Non-root install, please try the following solutions: \n 1.Please switch to [root] user install \n 2.Try executing the following install commands: \n sudo bash $0 $@"
+ exit 1
+fi
+
+is64bit=$(getconf LONG_BIT)
+if [ "${is64bit}" != '64' ]; then
+ Red_Error "Sorry, aaPanel does not support 32-bit systems"
+fi
+
+HOSTNAME_CHECK=$(cat /etc/hostname)
+if [ -z "${HOSTNAME_CHECK}" ];then
+ echo "hostname is empty. Already set as aaPanel"
+ echo "aaPanel" > /etc/hostname
+ hostnamectl set-hostname aaPanel
+fi
+
+if [ -f "/etc/SUSE-brand" ];then
+ openSUSE_check=$(cat /etc/SUSE-brand |grep openSUSE)
+ if [ "${openSUSE_check}" ];then
+ echo "Error: openSUSE not supported, Recommended that you use:"
+ echo "Debian 11/12, Ubuntu 20/22/24, Rocky/Alma 8, Rocky/Alma/Centos 9"
+ exit 1
+ fi
+fi
+
+cd ~
+setup_path="/www"
+python_bin=$setup_path/server/panel/pyenv/bin/python
+cpu_cpunt=$(cat /proc/cpuinfo | grep ^processor | wc -l)
+panelPort=$(expr $RANDOM % 55535 + 10000)
+if [ "$1" ]; then
+ IDC_CODE=$1
+fi
+
+Command_Exists() {
+ command -v "$@" >/dev/null 2>&1
+}
+
+GetSysInfo() {
+ if [ -s "/etc/redhat-release" ]; then
+ SYS_VERSION=$(cat /etc/redhat-release)
+ elif [ -s "/etc/issue" ]; then
+ SYS_VERSION=$(cat /etc/issue)
+ fi
+ SYS_INFO=$(uname -a)
+ SYS_BIT=$(getconf LONG_BIT)
+ MEM_TOTAL=$(free -m | grep Mem | awk '{print $2}')
+ CPU_INFO=$(getconf _NPROCESSORS_ONLN)
+
+ echo -e ${SYS_VERSION}
+ echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO}
+ echo -e ${SYS_INFO}
+ echo -e "Please screenshot above error message and post forum forum.aapanel.com or send email: kern@aapanel.com for help"
+}
+
+
+Replace_symbol(){
+# 更换符号为__
+ text="${text#"${text%%[![:space:]]*}"}"
+ text=${text%% }
+ text=${text// /__}
+ text=${text//\(/__}
+ text=${text//\)/__}
+ text=${text//\"/__}
+ text=${text//\“/__}
+ text=${text//\”/__}
+ text=${text//\(/__}
+ text=${text//\)/__}
+ text=${text//\!/__}
+ text=${text//\!/__}
+ text=${text//:/__}
+ text=${text//:/__}
+ text=${text//,/__}
+ text=${text//,/__}
+ text=${text//。/__}
+ text=${text//\$/__}
+ text=${text//\{/__}
+ text=${text//\}/__}
+ text=${text//\[/__}
+ text=${text//\]/__}
+ text=${text//./__}
+ text=${text//-/__}
+ text=${text//>/__}
+ text=${text//=/__}
+ text=${text//\//__}
+ text=${text//\'/__}
+
+}
+
+Red_Error() {
+ echo '================================================='
+ printf '\033[1;31;40m%b\033[0m\n' "$@"
+ GetSysInfo
+
+ if [[ "$@" == "" ]]; then
+ url_err_msg="aaPanel_install_failed_vP"
+ else
+ text="$@"
+ Replace_symbol
+
+ url_err_msg="${text}_vP"
+ #echo "url_err_msg:$url_err_msg"
+ fi
+ exit 1
+}
+
+if [ -f "/etc/redhat-release" ]; then
+ Centos6Check=$(cat /etc/redhat-release | grep ' 6.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos6Check}" ]; then
+ Red_Error "Sorry, Centos6 does not support installing aaPanel"
+ fi
+ Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
+ Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos7Check}" ] || [ "${Centos8Check}" ];then
+ echo "Centos 7/8 provider no longer maintained, Recommended that you use:"
+ echo "Debian 11/12, Ubuntu 20/22/24, Rocky/Alma 8, Rocky/Alma/Centos 9"
+ echo "Press Ctrl+C to cancel or Wait 10 seconds before install"
+ sleep 10
+ fi
+fi
+
+if [ -f "/etc/issue" ]; then
+ UbuntuCheck=$(cat /etc/issue | grep Ubuntu | awk '{print $2}' | cut -f 1 -d '.')
+ if [[ ! -z "${UbuntuCheck}" ]] && [[ "${UbuntuCheck}" =~ ^[0-9]+$ ]] && [[ "${UbuntuCheck}" -lt "18" ]]; then
+ Red_Error "Ubuntu ${UbuntuCheck} is not supported to the aaPanel, it is recommended to replace the Ubuntu 20/22/24 to install"
+ fi
+
+ DebianCheck=$(cat /etc/issue | grep Debian | awk '{print $3}' | cut -f 1 -d '.')
+ if [[ ! -z "${DebianCheck}" ]] && [[ "${DebianCheck}" =~ ^[0-9]+$ ]] && [[ "${DebianCheck}" -lt "10" ]]; then
+ Red_Error "Debian ${DebianCheck} is not supported to the aaPanel, it is recommended to replace the Debian 11/12 to install"
+ fi
+fi
+
+Check_Disk_Space() {
+ # Get the available space of the partition where the /www directory is located (in kb)
+ if [ -d "/www" ]; then
+ available_kb=$(df -k /www | awk 'NR==2 {print $4}')
+ else
+ available_kb=$(df -k / | awk 'NR==2 {print $4}')
+ fi
+
+ # 1GB = 1024MB = 1024*1024KB
+ available_gb=$((available_kb / 1024 / 1024))
+ echo "Available disk space on the install partition: "$available_gb" G"
+
+ # Determine if available space is less than 1 gb
+ if [ "$available_gb" -lt 1 ]; then
+ echo -e "\033[31m The available space is less than 1G.\033[0m"
+ echo -e "\033[31m It is recommended to clean or upgrade the server space before upgrading.\033[0m"
+ Red_Error "Error: The available space is less than 1G"
+ fi
+
+}
+
+Lock_Clear() {
+ if [ -f "/etc/bt_crack.pl" ]; then
+ chattr -R -ia /www
+ chattr -ia /etc/init.d/bt
+ \cp -rpa /www/backup/panel/vhost/* /www/server/panel/vhost/
+ mv /www/server/panel/BTPanel/__init__.bak /www/server/panel/BTPanel/__init__.py
+ rm -f /etc/bt_crack.pl
+ fi
+}
+Install_Check() {
+ if [ "${INSTALL_FORCE}" ]; then
+ return
+ fi
+ echo -e "----------------------------------------------------"
+ echo -e "Web service is already installed,installing aaPanel may affect existing sites."
+ echo -e "----------------------------------------------------"
+ echo -e "Enter [yes] to force installation"
+ read -p "Enter yes to force installation: " yes
+ if [ "$yes" != "yes" ]; then
+ echo -e "------------"
+ echo "Installation canceled"
+ exit
+ fi
+ INSTALL_FORCE="true"
+}
+System_Check() {
+ MYSQLD_CHECK=$(ps -ef | grep mysqld | grep -v grep | grep -v /www/server/mysql)
+ PHP_CHECK=$(ps -ef | grep php-fpm | grep master | grep -v /www/server/php)
+ NGINX_CHECK=$(ps -ef | grep nginx | grep master | grep -v /www/server/nginx)
+ HTTPD_CHECK=$(ps -ef | grep -E 'httpd|apache' | grep -v /www/server/apache | grep -v grep)
+ if [ "${PHP_CHECK}" ] || [ "${MYSQLD_CHECK}" ] || [ "${NGINX_CHECK}" ] || [ "${HTTPD_CHECK}" ]; then
+ Install_Check
+ fi
+}
+Set_Ssl() {
+ SET_SSL=true
+
+ if [ "${SSL_PL}" ];then
+ SET_SSL=""
+ fi
+}
+
+Get_Pack_Manager() {
+ if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
+ PM="yum"
+ elif [ -f "/usr/bin/apt-get" ] && [ -f "/usr/bin/dpkg" ]; then
+ PM="apt-get"
+ fi
+}
+
+Auto_Swap() {
+ swap=$(free | grep Swap | awk '{print $2}')
+ if [ "${swap}" -gt 1 ]; then
+ echo "Swap total sizse: $swap"
+ return
+ fi
+ if [ ! -d /www ]; then
+ mkdir /www
+ fi
+ swapFile="/www/swap"
+ dd if=/dev/zero of=$swapFile bs=1M count=1025
+ mkswap -f $swapFile
+ swapon $swapFile
+ echo "$swapFile swap swap defaults 0 0" >>/etc/fstab
+ swap=$(free | grep Swap | awk '{print $2}')
+ if [ $swap -gt 1 ]; then
+ echo "Swap total sizse: $swap"
+ return
+ fi
+
+ sed -i "/\/www\/swap/d" /etc/fstab
+ rm -f $swapFile
+}
+Service_Add() {
+ if Command_Exists systemctl ; then
+ wget --no-check-certificate -O /usr/lib/systemd/system/btpanel.service ${download_Url}/init/systemd/btpanel.service -t 5 -T 20
+ systemctl daemon-reload
+ systemctl enable btpanel
+
+ else
+ if [ "${PM}" == "yum" ] || [ "${PM}" == "dnf" ]; then
+ chkconfig --add bt
+ chkconfig --level 2345 bt on
+ elif [ "${PM}" == "apt-get" ]; then
+ update-rc.d bt defaults
+ fi
+ fi
+}
+
+Set_Centos7_Repo(){
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "[^#]mirror.centos.org")
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ echo "Centos7 official repository source has been discontinued , Replacement in progress."
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ fi
+
+ MIRROR_CHECK22=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "mirrorlist.centos.org"|grep -v '^#')
+ if [ "${MIRROR_CHECK22}" ] && [ "${is64bit}" == "64" ];then
+ echo "Centos7 official repository source has been discontinued , Replacement in progress."
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ \cp -rpa /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bt_bak
+cat > /etc/yum.repos.d/CentOS-Base.repo << EOF
+
+# CentOS-Base.repo
+
+[base]
+name=CentOS-\$releasever - Base
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=os&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/os/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#released updates
+[updates]
+name=CentOS-\$releasever - Updates
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=updates&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/updates/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that may be useful
+[extras]
+name=CentOS-\$releasever - Extras
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=extras&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/extras/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that extend functionality of existing packages
+[centosplus]
+name=CentOS-\$releasever - Plus
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=centosplus&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/centosplus/\$basearch/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+EOF
+
+ fi
+
+ ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
+ Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
+ if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
+ return
+ fi
+
+ yum install unzip -y
+ if [ "$?" != "0" ] ;then
+ TAR_CHECK=$(which tar)
+ if [ "$?" == "0" ] ;then
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ if [ -z "${download_Url}" ];then
+ download_Url="https://node.aapanel.com"
+ fi
+ curl -Ssk --connect-timeout 20 -m 60 -O ${download_Url}/src/el7repo.tar.gz
+ if [ -f "/usr/bin/wget" ] && [ ! -s "el7repo.tar.gz" ];then
+ wget --no-check-certificate -O el7repo.tar.gz ${download_Url}/src/el7repo.tar.gz -t 3 -T 20
+ fi
+ rm -f /etc/yum.repos.d/*.repo
+ tar -xvzf el7repo.tar.gz -C /etc/yum.repos.d/
+ rm -f el7repo.tar.gz
+ fi
+ fi
+
+}
+
+Set_Centos8_Repo(){
+ HUAWEI_CHECK=$(cat /etc/motd |grep "Huawei Cloud")
+ if [ "${HUAWEI_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ rm -f /etc/yum.repos.d/epel.repo
+ rm -f /etc/yum.repos.d/epel-*
+ fi
+ ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
+ if [ "${ALIYUN_CHECK}" ] && [ "${is64bit}" == "64" ] && [ ! -f "/etc/yum.repos.d/Centos-vault-8.5.2111.repo" ];then
+ rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
+ wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
+ wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
+ sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
+ sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
+ fi
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo |grep "[^#]mirror.centos.org")
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ fi
+
+ yum install unzip tar -y
+ if [ "$?" != "0" ] ;then
+ if [ -z "${download_Url}" ];then
+ download_Url="https://node.aapanel.com"
+ fi
+ if [ ! -f "/usr/bin/tar" ] ;then
+ curl -Ss --connect-timeout 20 -m 60 -O ${download_Url}/src/tar-1.30-5.el8.x86_64.rpm
+ if [ -f "/usr/bin/wget" ] && [ ! -s "tar-1.30-5.el8.x86_64.rpm" ];then
+ wget --no-check-certificate -O tar-1.30-5.el8.x86_64.rpm ${download_Url}/src/tar-1.30-5.el8.x86_64.rpm -t 3 -T 20
+ fi
+ # yum install tar-1.30-5.el8.x86_64.rpm -y
+ rpm -ivh tar-1.30-5.el8.x86_64.rpm
+ rm -f tar-1.30-5.el8.x86_64.rpm
+ fi
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ curl -Ss --connect-timeout 20 -m 60 -O ${download_Url}/src/el8repo.tar.gz
+ if [ -f "/usr/bin/wget" ] && [ ! -s "el8repo.tar.gz" ];then
+ wget --no-check-certificate -O el8repo.tar.gz ${download_Url}/src/el8repo.tar.gz -t 3 -T 20
+ fi
+ rm -f /etc/yum.repos.d/*.repo
+ tar -xvzf el8repo.tar.gz -C /etc/yum.repos.d/
+ rm -f el8repo.tar.gz
+ fi
+
+}
+
+Bored_waiting(){
+ w_time="$wait_time"
+ msg="$wait_msg"
+ progress="."
+ for ((i=0; i<${w_time}; i++))
+ do
+ printf "$msg %-10s %d\r" "$progress" "$((i+1))"
+ sleep 1
+
+ if [ "$progress" == ".........." ]; then
+ progress="."
+ else
+ progress+="."
+ fi
+ done
+ printf "$msg %-10s %d\r" ".........." "$w_time"
+ #echo ""
+}
+
+Check_apt_status(){
+
+ MAX_RETRIES=30
+ retries=0
+
+ while [ $retries -lt $MAX_RETRIES ]; do
+ output=$(ps aux| grep -E '(apt|apt-get)\s' 2>&1)
+ check_output=$(echo "$output" | grep -E '(apt|apt-get)\s')
+
+ #If check_output is empty, terminate the loop
+ if [ -z "$check_output" ]; then
+ break
+ fi
+
+ retries=$((retries + 1))
+
+ echo "apt-get is in use, it will automatically exit after ${retries}/${MAX_RETRIES} times, try again after 10 seconds..."
+ echo "$check_output"
+ wait_msg="Please wait"
+ wait_time="10"
+ Bored_waiting
+
+ done
+
+ if [ $retries -ge $MAX_RETRIES ]; then
+ Red_Error "ERROR: apt-get command exceeds the maximum wait times: ${MAX_RETRIES}." "Do not use the apt/apt-get command or install software during installation, please try to reinstall!"
+ fi
+
+}
+
+get_node_url() {
+
+ download_Url='https://node.aapanel.com'
+
+ if [ ! -f /bin/curl ]; then
+ if [ "${PM}" = "yum" ]; then
+ yum install curl -y
+ elif [ "${PM}" = "apt-get" ]; then
+ apt-get install curl -y
+ fi
+ fi
+
+ if [ -f "/www/node.pl" ];then
+ download_Url=$(cat /www/node.pl)
+ echo "Download node: $download_Url";
+ echo '---------------------------------------------';
+ return
+ fi
+
+ # echo '---------------------------------------------';
+ # echo "Selected download node...";
+ # nodes=(https://node.aapanel.com);
+
+ # if [ "$1" ];then
+ # nodes=($(echo ${nodes[*]}|sed "s#${1}##"))
+ # fi
+ # tmp_file1=/dev/shm/net_test1.pl
+ # tmp_file2=/dev/shm/net_test2.pl
+
+ # [ -f "${tmp_file1}" ] && rm -f ${tmp_file1}
+
+ # [ -f "${tmp_file2}" ] && rm -f ${tmp_file2}
+
+ # touch $tmp_file1
+ # touch $tmp_file2
+ # for node in ${nodes[@]}; do
+ # NODE_CHECK=$(curl -k --connect-timeout 3 -m 3 2>/dev/null -w "%{http_code} %{time_total}" ${node}/net_test|xargs)
+ # 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)
+ # if [ "${NODE_STATUS}" == "200" ]; then
+ # if [ $TIME_TOTAL -lt 100 ]; then
+ # if [ $RES -ge 1500 ]; then
+ # echo "$RES $node" >>$tmp_file1
+ # fi
+ # else
+ # if [ $RES -ge 1500 ]; then
+ # echo "$TIME_TOTAL $node" >>$tmp_file2
+ # fi
+ # fi
+
+ # i=$(($i + 1))
+ # if [ $TIME_TOTAL -lt 100 ]; then
+ # if [ $RES -ge 3000 ]; then
+ # break
+ # fi
+ # fi
+
+ # fi
+ # done
+
+ # NODE_URL=$(cat $tmp_file1 | sort -r -g -t " " -k 1 | head -n 1 | awk '{print $2}')
+ # if [ -z "$NODE_URL" ]; then
+ # NODE_URL=$(cat $tmp_file2 | sort -g -t " " -k 1 | head -n 1 | awk '{print $2}')
+ # if [ -z "$NODE_URL" ]; then
+ # NODE_URL='https://node.aapanel.com'
+ # fi
+ # fi
+
+ # rm -f $tmp_file1
+ # rm -f $tmp_file2
+ # download_Url=$NODE_URL
+ # echo "Download node: $download_Url"
+ # echo '---------------------------------------------'
+
+}
+Remove_Package() {
+ local PackageNmae=$1
+ if [ "${PM}" == "yum" ]; then
+ isPackage=$(rpm -q ${PackageNmae} | grep "not installed")
+ if [ -z "${isPackage}" ]; then
+ yum remove ${PackageNmae} -y
+ fi
+ elif [ "${PM}" == "apt-get" ]; then
+ isPackage=$(dpkg -l | grep ${PackageNmae})
+ if [ "${PackageNmae}" ]; then
+ apt-get remove ${PackageNmae} -y
+ fi
+ fi
+}
+Install_RPM_Pack() {
+ yumPath=/etc/yum.conf
+ Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
+ CentOS_Stream_8=$(cat /etc/redhat-release | grep 'CentOS Stream release 8' | grep -iE 'centos|Red Hat')
+ if [ "${Centos8Check}" ] || [ "${CentOS_Stream_8}" ];then
+ Set_Centos8_Repo
+ fi
+ Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos7Check}" ];then
+ Set_Centos7_Repo
+ fi
+
+ isExc=$(cat $yumPath | grep httpd)
+ if [ "$isExc" = "" ]; then
+ echo "exclude=httpd nginx php mysql mairadb python-psutil python2-psutil" >>$yumPath
+ fi
+
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el8") ];then
+ yum config-manager --set-enabled powertools
+ yum config-manager --set-enabled PowerTools
+ fi
+
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el9") ];then
+ dnf config-manager --set-enabled crb -y
+ fi
+
+ #yumBaseUrl=$(cat /etc/yum.repos.d/CentOS-Base.repo|grep baseurl=http|cut -d '=' -f 2|cut -d '$' -f 1|head -n 1)
+ #[ "${yumBaseUrl}" ] && checkYumRepo=$(curl --connect-timeout 5 --head -s -o /dev/null -w %{http_code} ${yumBaseUrl})
+ #if [ "${checkYumRepo}" != "200" ];then
+ # curl -Ss --connect-timeout 3 -m 60 http://node.aapanel.com/install/yumRepo_select.sh|bash
+ #fi
+
+ #尝试同步时间(从bt.cn)
+ # echo 'Synchronizing system time...'
+ # getBtTime=$(curl -sS --connect-timeout 3 -m 60 http://www.bt.cn/api/index/get_time)
+ # if [ "${getBtTime}" ];then
+ # date -s "$(date -d @$getBtTime +"%Y-%m-%d %H:%M:%S")"
+ # fi
+
+ #if [ -z "${Centos8Check}" ]; then
+ # yum install ntp -y
+ # rm -rf /etc/localtime
+ # ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+ #尝试同步国际时间(从ntp服务器)
+ # ntpdate 0.asia.pool.ntp.org
+ # setenforce 0
+ #fi
+ setenforce 0
+ startTime=$(date +%s)
+
+ 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 firewalld ipset libpq-devel ca-certificates sudo at mariadb rsyslog autoconf xfsprogs quota"
+ 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
+ if [ -f "/usr/bin/dnf" ]; then
+ dnf install -y redhat-rpm-config
+ fi
+
+ ALI_OS=$(cat /etc/redhat-release | grep "Alibaba Cloud Linux release 3")
+ if [ -z "${ALI_OS}" ]; then
+ yum install epel-release -y
+ fi
+}
+Install_Deb_Pack() {
+ Check_apt_status
+
+ ln -sf bash /bin/sh
+
+ UBUNTU_22=$(cat /etc/issue|grep "Ubuntu 22")
+ UBUNTU_24=$(cat /etc/issue|grep "Ubuntu 24")
+ if [ "${UBUNTU_22}" ] || [ "${UBUNTU_24}" ];then
+ apt-get remove needrestart -y
+ fi
+ apt-get update -y
+ apt-get install bash -y
+ if [ -f "/usr/bin/bash" ];then
+ ln -sf /usr/bin/bash /bin/sh
+ fi
+
+ FNOS_CHECK=$(grep fnOS /etc/issue)
+ if [ "${FNOS_CHECK}" ];then
+ apt-get install libc6 -y --allow-change-held-packages
+ apt-get install libc6-dev -y --allow-change-held-packages
+ fi
+
+ apt-get install ruby -y
+ apt-get install lsb-release -y
+ #apt-get install ntp ntpdate -y
+ #/etc/init.d/ntp stop
+ #update-rc.d ntp remove
+ #cat >>~/.profile</var/spool/cron/crontabs/root
+ chmod 600 /var/spool/cron/crontabs/root
+ fi
+ fi
+}
+
+Ubuntu_20_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb http://archive.ubuntu.com/ubuntu focal main restricted
+# deb-src http://archive.ubuntu.com/ubuntu focal main restricted
+
+deb http://ubuntu.mirror.constant.com focal main restricted
+# deb-src http://ubuntu.mirror.constant.com focal main restricted
+
+deb http://archive.ubuntu.com/ubuntu focal-updates main restricted
+# deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted
+
+deb http://ubuntu.mirror.constant.com focal-updates main restricted
+# deb-src http://ubuntu.mirror.constant.com focal-updates main restricted
+
+deb http://archive.ubuntu.com/ubuntu focal universe
+# deb-src http://archive.ubuntu.com/ubuntu focal universe
+deb http://archive.ubuntu.com/ubuntu focal-updates universe
+# deb-src http://archive.ubuntu.com/ubuntu focal-updates universe
+
+deb http://ubuntu.mirror.constant.com focal universe
+# deb-src http://ubuntu.mirror.constant.com focal universe
+deb http://ubuntu.mirror.constant.com focal-updates universe
+# deb-src http://ubuntu.mirror.constant.com focal-updates universe
+
+deb http://archive.ubuntu.com/ubuntu focal multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal multiverse
+deb http://archive.ubuntu.com/ubuntu focal-updates multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal-updates multiverse
+
+deb http://ubuntu.mirror.constant.com focal multiverse
+# deb-src http://ubuntu.mirror.constant.com focal multiverse
+deb http://ubuntu.mirror.constant.com focal-updates multiverse
+# deb-src http://ubuntu.mirror.constant.com focal-updates multiverse
+
+deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse
+
+deb http://ubuntu.mirror.constant.com focal-backports main restricted universe multiverse
+# deb-src http://ubuntu.mirror.constant.com focal-backports main restricted universe multiverse
+
+deb http://archive.ubuntu.com/ubuntu focal-security main restricted
+# deb-src http://archive.ubuntu.com/ubuntu focal-security main restricted
+deb http://archive.ubuntu.com/ubuntu focal-security universe
+# deb-src http://archive.ubuntu.com/ubuntu focal-security universe
+deb http://archive.ubuntu.com/ubuntu focal-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu focal-security multiverse
+
+deb http://ubuntu.mirror.constant.com focal-security main restricted
+# deb-src http://ubuntu.mirror.constant.com focal-security main restricted
+deb http://ubuntu.mirror.constant.com focal-security universe
+# deb-src http://ubuntu.mirror.constant.com focal-security universe
+deb http://ubuntu.mirror.constant.com focal-security multiverse
+# deb-src http://ubuntu.mirror.constant.com focal-security multiverse
+
+EOF
+
+}
+
+Ubuntu_22_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb http://archive.ubuntu.com/ubuntu jammy main restricted
+# deb-src http://archive.ubuntu.com/ubuntu jammy main restricted
+
+deb http://ubuntu.mirror.constant.com jammy main restricted
+# deb-src http://ubuntu.mirror.constant.com jammy main restricted
+
+deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted
+# deb-src http://archive.ubuntu.com/ubuntu jammy-updates main restricted
+
+deb http://ubuntu.mirror.constant.com jammy-updates main restricted
+# deb-src http://ubuntu.mirror.constant.com jammy-updates main restricted
+
+deb http://archive.ubuntu.com/ubuntu jammy universe
+# deb-src http://archive.ubuntu.com/ubuntu jammy universe
+deb http://archive.ubuntu.com/ubuntu jammy-updates universe
+# deb-src http://archive.ubuntu.com/ubuntu jammy-updates universe
+
+deb http://ubuntu.mirror.constant.com jammy universe
+# deb-src http://ubuntu.mirror.constant.com jammy universe
+deb http://ubuntu.mirror.constant.com jammy-updates universe
+# deb-src http://ubuntu.mirror.constant.com jammy-updates universe
+
+deb http://archive.ubuntu.com/ubuntu jammy multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy multiverse
+deb http://archive.ubuntu.com/ubuntu jammy-updates multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy-updates multiverse
+
+deb http://ubuntu.mirror.constant.com jammy multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy multiverse
+deb http://ubuntu.mirror.constant.com jammy-updates multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy-updates multiverse
+
+deb http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy-backports main restricted universe multiverse
+
+deb http://ubuntu.mirror.constant.com jammy-backports main restricted universe multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy-backports main restricted universe multiverse
+
+deb http://archive.ubuntu.com/ubuntu jammy-security main restricted
+# deb-src http://archive.ubuntu.com/ubuntu jammy-security main restricted
+deb http://archive.ubuntu.com/ubuntu jammy-security universe
+# deb-src http://archive.ubuntu.com/ubuntu jammy-security universe
+deb http://archive.ubuntu.com/ubuntu jammy-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu jammy-security multiverse
+
+deb http://ubuntu.mirror.constant.com jammy-security main restricted
+# deb-src http://ubuntu.mirror.constant.com jammy-security main restricted
+deb http://ubuntu.mirror.constant.com jammy-security universe
+# deb-src http://ubuntu.mirror.constant.com jammy-security universe
+deb http://ubuntu.mirror.constant.com jammy-security multiverse
+# deb-src http://ubuntu.mirror.constant.com jammy-security multiverse
+
+EOF
+
+}
+
+
+Ubuntu_24_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb http://archive.ubuntu.com/ubuntu noble main restricted
+# deb-src http://archive.ubuntu.com/ubuntu noble main restricted
+
+deb http://ubuntu.mirror.constant.com noble main restricted
+# deb-src http://ubuntu.mirror.constant.com noble main restricted
+
+deb http://archive.ubuntu.com/ubuntu noble-updates main restricted
+# deb-src http://archive.ubuntu.com/ubuntu noble-updates main restricted
+
+deb http://ubuntu.mirror.constant.com noble-updates main restricted
+# deb-src http://ubuntu.mirror.constant.com noble-updates main restricted
+
+deb http://archive.ubuntu.com/ubuntu noble universe
+# deb-src http://archive.ubuntu.com/ubuntu noble universe
+deb http://archive.ubuntu.com/ubuntu noble-updates universe
+# deb-src http://archive.ubuntu.com/ubuntu noble-updates universe
+
+deb http://ubuntu.mirror.constant.com noble universe
+# deb-src http://ubuntu.mirror.constant.com noble universe
+deb http://ubuntu.mirror.constant.com noble-updates universe
+# deb-src http://ubuntu.mirror.constant.com noble-updates universe
+
+deb http://archive.ubuntu.com/ubuntu noble multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble multiverse
+deb http://archive.ubuntu.com/ubuntu noble-updates multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble-updates multiverse
+
+deb http://ubuntu.mirror.constant.com noble multiverse
+# deb-src http://ubuntu.mirror.constant.com noble multiverse
+deb http://ubuntu.mirror.constant.com noble-updates multiverse
+# deb-src http://ubuntu.mirror.constant.com noble-updates multiverse
+
+deb http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble-backports main restricted universe multiverse
+
+deb http://ubuntu.mirror.constant.com noble-backports main restricted universe multiverse
+# deb-src http://ubuntu.mirror.constant.com noble-backports main restricted universe multiverse
+
+deb http://archive.ubuntu.com/ubuntu noble-security main restricted
+# deb-src http://archive.ubuntu.com/ubuntu noble-security main restricted
+deb http://archive.ubuntu.com/ubuntu noble-security universe
+# deb-src http://archive.ubuntu.com/ubuntu noble-security universe
+deb http://archive.ubuntu.com/ubuntu noble-security multiverse
+# deb-src http://archive.ubuntu.com/ubuntu noble-security multiverse
+
+deb http://ubuntu.mirror.constant.com noble-security main restricted
+# deb-src http://ubuntu.mirror.constant.com noble-security main restricted
+deb http://ubuntu.mirror.constant.com noble-security universe
+# deb-src http://ubuntu.mirror.constant.com noble-security universe
+deb http://ubuntu.mirror.constant.com noble-security multiverse
+# deb-src http://ubuntu.mirror.constant.com noble-security multiverse
+
+EOF
+
+}
+
+Debian_11_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb https://deb.debian.org/debian bullseye main contrib non-free
+deb-src https://deb.debian.org/debian bullseye main contrib non-free
+
+deb https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
+deb-src https://deb.debian.org/debian-security/ bullseye-security main contrib non-free
+
+deb https://deb.debian.org/debian bullseye-updates main contrib non-free
+deb-src https://deb.debian.org/debian bullseye-updates main contrib non-free
+
+#deb https://deb.debian.org/debian bullseye-backports main contrib non-free
+#deb-src https://deb.debian.org/debian bullseye-backports main contrib non-free
+
+deb https://debian.mirror.constant.com bullseye main contrib non-free
+deb-src https://debian.mirror.constant.com bullseye main contrib non-free
+
+EOF
+
+}
+
+
+Debian_12_sources () {
+
+cat > /etc/apt/sources.list << EOF
+deb https://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
+deb-src https://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
+
+deb https://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
+deb-src https://deb.debian.org/debian-security/ bookworm-security main contrib non-free non-free-firmware
+
+deb https://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
+deb-src https://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
+
+#deb https://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
+#deb-src https://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware
+
+deb https://debian.mirror.constant.com bookworm main contrib non-free non-free-firmware
+deb-src https://debian.mirror.constant.com bookworm main contrib non-free non-free-firmware
+
+EOF
+
+}
+
+
+Change_sources () {
+ if [ -s /etc/os-release ] && [ -s /etc/issue ]; then
+ . /etc/os-release
+ echo "detected OS: $ID - $VERSION_ID"
+
+ UD_os_version=$(cat /etc/issue | grep Ubuntu | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ OS_v=Ubuntu
+ if [ "${UD_os_version}" = "" ]; then
+ OS_v=Debian
+ UD_os_version=$(cat /etc/issue | grep Debian | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '[0-9]+')
+ if [ "${UD_os_version}" = "" ]; then
+ UD_os_version=$(cat /etc/issue | grep Debian | grep -Eo '[0-9]+')
+ fi
+ fi
+ echo "detected OS version: $OS_v $UD_os_version"
+
+ if [ $ID == "debian" ] && [ $OS_v == "Debian" ]; then
+ if [ $VERSION_ID == "11" ] && [ $UD_os_version == "11" ]; then
+ Debian_11_sources
+ elif [ $VERSION_ID == "12" ] && [ $UD_os_version == "12" ]; then
+ Debian_12_sources
+ else
+ echo -e "\033[31mSorry: $OS_v $UD_os_version This system does not support changing apt source, please try to change it yourself. \033[0m"
+ Change_apt_sources="no"
+ fi
+
+ elif [ $ID == "ubuntu" ] && [ $OS_v == "Ubuntu" ]; then
+ if [ `echo "$VERSION_ID" | cut -b-2 ` == "20" ] && [ $UD_os_version == "20" ]; then
+ Ubuntu_20_sources
+ elif [ `echo "$VERSION_ID" | cut -b-2 ` == "22" ] && [ $UD_os_version == "22" ]; then
+ Ubuntu_22_sources
+ elif [ `echo "$VERSION_ID" | cut -b-2 ` == "24" ] && [ $UD_os_version == "24" ]; then
+ Ubuntu_24_sources
+ else
+ echo -e "\033[31mSorry: $OS_v $UD_os_version This system does not support changing apt source, please try to change it yourself. \033[0m"
+ Change_apt_sources="no"
+ fi
+ else
+ echo -e "\033[31mSorry: $OS_v $UD_os_version This system does not support changing apt source, please try to change it yourself. \033[0m"
+ Change_apt_sources="no"
+ fi
+
+ fi
+}
+
+Check_Change_official_sources () {
+ if [ -s /etc/apt/sources.list ]; then
+ ubuntu_sources=$(grep "\.ubuntu\.com" /etc/apt/sources.list | grep -v '^#' | grep -v "security\.ubuntu\.com")
+ debian_sources=$(grep "\.debian\.org" /etc/apt/sources.list | grep -v '^#' | grep -v "security\.debian\.org")
+
+ if [ "$ubuntu_sources" = "" ] && [ "$debian_sources" = "" ]; then
+ while [ "$yes2" != 'yes' ] && [ "$yes2" != 'no' ]; do
+ read -p "Found that apt source cannot be used. Do need to change it to the official source? [yes/no] " yes2
+ done
+ if [ "$yes2" = "yes" ]; then
+
+ Backup_sources_time=$(date +%Y_%m_%d_%H_%M_%S)
+ cp -arpf /etc/apt/sources.list /etc/apt/sources.list_aapanel_${Backup_sources_time}
+ echo -e "The sources.list file has been backup. The backup file name is:\033[31m /etc/apt/sources.list_aapanel_${Backup_sources_time} \033[0m"
+
+ Change_sources
+
+ if [ "${Change_apt_sources}" != "no" ]; then
+ Install_Deb_Pack
+ fi
+
+ fi
+ fi
+ fi
+}
+
+
+Check_Install_Sys_Packs() {
+ echo "Checking necessary dependency system packages"
+ # Define functions for installation packages
+ install_package() {
+ local package=$1
+ if [ "${PM}" = "yum" ]; then
+ yum install "$package" -y
+ elif [ "${PM}" = "apt-get" ]; then
+ dpkg --configure -a
+ apt-get update
+ apt-get install "$package" -y
+ fi
+ }
+
+ # Define a function to install and verify
+ install_and_verify() {
+ local package_name=$1
+ local command_name=$2
+
+ # First try installing directly
+ if ! Command_Exists "$command_name"; then
+ install_package "$package_name"
+ fi
+
+ # try change official sources
+ if [ ! -f "/usr/bin/$command_name" ] && [ ! -f "/bin/$command_name" ] && ! Command_Exists "$command_name"; then
+ Check_Change_official_sources
+ fi
+
+ # Check again, if it is still missing, an error message will be reported.
+ if [ ! -f "/usr/bin/$command_name" ] && [ ! -f "/bin/$command_name" ] && ! Command_Exists "$command_name"; then
+ echo -e "\033[31mERROR: "$command_name" command does not exist, try the following solutions:\033[0m"
+ echo -e "1. Use command reinstall dependent packages: \033[31m ${PM} reinstall -y $package_name \033[0m"
+ echo -e "2. Check if system source is available? Try changing available system sources"
+ echo -e "After solving the above problems, please try to reinstall!"
+ if [ -s /etc/apt/sources.list ]; then
+ Vive_source=$(grep -v '^#' /etc/apt/sources.list | grep -Ev "^\s*$|security\.ubuntu\.com|security\.debian\.org" | head -n 1)
+ Vive_source="apt source: $Vive_source"
+ # echo "$Vive_source"
+ fi
+ Red_Error "Error: $command_name command not found, please install $package_name command. $Vive_source"
+ fi
+ }
+
+ # Install and check unzip
+ install_and_verify "unzip" "unzip"
+
+ # Install and check tar
+ install_and_verify "tar" "tar"
+
+ # Install and check wget
+ install_and_verify "wget" "wget"
+}
+
+Get_Versions() {
+ redhat_version_file="/etc/redhat-release"
+ deb_version_file="/etc/issue"
+
+ if [[ $(grep "Amazon Linux" /etc/os-release) ]]; then
+ os_type="Amazon-"
+ os_version=$(cat /etc/os-release | grep "Amazon Linux" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ yum install cronie -y
+ return
+ fi
+
+ if [[ $(grep OpenCloudOS /etc/os-release) ]]; then
+ os_type="OpenCloudOS-"
+ os_version=$(cat /etc/os-release | grep OpenCloudOS | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [[ $os_version == "7" ]]; then
+ os_type="el"
+ os_version="7"
+ fi
+ return
+ fi
+
+ if [[ $(grep "Linux Mint" $deb_version_file) ]]; then
+ os_version=$(cat $deb_version_file | grep "Linux Mint" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_version=$(cat $deb_version_file | grep "Linux Mint" | grep -Eo '[0-9]+')
+ fi
+ # Linux-Mint 使用 ubuntu pyenv
+ os_type='ubuntu'
+ if [[ "$os_version" =~ "21" ]]; then
+ os_version="22"
+ echo "$os_version"
+ fi
+ if [[ "$os_version" =~ "20" ]]; then
+ os_version="20"
+ echo "$os_version"
+ fi
+ return
+ fi
+
+ if [[ $(grep openEuler /etc/os-release) ]]; then
+ os_type="openEuler-"
+ os_version=$(cat /etc/os-release | grep openEuler | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep AlmaLinux /etc/os-release) ]]; then
+ os_type="Alma-"
+ os_version=$(cat /etc/os-release | grep AlmaLinux | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep Rocky /etc/os-release) ]]; then
+ os_type="Rocky-"
+ os_version=$(cat /etc/os-release | grep Rocky | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep Anolis /etc/os-release) ]] && [[ $(grep VERSION /etc/os-release|grep 8.8) ]];then
+ if [ -f "/usr/bin/yum" ];then
+ os_type="anolis"
+ os_version="8"
+ return
+ fi
+ fi
+
+ if [ -s $redhat_version_file ]; then
+ os_type='el'
+ if [[ $(grep 'Alibaba Cloud Linux (Aliyun Linux) release 2' $redhat_version_file) ]]; then
+ os_version="7"
+ return
+ fi
+
+ is_aliyunos=$(cat $redhat_version_file | grep Aliyun)
+ if [ "$is_aliyunos" != "" ]; then
+ return
+ fi
+
+ if [[ $(grep "Red Hat" $redhat_version_file) ]]; then
+ os_type='el'
+ os_version=$(cat $redhat_version_file | grep "Red Hat" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]')
+ return
+ fi
+
+ if [[ $(grep "Alibaba Cloud Linux release 3 " /etc/redhat-release) ]]; then
+ os_type="ali-linux-"
+ os_version="3"
+ return
+ fi
+
+ if [[ $(grep "Alibaba Cloud" /etc/redhat-release) ]] && [[ $(grep al8 /etc/os-release) ]];then
+ os_type="ali-linux-"
+ os_version="al8"
+ return
+ fi
+
+ if [[ $(grep TencentOS /etc/redhat-release) ]]; then
+ os_type="TencentOS-"
+ os_version=$(cat /etc/redhat-release | grep TencentOS | grep -Eo '([0-9]+\.)+[0-9]+')
+ if [[ $os_version == "2.4" ]]; then
+ os_type="el"
+ os_version="7"
+ elif [[ $os_version == "3.1" ]]; then
+ os_version="3.1"
+ fi
+ return
+ fi
+
+ os_version=$(cat $redhat_version_file | grep CentOS | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]')
+ if [ "${os_version}" = "5" ]; then
+ os_version=""
+ fi
+ if [ -z "${os_version}" ]; then
+ os_version=$(cat /etc/redhat-release | grep Stream | grep -oE "8|9")
+ fi
+ else
+ os_type='ubuntu'
+ os_version=$(cat $deb_version_file | grep Ubuntu | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_type='debian'
+ os_version=$(cat $deb_version_file | grep Debian | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_version=$(cat $deb_version_file | grep Debian | grep -Eo '[0-9]+')
+ fi
+ if [ "${os_version}" = "8" ]; then
+ os_version=""
+ fi
+ if [ "${is64bit}" = '32' ]; then
+ os_version=""
+ fi
+ else
+ if [ "$os_version" = "14" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "12" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "19" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "21" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "20" ]; then
+ os_version2004=$(cat /etc/issue | grep 20.04)
+ if [ -z "${os_version2004}" ]; then
+ os_version=""
+ fi
+ fi
+ fi
+ fi
+}
+
+Install_Openssl111(){
+ Get_Versions
+ if [ -f "/www/server/panel/openssl_make.pl" ]; then
+ # 存在时编译
+ openssl_make="yes"
+ rm -f /www/server/panel/openssl_make.pl
+ fi
+
+ CPU_arch=$(uname -m)
+ if [ "${CPU_arch}" == "aarch64" ];then
+ CPU_arch="-aarch64"
+ elif [ "${CPU_arch}" == "x86_64" ];then
+ # x86_64 默认为空
+ CPU_arch=""
+ else
+ openssl_make="yes"
+ fi
+
+ if [[ $os_type = "el" ]] && [[ $os_version == "7" ]] && [[ $openssl_make != "yes" ]]; then
+ wget --no-check-certificate -O openssl111.tar.gz ${download_Url}/install/src/openssl111${CPU_arch}.tar.gz -t 5 -T 20
+ tmp_size=$(du -b openssl111.tar.gz | awk '{print $1}')
+ if [ $tmp_size -lt 5014046 ]; then
+ rm -f openssl111.tar.gz
+ Red_Error "ERROR: Download openssl111.tar.gz fielded."
+ fi
+ tar zxvf openssl111.tar.gz -C /usr/local/
+ rm -f openssl111.tar.gz
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ];then
+ Red_Error "/usr/local/openssl111/bin/openssl file does not exist!"
+ fi
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ else
+ if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
+ yum install -y perl lksctp-tools-devel
+ else
+ apt install -y perl
+ fi
+ opensslVersion="1.1.1o"
+ wget --no-check-certificate -O openssl-${opensslVersion}.tar.gz ${download_Url}/src/openssl-${opensslVersion}.tar.gz -t 5 -T 20
+ tmp_size=$(du -b openssl-${opensslVersion}.tar.gz | awk '{print $1}')
+ if [ $tmp_size -lt 9056386 ]; then
+ rm -f openssl-${opensslVersion}.tar.gz
+ Red_Error "ERROR: Download openssl-${opensslVersion}.tar.gz fielded."
+ fi
+ tar -zxvf openssl-${opensslVersion}.tar.gz
+ if [ ! -d "openssl-${opensslVersion}" ];then
+ Red_Error "Decompression failed openssl-${opensslVersion} Directory does not exist!"
+ fi
+ cd openssl-${opensslVersion}
+ ./config --prefix=/usr/local/openssl111 --openssldir=/usr/local/openssl111 enable-md2 enable-rc5 sctp zlib-dynamic shared -fPIC
+ make -j$cpu_cpunt
+ make install
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ];then
+ Red_Error "Compilation failed /usr/local/openssl111/bin/openssl file does not exist!"
+ fi
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ cd ..
+ rm -rf openssl-${opensslVersion} openssl-${opensslVersion}.tar.gz
+ fi
+ openssl111Check=$(/usr/local/openssl111/bin/openssl version|grep 1.1.1)
+ if [ -z "${openssl111Check}" ];then
+ Red_Error "openssl-1.1.1 install failed!"
+ fi
+}
+
+Update_Py_Lib(){
+# Need to use Werkzeug 2.2.3
+ mypip="/www/server/panel/pyenv/bin/pip3"
+ Werkzeug_path="/www/server/panel/script/Werkzeug-2.2.3-py3-none-any.whl"
+ pycountry_path="/www/server/panel/script/pycountry-24.6.1-py3-none-any.whl"
+ # pyOpenSSL_path="/www/server/panel/script/pyOpenSSL-23.1.1-py3-none-any.whl"
+
+ change_pip_package_list=$( $mypip list | grep -E "Werkzeug|lxml|pycountry" )
+ #change_pip_package_list=$( $mypip list | grep -E "Werkzeug|lxml" )
+
+ Werkzeug_v=$(echo "$change_pip_package_list" | grep Werkzeug | grep 2.2.3)
+ if [ "$Werkzeug_v" = "" ];then
+ echo "Update Werkzeug"
+ $mypip uninstall Werkzeug -y
+ $mypip install $Werkzeug_path
+
+ Werkzeug_v_2=$($mypip list |grep Werkzeug | grep 2.2.3)
+ if [ "$Werkzeug_v_2" = "" ];then
+ $mypip install Werkzeug==2.2.3
+ fi
+ fi
+
+ pycountry_v=$(echo "$change_pip_package_list" | grep pycountry)
+ if [ "$pycountry_v" = "" ];then
+ echo "Update pycountry"
+ $mypip install $pycountry_path
+ rm -f $pycountry_path
+
+ pycountry_v_2=$($mypip list |grep pycountry)
+ if [ "$pycountry_v_2" = "" ];then
+ $mypip install pycountry
+ fi
+ fi
+
+ # pyOpenSSL_v=$(echo "$change_pip_package_list" | grep pyOpenSSL | grep 23.1.1)
+ # if [ "$pyOpenSSL_v" = "" ];then
+ # echo "Update pyOpenSSL"
+ # $mypip uninstall pyOpenSSL cryptography -y
+ # $mypip install $pyOpenSSL_path cryptography==40.0.2
+
+ # pyOpenSSL_v_2=$($mypip list |grep pyOpenSSL | grep 23.1.1)
+ # if [ "$pyOpenSSL_v_2" = "" ];then
+ # $mypip install pyOpenSSL==23.1.1 cryptography==40.0.2
+ # fi
+ # fi
+
+ lxml_v=$(echo "$change_pip_package_list" | grep lxml | grep 5.2.1)
+ if [ "$lxml_v" != "" ];then
+ echo "Update lxml"
+ $mypip uninstall lxml -y
+ # bt 16 升级脚本时安装,安装时间久 这里不开,下面进行处理了
+ # echo "Please wait a moment to install lxml, it will take a long time."
+ # $mypip install lxml==5.0.0
+
+ # lxml_v_2=$($mypip list |grep lxml | grep 5.2.1)
+ # if [ "$lxml_v_2" = "" ];then
+ # $mypip install lxml==5.0.0
+ # fi
+ fi
+
+}
+
+Check_PIP_Packages(){
+
+ mypip="/www/server/panel/pyenv/bin/pip3"
+ show_pip_list_panel="/tmp/show_pip_list_panel.txt"
+
+ trusted_host="--trusted-host mirrors.tencent.com --trusted-host pypi.doubanio.com --trusted-host mirrors.aliyun.com --trusted-host pypi.tuna.tsinghua.edu.cn --trusted-host pypi.org"
+
+ echo "Check pip package, please wait..."
+
+ ${mypip} list | awk '{print $1}' > ${show_pip_list_panel}
+
+ check_pip_packs="/www/server/panel/check-pip-packs.txt"
+ if [ ! -s "${check_pip_packs}" ]; then
+ check_pip_packs="/tmp/check-pip-packs_3.12.txt"
+ wget --no-check-certificate -O ${check_pip_packs} ${download_Url}/install/pyenv/3.12/check-pip-packs_3.12.txt -t 5 -T 20
+ fi
+
+ Install_PIP_PACKS_File="/www/server/panel/requirements.txt"
+ if [ ! -s "${Install_PIP_PACKS_File}" ]; then
+ Install_PIP_PACKS_File="/tmp/pip_en_3.12.txt"
+ wget --no-check-certificate -O ${Install_PIP_PACKS_File} ${download_Url}/install/pyenv/3.12/pip_en_3.12.txt -t 5 -T 20
+ fi
+
+ PIP_PACKS=$(cat ${check_pip_packs} )
+ for ONE_PACK in ${PIP_PACKS};
+ do
+ Install_PIP_PACKS=`grep "^${ONE_PACK}==" ${Install_PIP_PACKS_File}`
+ if [ -z "${Install_PIP_PACKS}" ]; then
+ Install_PIP_PACKS=${ONE_PACK}
+ fi
+ Show_PIP_PACK=`grep "^${ONE_PACK}\$" ${show_pip_list_panel}`
+ # echo ${Show_PIP_PACK}
+ if [ -z "${Show_PIP_PACK}" ];then
+ if [[ "${ONE_PACK}" == "aliyun-python-sdk-kms" || "${ONE_PACK}" == "aliyun-python-sdk-core" || "${ONE_PACK}" == "aliyun-python-sdk-core-v3" || "${ONE_PACK}" == "qiniu" || "${ONE_PACK}" == "cos-python-sdk-v5" ]]; then
+ echo "Install packages: ${Install_PIP_PACKS}" >/dev/null 2>&1
+ else
+ echo "Install packages: ${Install_PIP_PACKS}"
+ fi
+
+ if [[ "${ONE_PACK}" == "Flask" ]]; then
+ ${mypip} uninstall Flask Werkzeug -y
+ ${mypip} install Flask==2.2.5 Werkzeug==2.2.3 ${trusted_host}
+ elif [[ "${ONE_PACK}" == "Werkzeug" ]]; then
+ ${mypip} install Werkzeug==2.2.3 ${trusted_host}
+ elif [[ "${ONE_PACK}" == "aliyun-python-sdk-kms" || "${ONE_PACK}" == "aliyun-python-sdk-core" || "${ONE_PACK}" == "aliyun-python-sdk-core-v3" || "${ONE_PACK}" == "qiniu" || "${ONE_PACK}" == "cos-python-sdk-v5" ]]; then
+ echo "${Install_PIP_PACKS} ..." >/dev/null 2>&1
+ else
+ ${mypip} install ${Install_PIP_PACKS} ${trusted_host}
+ fi
+ fi
+ done
+
+}
+
+Install_Python_Lib() {
+
+ # openssl 版本低于1.1.1 需要安装 如CentOS 7
+ OPENSSL_VER=$(openssl version|grep -oE '1.0|1.1.0')
+ if [ "${OPENSSL_VER}" ]; then
+
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ]; then
+ Install_Openssl111
+ else
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ openssl111Check=$(/usr/local/openssl111/bin/openssl version|grep 1.1.1)
+ if [ -z "${openssl111Check}" ];then
+ Install_Openssl111
+ fi
+ if [ ! -f "/etc/ld.so.conf.d/openssl111.conf" ] || [ ! -f "/etc/ld.so.conf.d/zopenssl111.conf" ]; then
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ fi
+ fi
+ Use_Openssl111="yes"
+ fi
+
+ curl -sSk --connect-timeout 5 -m 60 $download_Url/install/pip_select.sh | bash
+ pyenv_path="/www/server/panel"
+ if [ -f $pyenv_path/pyenv/bin/python ]; then
+ is_ssl=$($python_bin -c "import ssl" 2>&1 | grep cannot)
+ $pyenv_path/pyenv/bin/python3.12 -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 --no-check-certificate -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/3.12/pip_en_3.12.txt -t 5 -T 20
+ $pyenv_path/pyenv/bin/pip install -U pip
+ $pyenv_path/pyenv/bin/pip install -U setuptools
+ $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
+
+ py_version="3.12.3"
+ python_version="-3.12"
+ mkdir -p $pyenv_path
+ echo "True" >/www/disk.pl
+ if [ ! -w /www/disk.pl ]; then
+ Red_Error "ERROR: Install python env fielded." "ERROR: path [www] cannot be written, please check the directory/user/disk permissions!"
+ fi
+ os_type='el'
+ os_version='7'
+ is_export_openssl=0
+ Get_Versions
+ echo "OS: $os_type - $os_version"
+ is_aarch64=$(uname -m | grep aarch64)
+ if [ "$is_aarch64" != "" ]; then
+ is64bit="aarch64"
+ fi
+ if [ -f "/www/server/panel/pymake.pl" ]; then
+ os_version=""
+ rm -f /www/server/panel/pymake.pl
+ fi
+ if [ "${os_version}" != "" ]; then
+ pyenv_file="/www/pyenv.tar.gz"
+ wget --no-check-certificate -O $pyenv_file $download_Url/install/pyenv/3.12/pyenv-${os_type}${os_version}-x${is64bit}${python_version}.tar.gz -t 5 -T 20
+ if [ "$?" != "0" ];then
+ get_node_url $download_Url
+ wget --no-check-certificate -O $pyenv_file $download_Url/install/pyenv/3.12/pyenv-${os_type}${os_version}-x${is64bit}${python_version}.tar.gz -t 5 -T 20
+ fi
+ tmp_size=$(du -b $pyenv_file | awk '{print $1}')
+ if [ $tmp_size -lt 122271175 ]; then
+ rm -f $pyenv_file
+ echo "ERROR: Download python env fielded."
+ else
+ echo "Install python env..."
+ 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. Please try to reinstall"
+ fi
+ $pyenv_path/pyenv/bin/python3.12 -V
+ if [ $? -eq 0 ]; then
+ rm -f $pyenv_file
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 /usr/bin/btpip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 /usr/bin/btpython
+ source $pyenv_path/pyenv/bin/activate
+ return
+ else
+ rm -f $pyenv_file
+ rm -rf $pyenv_path/pyenv
+ fi
+ fi
+ fi
+
+ cd /www
+ python_src='/www/python_src.tar.xz'
+ python_src_path="/www/Python-${py_version}"
+ wget --no-check-certificate -O $python_src $download_Url/src/Python-${py_version}.tar.xz -t 5 -T 20
+ 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. Please try to reinstall OS_${os_type}_${os_version}."
+ fi
+ tar xvf $python_src
+ rm -f $python_src
+ cd $python_src_path
+ if [[ $Use_Openssl111 = "yes" ]]; then
+ # centos7 或者低openssl于1.1.1使用
+ export OPENSSL_DIR=/usr/local/openssl111
+ ./configure --prefix=$pyenv_path/pyenv \
+ LDFLAGS="-L$OPENSSL_DIR/lib" \
+ CPPFLAGS="-I$OPENSSL_DIR/include" \
+ --with-openssl=$OPENSSL_DIR
+ else
+ ./configure --prefix=$pyenv_path/pyenv
+ fi
+
+ make -j$cpu_cpunt
+ make install
+ if [ ! -f $pyenv_path/pyenv/bin/python3.12 ]; then
+ rm -rf $python_src_path
+ Red_Error "ERROR: Make python env fielded. Please try to reinstall"
+ fi
+ cd ~
+ rm -rf $python_src_path
+ wget --no-check-certificate -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -t 5 -T 20
+ wget --no-check-certificate -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/3.12/pip-3.12.3.txt -t 5 -T 20
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 $pyenv_path/pyenv/bin/pip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 $pyenv_path/pyenv/bin/python
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 /usr/bin/btpip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 /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 wheel==0.34.2
+ $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.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
+ Check_PIP_Packages
+ 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
+ fi
+}
+
+delete_useless_package() {
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-kms -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-core -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-core-v3 -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall qiniu -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall cos-python-sdk-v5 -y >/dev/null 2>&1
+}
+
+Install_Bt() {
+ if [ -f ${setup_path}/server/panel/data/port.pl ]; then
+ panelPort=$(cat ${setup_path}/server/panel/data/port.pl)
+ fi
+
+ if [ "${PANEL_PORT}" ];then
+ panelPort=$PANEL_PORT
+ fi
+
+ mkdir -p ${setup_path}/server/panel/logs
+ mkdir -p ${setup_path}/server/panel/vhost/apache
+ mkdir -p ${setup_path}/server/panel/vhost/nginx
+ mkdir -p ${setup_path}/server/panel/vhost/rewrite
+ mkdir -p ${setup_path}/server/panel/install
+ mkdir -p /www/server
+ mkdir -p /www/wwwroot
+ mkdir -p /www/wwwlogs
+ mkdir -p /www/backup/database
+ mkdir -p /www/backup/site
+
+ if [ ! -d "/etc/init.d" ];then
+ mkdir -p /etc/init.d
+ fi
+
+ if [ -f "/etc/init.d/bt" ]; then
+ /etc/init.d/bt stop
+ sleep 1
+ fi
+
+ panel_file="${setup_path}/panel.zip"
+ wget --no-check-certificate -O ${panel_file} ${Btapi_Url}/install/src/panel_pro_en.zip -t 5 -T 20
+
+ tmp_size=$(du -b ${panel_file} | awk '{print $1}')
+ if [ $tmp_size -lt 10026905 ]; then
+ ls -lh ${panel_file}
+ rm -f ${panel_file}
+ Red_Error "ERROR: Failed to download panel, please try install again!"
+ fi
+
+ # wget --no-check-certificate -O /etc/init.d/bt ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ # wget --no-check-certificate -O /www/server/panel/init.sh ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ # wget --no-check-certificate -O /www/server/panel/install/public.sh ${download_Url}/install/public.sh -t 5 -T 20
+
+ if [ -f "${setup_path}/server/panel/data/default.db" ]; then
+ if [ -d "/${setup_path}/server/panel/old_data" ]; then
+ rm -rf ${setup_path}/server/panel/old_data
+ fi
+ mkdir -p ${setup_path}/server/panel/old_data
+ d_format=$(date +"%Y%m%d_%H%M%S")
+ \cp -arf ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/data/default_backup_${d_format}.db
+ mv -f ${setup_path}/server/panel/data/default.db ${setup_path}/server/panel/old_data/default.db
+ mv -f ${setup_path}/server/panel/data/system.db ${setup_path}/server/panel/old_data/system.db
+ mv -f ${setup_path}/server/panel/data/port.pl ${setup_path}/server/panel/old_data/port.pl
+ mv -f ${setup_path}/server/panel/data/admin_path.pl ${setup_path}/server/panel/old_data/admin_path.pl
+ fi
+
+ unzip -o ${panel_file} -d ${setup_path}/server/ >/dev/null
+
+ if [ -d "${setup_path}/server/panel/old_data" ]; then
+ mv -f ${setup_path}/server/panel/old_data/default.db ${setup_path}/server/panel/data/default.db
+ mv -f ${setup_path}/server/panel/old_data/system.db ${setup_path}/server/panel/data/system.db
+ mv -f ${setup_path}/server/panel/old_data/port.pl ${setup_path}/server/panel/data/port.pl
+ mv -f ${setup_path}/server/panel/old_data/admin_path.pl ${setup_path}/server/panel/data/admin_path.pl
+ if [ -d "/${setup_path}/server/panel/old_data" ]; then
+ rm -rf ${setup_path}/server/panel/old_data
+ fi
+ fi
+
+ if [ ! -f "${setup_path}/server/panel/tools.py" ] || [ ! -f "${setup_path}/server/panel/BT-Panel" ]; then
+ ls -lh ${setup_path}/server/panel/BT-* ${setup_path}/server/panel/tools.py
+ Red_Error "ERROR: tools.py BT-Panel file does not exist, please try install again!"
+ fi
+
+ pro_file='/www/server/panel/data/panel_pro.pl'
+ if [ ! -e $pro_file ]; then
+ touch $pro_file
+ echo "true" > $pro_file
+ fi
+
+ Check_PIP_Packages
+ delete_useless_package
+ Update_Py_Lib
+ rm -f ${panel_file}
+ rm -f ${setup_path}/server/panel/class/*.pyc
+ rm -f ${setup_path}/server/panel/*.pyc
+
+ \cp -arpf /www/server/panel/init.sh /etc/init.d/bt
+ if [[ ! -s "/etc/init.d/bt" ]];then
+ rm -f /etc/init.d/bt
+ wget --no-check-certificate -O /etc/init.d/bt ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ wget --no-check-certificate -O /www/server/panel/init.sh ${download_Url}/install/src/bt7_en.init -t 5 -T 20
+ if [[ ! -s "/etc/init.d/bt" ]];then
+ Red_Error "ERROR: /etc/init.d/bt file content is 0kb "
+ fi
+ fi
+ chmod +x /etc/init.d/bt
+ chmod -R 600 ${setup_path}/server/panel
+ chmod -R 755 ${setup_path}/server/panel/webserver
+ chmod -R +x ${setup_path}/server/panel/script
+ ln -sf /etc/init.d/bt /usr/bin/bt
+ echo "${panelPort}" >${setup_path}/server/panel/data/port.pl
+ wget --no-check-certificate -O /www/server/panel/data/softList.conf ${download_Url}/install/conf/softList_en.conf -t 5 -T 20
+
+ rm -f /www/server/panel/class/*.so
+ if [ ! -f /www/server/panel/data/userInfo.json ]; then
+ echo "{\"id\":1,\"uid\":1,\"server_id\":\"1\",\"last_login_ip\":\"127.0.0.1\",\"username\":\"Administrator\",\"email\":\"admin@aapanel.com\",\"status\":1,\"token\":\"aaa.bbb.ccc\"}" > /www/server/panel/data/userInfo.json
+ fi
+}
+
+Use_self_signed_certificate() {
+ echo "Use Self-signed certificate"
+ rm -f /www/server/panel/ssl/*
+ SSL_path=/www/server/panel/ssl
+ # Create private key
+ openssl genrsa -out ${SSL_path}/privateKey.pem 2048
+
+ # Create a self-signed root certificate
+ openssl req -x509 -new -nodes -key ${SSL_path}/privateKey.pem -sha256 -days 3650 -out ${SSL_path}/certificate.pem \
+ -subj "/C=US/ST=State/L=City/O=aapanel.com/OU=aapanel.com/CN=*.aapanel.com" -nodes
+
+ # Use random password
+ # SSL_password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 16)
+
+ # Create PFX file
+ # openssl pkcs12 -export -out ${SSL_path}/baota_root.pfx -inkey ${SSL_path}/privateKey.pem -in ${SSL_path}/certificate.pem -passout pass:${SSL_password}
+
+ # Create password file
+ # echo "${SSL_password}" > ${SSL_path}/root_password.pl
+
+ echo "True" > /www/server/panel/data/ssl.pl
+ SET_SSL=true
+
+ if [ ! -s "${SSL_path}/privateKey.pem" ] || [ ! -s "${SSL_path}/certificate.pem" ]; then
+ SET_SSL=false
+ rm -f /www/server/panel/data/ssl.pl
+ echo "Self-signed certificate failed, panel SSl closed"
+ fi
+}
+
+Set_Bt_Panel() {
+ Run_User="www"
+ wwwUser=$(cat /etc/passwd|cut -d ":" -f 1|grep ^www$)
+ if [ "${wwwUser}" != "www" ];then
+ groupadd ${Run_User}
+ useradd -s /sbin/nologin -g ${Run_User} ${Run_User}
+ fi
+ chmod -R 700 /www/server/panel/pyenv/bin
+ # /www/server/panel/pyenv/bin/pip install cachelib
+ /www/server/panel/pyenv/bin/pip install python-telegram-bot==20.3
+ password=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
+ if [ "$PANEL_PASSWORD" ];then
+ password=$PANEL_PASSWORD
+ fi
+ sleep 1
+ admin_auth="/www/server/panel/data/admin_path.pl"
+ if [ ! -f ${admin_auth} ]; then
+ auth_path=$(cat /dev/urandom | head -n 16 | md5sum | head -c 8)
+ echo "/${auth_path}" >${admin_auth}
+ fi
+ if [ "${SAFE_PATH}" ];then
+ auth_path=$SAFE_PATH
+ echo "/${auth_path}" > ${admin_auth}
+ fi
+ auth_path=$(cat ${admin_auth})
+ # /www/server/panel/pyenv/bin/pip3 install pymongo
+ # /www/server/panel/pyenv/bin/pip3 install psycopg2-binary
+ # /www/server/panel/pyenv/bin/pip3 install flask -U
+ # /www/server/panel/pyenv/bin/pip3 install flask-sock
+ # /www/server/panel/pyenv/bin/pip3 install simple-websocket==0.10.0
+ check_pyOpenSSL=$(/www/server/panel/pyenv/bin/pip list|grep pyOpenSSL)
+ if [ -z "$check_pyOpenSSL" ]; then
+ /www/server/panel/pyenv/bin/pip install -I pyOpenSSl
+ fi
+ cd ${setup_path}/server/panel/
+ if [ "$SET_SSL" == true ]; then
+ # mkdir /www/server/panel/ssl
+ echo "SET ssl, please wait...."
+ ssl=$(/www/server/panel/pyenv/bin/python /www/server/panel/tools.py ssl)
+ echo ${ssl}
+ if [[ "${ssl}" -eq 1 ]];then
+ if [ -s "/www/server/panel/ssl/certificate.pem" ];then
+ check_certificate=$(openssl x509 -noout -modulus -in /www/server/panel/ssl/certificate.pem | openssl md5)
+ check_privateKey=$(openssl rsa -noout -modulus -in /www/server/panel/ssl/privateKey.pem | openssl md5)
+ if [ "${check_certificate}" != "${check_privateKey}" ];then
+ echo -e "The certificate and privateKey are not consistent, Use the built-in SSL certificate."
+ Use_self_signed_certificate
+ fi
+ else
+ Use_self_signed_certificate
+ fi
+ else
+ Use_self_signed_certificate
+ fi
+ echo "SET_SSL: $SET_SSL"
+ fi
+ /etc/init.d/bt start
+ $python_bin -m py_compile tools.py
+ $python_bin tools.py username
+ username=$($python_bin tools.py panel ${password})
+ if [ "$PANEL_USER" ];then
+ username=$PANEL_USER
+ fi
+ cd ~
+ echo "${password}" >${setup_path}/server/panel/default.pl
+ chmod 600 ${setup_path}/server/panel/default.pl
+ sleep 3
+ /etc/init.d/bt restart
+ sleep 5
+ isStart=$(ps aux | grep 'BT-Panel' | grep -v grep | awk '{print $2}')
+ if [ -z "${isStart}" ]; then
+ /etc/init.d/bt start
+ sleep 5
+ isStart=$(ps aux | grep 'BT-Panel' | grep -v grep | awk '{print $2}')
+ if [ -z "${isStart}" ]; then
+ Check_PIP_Packages
+ /etc/init.d/bt start
+ sleep 5
+ isStart=$(ps aux | grep 'BT-Panel' | grep -v grep | awk '{print $2}')
+ fi
+ fi
+
+ LOCAL_CURL=$(curl 127.0.0.1:$panelPort/login 2>&1 | grep -i html)
+ if [ -z "${isStart}" ] && [ -z "${LOCAL_CURL}" ]; then
+ /etc/init.d/bt 22
+ cd /www/server/panel/pyenv/bin
+ touch t.pl
+ ls -al python3.12 python3 python ${setup_path}/server/panel/BT-*
+ lsattr python3.12 python3 python
+ Red_Error "ERROR: The BT-Panel service startup failed."
+ fi
+
+ if [ "$PANEL_USER" ];then
+ cd ${setup_path}/server/panel/
+ btpython -c 'import tools;tools.set_panel_username("'$PANEL_USER'")'
+ cd ~
+ fi
+ if [ -f "/usr/bin/sqlite3" ] ;then
+ #sqlite3 /www/server/panel/data/db/panel.db "UPDATE config SET status = '1' WHERE id = '1';" > /dev/null 2>&1
+ sqlite3 /www/server/panel/data/default.db "UPDATE config SET status = '1' WHERE id = '1';" > /dev/null 2>&1
+ fi
+
+ touch /www/server/panel/install/i_mysql.pl
+
+}
+Set_Firewall() {
+ sshPort=$(cat /etc/ssh/sshd_config | grep 'Port ' | awk '{print $2}')
+ if [ "${PM}" = "apt-get" ]; then
+ if [ ! -f "/usr/bin/ufw" ] && [ ! -f "/bin/ufw" ] && ! Command_Exists "ufw"; then
+ apt-get install -y ufw
+ fi
+ if [ -f "/usr/sbin/ufw" ]; then
+ ufw allow 20/tcp >/dev/null 2>&1
+ ufw allow 21/tcp >/dev/null 2>&1
+ ufw allow 22/tcp >/dev/null 2>&1
+ ufw allow 80/tcp >/dev/null 2>&1
+ ufw allow 443/tcp >/dev/null 2>&1
+ ufw allow 888/tcp >/dev/null 2>&1
+ ufw allow 39000:40000/tcp >/dev/null 2>&1
+ ufw allow ${panelPort}/tcp >/dev/null 2>&1
+ ufw allow ${sshPort}/tcp >/dev/null 2>&1
+ ufw_status=$(ufw status)
+ echo y | ufw enable
+ ufw default deny
+ ufw reload
+ fi
+ else
+ if [ -f "/etc/init.d/iptables" ]; then
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 20 -j ACCEPT
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+ 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 ${panelPort} -j ACCEPT
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport ${sshPort} -j ACCEPT
+ iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 39000:40000 -j ACCEPT
+ #iptables -I INPUT -p tcp -m state --state NEW -m udp --dport 39000:40000 -j ACCEPT
+ iptables -A INPUT -p icmp --icmp-type any -j ACCEPT
+ iptables -A INPUT -s localhost -d localhost -j ACCEPT
+ iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
+ iptables -P INPUT DROP
+ service iptables save
+ sed -i "s#IPTABLES_MODULES=\"\"#IPTABLES_MODULES=\"ip_conntrack_netbios_ns ip_conntrack_ftp ip_nat_ftp\"#" /etc/sysconfig/iptables-config
+ iptables_status=$(service iptables status | grep 'not running')
+ if [ "${iptables_status}" == '' ]; then
+ service iptables restart
+ fi
+ else
+ AliyunCheck=$(cat /etc/redhat-release | grep "Aliyun Linux")
+ [ "${AliyunCheck}" ] && return
+ if [ ! -f "/usr/bin/firewall-cmd" ] && [ ! -f "/bin/firewall-cmd" ] && ! Command_Exists "firewall-cmd"; then
+ yum install firewalld -y
+ fi
+ [ "${Centos8Check}" ] && yum reinstall python3-six -y
+ systemctl enable firewalld
+ systemctl start firewalld
+ firewall-cmd --set-default-zone=public >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=20/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=21/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=22/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=80/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=443/tcp > /dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=${panelPort}/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=${sshPort}/tcp >/dev/null 2>&1
+ firewall-cmd --permanent --zone=public --add-port=39000-40000/tcp >/dev/null 2>&1
+ #firewall-cmd --permanent --zone=public --add-port=39000-40000/udp > /dev/null 2>&1
+ firewall-cmd --reload
+ fi
+ fi
+}
+Get_Ip_Address() {
+ getIpAddress=""
+ # getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://brandnew.aapanel.com/api/common/getClientIP)
+ getIpAddress=$(curl -sSk --connect-timeout 10 -m 60 https://www.aapanel.com/api/common/getClientIP)
+ # if [ -z "${getIpAddress}" ] || [ "${getIpAddress}" = "0.0.0.0" ]; then
+ # isHosts=$(cat /etc/hosts|grep 'www.bt.cn')
+ # if [ -z "${isHosts}" ];then
+ # echo "" >> /etc/hosts
+ # echo "103.224.251.67 www.bt.cn" >> /etc/hosts
+ # #getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://brandnew.aapanel.com/api/common/getClientIP)
+ # getIpAddress=$(curl -sS --connect-timeout 10 -m 60 https://www.bt.cn/Api/getIpAddress)
+ # if [ -z "${getIpAddress}" ];then
+ # sed -i "/bt.cn/d" /etc/hosts
+ # fi
+ # fi
+ # fi
+
+ ipv4Check=$($python_bin -c "import re; print(re.match(r'^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$','${getIpAddress}'))")
+ if [ "${ipv4Check}" == "None" ]; then
+ ipv6Address=$(echo ${getIpAddress} | tr -d "[]")
+ ipv6Check=$($python_bin -c "import re; print(re.match(r'^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$','${ipv6Address}'))")
+ if [ "${ipv6Check}" == "None" ]; then
+ getIpAddress="SERVER_IP"
+ else
+ getIpAddress=$(echo "[$getIpAddress]")
+ echo "True" >${setup_path}/server/panel/data/ipv6.pl
+ sleep 1
+ /etc/init.d/bt restart
+ fi
+ fi
+
+ if [ "${getIpAddress}" != "SERVER_IP" ]; then
+ echo "${getIpAddress}" >${setup_path}/server/panel/data/iplist.txt
+ fi
+}
+Setup_Count() {
+ # curl -sSk --connect-timeout 10 -m 60 https://www.aapanel.com/api/setupCount/setupPanel?o=$1 >/dev/null 2>&1
+ # curl -sS --connect-timeout 10 -m 60 https://console.aapanel.com/Api/SetupCount?type=Linux > /dev/null 2>&1
+ if [ "$1" != "" ]; then
+ echo $1 >/www/server/panel/data/o.pl
+ cd /www/server/panel
+ $python_bin tools.py o
+ fi
+ echo /www >/var/bt_setupPath.conf
+}
+
+Install_Main() {
+
+ Check_Disk_Space
+ startTime=$(date +%s)
+ Lock_Clear
+ System_Check
+ Set_Ssl
+ Get_Pack_Manager
+ get_node_url
+
+ MEM_TOTAL=$(free -g | grep Mem | awk '{print $2}')
+ if [ "${MEM_TOTAL}" -le "1" ]; then
+ Auto_Swap
+ fi
+
+ if [ "${PM}" = "yum" ]; then
+ Install_RPM_Pack
+ elif [ "${PM}" = "apt-get" ]; then
+ Install_Deb_Pack
+ fi
+
+ Check_Install_Sys_Packs
+
+ Install_Python_Lib
+ Install_Bt
+
+ Set_Bt_Panel
+ Service_Add
+ Set_Firewall
+
+ Get_Ip_Address
+ Setup_Count ${IDC_CODE}
+}
+
+echo "
++----------------------------------------------------------------------
+| aaPanel FOR CentOS/Ubuntu/Debian
++----------------------------------------------------------------------
+| Copyright © 2015-2099 BT-SOFT(https://www.aapanel.com) All rights reserved.
++----------------------------------------------------------------------
+| The WebPanel URL will be https://SERVER_IP:$panelPort when installed.
++----------------------------------------------------------------------
+"
+
+while [ ${#} -gt 0 ]; do
+ case $1 in
+ -h|--help)
+ echo "Usage: [options]"
+ echo "Options:"
+ echo " -u, --user Set aaPanel user name"
+ echo " -p, --password Set aaPanel password"
+ echo " -P, --port Set aaPanel port"
+ echo " --safe-path Set aaPanel safe path"
+ exit 0
+ ;;
+ -u|--user)
+ PANEL_USER=$2
+ shift 1
+ ;;
+ -p|--password)
+ PANEL_PASSWORD=$2
+ shift 1
+ ;;
+ -P|--port)
+ PANEL_PORT=$2
+ shift 1
+ ;;
+ --safe-path)
+ SAFE_PATH=$2
+ shift 1
+ ;;
+ --ssl-disable)
+ SSL_PL="disable"
+ ;;
+ -y)
+ go="y"
+ ;;
+ *)
+ IDC_CODE=$1
+ ;;
+ esac
+ shift 1
+done
+while [ "$go" != 'y' ] && [ "$go" != 'n' ]; do
+ read -p "Do you want to install aaPanel to the $setup_path directory now?(y/n): " go
+done
+
+if [ "$go" == 'n' ]; then
+ exit
+fi
+
+Install_Main
+/etc/init.d/bt restart
+intenal_ip=$(ip addr | grep -E -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | grep -E -v "^127\.|^255\.|^0\." | head -n 1)
+echo -e "=================================================================="
+echo -e "\033[32mCongratulations! Installed successfully!\033[0m"
+echo -e "=================================================================="
+if [[ "$SET_SSL" == "true" ]]; then
+ HTTP_S="https"
+else
+ HTTP_S="http"
+fi
+echo "aaPanel Internet Address: ${HTTP_S}://${getIpAddress}:${panelPort}$auth_path"
+echo "aaPanel Internal Address: ${HTTP_S}://${intenal_ip}:${panelPort}$auth_path"
+echo -e "username: $username"
+echo -e "password: $password"
+echo -e "\033[33mWarning:\033[0m"
+echo -e "\033[33mIf you cannot access the panel, \033[0m"
+echo -e "\033[33mrelease the following port ($panelPort|888|80|443|20|21) in the security group\033[0m"
+echo -e "=================================================================="
+
+endTime=$(date +%s)
+((outTime = ($endTime - $startTime) / 60))
+if [ "${outTime}" == "0" ];then
+ ((outTime=($endTime-$startTime)))
+ echo -e "Time consumed:\033[32m $outTime \033[0mseconds!"
+else
+ echo -e "Time consumed:\033[32m $outTime \033[0mMinute!"
+fi
+rm -f install_7.0_en.sh /tmp/pip_en_3.12.txt ${check_pip_packs} ${show_pip_list_panel}
diff --git a/public/install/src/panel6.zip b/public/install/src/panel6.zip
index 70ec706..f5dc10a 100644
Binary files a/public/install/src/panel6.zip and b/public/install/src/panel6.zip differ
diff --git a/public/install/src/panel_7_en.zip b/public/install/src/panel_7_en.zip
new file mode 100644
index 0000000..b0963a4
Binary files /dev/null and b/public/install/src/panel_7_en.zip differ
diff --git a/public/install/update/LinuxPanel-9.3.0.zip b/public/install/update/LinuxPanel-9.3.0.zip
index 1593c70..a28e64a 100644
Binary files a/public/install/update/LinuxPanel-9.3.0.zip and b/public/install/update/LinuxPanel-9.3.0.zip differ
diff --git a/public/install/update/LinuxPanel_EN-7.0.13.zip b/public/install/update/LinuxPanel_EN-7.0.13.zip
new file mode 100644
index 0000000..240e8db
Binary files /dev/null and b/public/install/update/LinuxPanel_EN-7.0.13.zip differ
diff --git a/public/install/update6.sh b/public/install/update6.sh
index 87620e6..05bc267 100644
--- a/public/install/update6.sh
+++ b/public/install/update6.sh
@@ -254,7 +254,7 @@ if [ ! -f /www/server/panel/data/not_workorder.pl ]; then
echo "True" > /www/server/panel/data/not_workorder.pl
fi
if [ ! -f /www/server/panel/data/userInfo.json ]; then
- echo "{\"uid\":1,\"username\":\"Administrator\",\"address\":\"127.0.0.1\",\"serverid\":\"1\",\"access_key\":\"test\",\"secret_key\":\"123456\",\"ukey\":\"123456\",\"state\":1}" > /www/server/panel/data/userInfo.json
+ echo "{\"uid\":1,\"username\":\"Administrator\",\"address\":\"127.0.0.1\",\"access_key\":\"test\",\"secret_key\":\"123456\",\"ukey\":\"123456\",\"state\":1}" > /www/server/panel/data/userInfo.json
fi
if [ ! -f /www/server/panel/data/panel_nps.pl ]; then
echo "" > /www/server/panel/data/panel_nps.pl
diff --git a/public/install/update_7.x_en.sh b/public/install/update_7.x_en.sh
new file mode 100644
index 0000000..c6dd32a
--- /dev/null
+++ b/public/install/update_7.x_en.sh
@@ -0,0 +1,1017 @@
+#!/bin/bash
+PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
+export PATH
+LANG=en_US.UTF-8
+
+Btapi_Url='http://www.example.com'
+if [ ! -d /www/server/panel/BTPanel ];then
+ echo "============================================="
+ echo "Error, 5.x Can't use this command to upgrade!"
+ exit 0;
+fi
+
+Updating="/tmp/update_to7.pl"
+if [ -f "$Updating" ];then
+ echo "Error, $Updating file exists. Please delete this $Updating before executing the command."
+ exit 0;
+else
+ touch $Updating
+fi
+
+
+# public_file=/www/server/panel/install/public.sh
+# publicFileMd5=$(md5sum ${public_file} 2>/dev/null|awk '{print $1}')
+# md5check="f3fb69f071f7fa800e5f2d5ec3e128c3"
+# if [ "${publicFileMd5}" != "${md5check}" ]; then
+# wget -O Tpublic.sh https://node.aapanel.com/install/public.sh -T 20;
+# publicFileMd5=$(md5sum Tpublic.sh 2>/dev/null|awk '{print $1}')
+# if [ "${publicFileMd5}" == "${md5check}" ]; then
+# \cp -rpa Tpublic.sh $public_file
+# fi
+# rm -f Tpublic.sh
+# fi
+
+# . $public_file
+
+if [ -f /etc/redhat-releas ]; then
+ Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos8Check}" ];then
+ if [ ! -f "/usr/bin/python" ] && [ -f "/usr/bin/python3" ] && [ ! -d "/www/server/panel/pyenv" ]; then
+ ln -sf /usr/bin/python3 /usr/bin/python
+ fi
+ fi
+fi
+
+# download_Url=$NODE_URL
+# if [ "$download_Url" = "" ];then
+# download_Url=https://node.aapanel.com
+# fi
+
+download_Url=https://node.aapanel.com
+
+Set_Centos7_Repo(){
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "[^#]mirror.centos.org")
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ echo "Centos7 official repository source has been discontinued , Replacement in progress."
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist=/#mirrorlist=/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ fi
+
+ MIRROR_CHECK22=$(cat /etc/yum.repos.d/CentOS-Base.repo |grep "mirrorlist.centos.org"|grep -v '^#')
+ if [ "${MIRROR_CHECK22}" ] && [ "${is64bit}" == "64" ];then
+ echo "Centos7 official repository source has been discontinued , Replacement in progress."
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ \cp -rpa /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bt_bak
+cat > /etc/yum.repos.d/CentOS-Base.repo << EOF
+
+# CentOS-Base.repo
+
+[base]
+name=CentOS-\$releasever - Base
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=os&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/os/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#released updates
+[updates]
+name=CentOS-\$releasever - Updates
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=updates&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/updates/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that may be useful
+[extras]
+name=CentOS-\$releasever - Extras
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=extras&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/extras/\$basearch/
+gpgcheck=1
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+#additional packages that extend functionality of existing packages
+[centosplus]
+name=CentOS-\$releasever - Plus
+#mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=centosplus&infra=\$infra
+baseurl=http://vault.epel.cloud/centos/\$releasever/centosplus/\$basearch/
+gpgcheck=1
+enabled=0
+gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
+
+EOF
+
+ fi
+
+ ALI_CLOUD_CHECK=$(grep Alibaba /etc/motd)
+ Tencent_Cloud=$(cat /etc/hostname |grep -E VM-[0-9]+-[0-9]+)
+ if [ "${ALI_CLOUD_CHECK}" ] || [ "${Tencent_Cloud}" ];then
+ return
+ fi
+
+ yum install tree -y
+ if [ "$?" != "0" ] ;then
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ if [ -z "${download_Url}" ];then
+ download_Url="https://node.aapanel.com"
+ fi
+ curl -Ssk --connect-timeout 20 -m 60 -O ${download_Url}/src/el7repo.tar.gz
+ if [ -f "/usr/bin/wget" ] && [ ! -s "el7repo.tar.gz" ];then
+ wget --no-check-certificate -O el7repo.tar.gz ${download_Url}/src/el7repo.tar.gz -t 3 -T 20
+ fi
+ # rm -f /etc/yum.repos.d/*.repo
+ tar -xvzf el7repo.tar.gz -C /etc/yum.repos.d/
+ rm -f el7repo.tar.gz
+ fi
+
+}
+
+Set_Centos8_Repo(){
+ HUAWEI_CHECK=$(cat /etc/motd |grep "Huawei Cloud")
+ if [ "${HUAWEI_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ rm -f /etc/yum.repos.d/epel.repo
+ rm -f /etc/yum.repos.d/epel-*
+ fi
+ ALIYUN_CHECK=$(cat /etc/motd|grep "Alibaba Cloud ")
+ if [ "${ALIYUN_CHECK}" ] && [ "${is64bit}" == "64" ] && [ ! -f "/etc/yum.repos.d/Centos-vault-8.5.2111.repo" ];then
+ rename '.repo' '.repo.bak' /etc/yum.repos.d/*.repo
+ wget https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo -O /etc/yum.repos.d/Centos-vault-8.5.2111.repo
+ wget https://mirrors.aliyun.com/repo/epel-archive-8.repo -O /etc/yum.repos.d/epel-archive-8.repo
+ sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/Centos-vault-8.5.2111.repo
+ sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/epel-archive-8.repo
+ fi
+ MIRROR_CHECK=$(cat /etc/yum.repos.d/CentOS-Linux-AppStream.repo |grep "[^#]mirror.centos.org")
+ if [ "${MIRROR_CHECK}" ] && [ "${is64bit}" == "64" ];then
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*.repo
+ sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.epel.cloud|g' /etc/yum.repos.d/CentOS-*.repo
+ fi
+
+ yum install tree -y
+ if [ "$?" != "0" ] ;then
+ if [ -z "${download_Url}" ];then
+ download_Url="https://node.aapanel.com"
+ fi
+ if [ -d "/etc/yumBak" ];then
+ mv /etc/yumBak /etc/yumBak_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+ \cp -rpa /etc/yum.repos.d/ /etc/yumBak
+ curl -Ss --connect-timeout 20 -m 60 -O ${download_Url}/src/el8repo.tar.gz
+ if [ -f "/usr/bin/wget" ] && [ ! -s "el8repo.tar.gz" ];then
+ wget --no-check-certificate -O el8repo.tar.gz ${download_Url}/src/el8repo.tar.gz -t 3 -T 20
+ fi
+ rm -f /etc/yum.repos.d/*.repo
+ tar -xvzf el8repo.tar.gz -C /etc/yum.repos.d/
+ rm -f el8repo.tar.gz
+ fi
+
+}
+
+if [ -f "/etc/redhat-release" ];then
+ Centos7Check=$(cat /etc/redhat-release | grep ' 7.' | grep -iE 'centos|Red Hat')
+ if [ "${Centos7Check}" ];then
+ Set_Centos7_Repo
+ fi
+
+ Centos8Check=$(cat /etc/redhat-release | grep ' 8.' | grep -iE 'centos|Red Hat')
+ CentOS_Stream_8=$(cat /etc/redhat-release | grep 'CentOS Stream release 8' | grep -iE 'centos|Red Hat')
+ if [ "${Centos8Check}" ] || [ "${CentOS_Stream_8}" ];then
+ Set_Centos8_Repo
+ fi
+fi
+
+setup_path="/www"
+python_bin=$setup_path/server/panel/pyenv/bin/python
+cpu_cpunt=$(cat /proc/cpuinfo | grep ^processor | wc -l)
+is64bit=$(getconf LONG_BIT)
+
+GetSysInfo() {
+ if [ -s "/etc/redhat-release" ]; then
+ SYS_VERSION=$(cat /etc/redhat-release)
+ elif [ -s "/etc/issue" ]; then
+ SYS_VERSION=$(cat /etc/issue)
+ fi
+ SYS_INFO=$(uname -a)
+ SYS_BIT=$(getconf LONG_BIT)
+ MEM_TOTAL=$(free -m | grep Mem | awk '{print $2}')
+ CPU_INFO=$(getconf _NPROCESSORS_ONLN)
+
+ echo -e ${SYS_VERSION}
+ echo -e Bit:${SYS_BIT} Mem:${MEM_TOTAL}M Core:${CPU_INFO}
+ echo -e ${SYS_INFO}
+ echo -e "Please screenshot the above error message and post to the forum forum.aapanel.com for help"
+}
+
+Red_Error(){
+ echo '============== Update Failed! ==============='
+ printf '\033[1;31;40m%b\033[0m\n' "$@";
+ GetSysInfo
+
+ if [[ "$Install_pyenv_fielded" == "yes" ]] && [ -d "$pyenv_path/pyenv_update-panel" ]; then
+ if [ -d "$pyenv_path/pyenv" ]; then
+ if [ -d "$pyenv_path/pyenv_update-fail" ]; then
+ rm -rf $pyenv_path/pyenv_update-fail
+ fi
+ mv $pyenv_path/pyenv $pyenv_path/pyenv_update-fail
+ fi
+ echo "Restoring pyenv directory"
+ mv $pyenv_path/pyenv_update-panel $pyenv_path/pyenv
+ fi
+
+ /etc/init.d/bt start
+ rm -f $Updating
+ echo '============== Update Failed! ==============='
+ exit 1;
+}
+
+Get_Pack_Manager() {
+ if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
+ PM="yum"
+ elif [ -f "/usr/bin/apt-get" ] && [ -f "/usr/bin/dpkg" ]; then
+ PM="apt-get"
+ fi
+}
+
+Install_RPM_Pack() {
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el8") ];then
+ yum config-manager --set-enabled powertools
+ yum config-manager --set-enabled PowerTools
+ fi
+
+ if [ -f "/etc/redhat-release" ] && [ $(cat /etc/os-release|grep PLATFORM_ID|grep -oE "el9") ];then
+ dnf config-manager --set-enabled crb -y
+ fi
+
+ 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 firewalld ipset libpq-devel"
+ 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
+ if [ -f "/usr/bin/dnf" ]; then
+ dnf install -y redhat-rpm-config
+ fi
+
+ ALI_OS=$(cat /etc/redhat-release | grep "Alibaba Cloud Linux release 3")
+ if [ -z "${ALI_OS}" ]; then
+ yum install epel-release -y
+ fi
+}
+
+Install_Deb_Pack() {
+
+ debPacks="wget curl libcurl4-openssl-dev gcc make zip unzip tar openssl libssl-dev gcc libxml2 libxml2-dev libxslt-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 ufw ipset sqlite3 uuid-dev libpq-dev liblzma-dev"
+
+ #DEBIAN_FRONTEND=noninteractive apt-get install -y $debPacks --allow-downgrades --allow-remove-essential --allow-change-held-packages
+ DEBIAN_FRONTEND=noninteractive apt-get install -y $debPacks --force-yes
+
+ for debPack in ${debPacks}; do
+ packCheck=$(dpkg -l ${debPack})
+ if [ "$?" -ne "0" ]; then
+ DEBIAN_FRONTEND=noninteractive apt-get install -y $debPack --force-yes
+ fi
+ done
+
+}
+
+Get_Versions() {
+ redhat_version_file="/etc/redhat-release"
+ deb_version_file="/etc/issue"
+
+ if [[ $(grep "Amazon Linux" /etc/os-release) ]]; then
+ os_type="Amazon-"
+ os_version=$(cat /etc/os-release | grep "Amazon Linux" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep OpenCloudOS /etc/os-release) ]]; then
+ os_type="OpenCloudOS-"
+ os_version=$(cat /etc/os-release | grep OpenCloudOS | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [[ $os_version == "7" ]]; then
+ os_type="el"
+ os_version="7"
+ fi
+ return
+ fi
+
+ if [[ $(grep "Linux Mint" $deb_version_file) ]]; then
+ os_version=$(cat $deb_version_file | grep "Linux Mint" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_version=$(cat $deb_version_file | grep "Linux Mint" | grep -Eo '[0-9]+')
+ fi
+ # Linux-Mint 使用 ubuntu pyenv
+ os_type='ubuntu'
+ if [[ "$os_version" =~ "21" ]]; then
+ os_version="22"
+ echo "$os_version"
+ fi
+ if [[ "$os_version" =~ "20" ]]; then
+ os_version="20"
+ echo "$os_version"
+ fi
+ return
+ fi
+
+ if [[ $(grep openEuler /etc/os-release) ]]; then
+ os_type="openEuler-"
+ os_version=$(cat /etc/os-release | grep openEuler | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep AlmaLinux /etc/os-release) ]]; then
+ os_type="Alma-"
+ os_version=$(cat /etc/os-release | grep AlmaLinux | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep Rocky /etc/os-release) ]]; then
+ os_type="Rocky-"
+ os_version=$(cat /etc/os-release | grep Rocky | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ return
+ fi
+
+ if [[ $(grep Anolis /etc/os-release) ]] && [[ $(grep VERSION /etc/os-release|grep 8.8) ]];then
+ if [ -f "/usr/bin/yum" ];then
+ os_type="anolis"
+ os_version="8"
+ return
+ fi
+ fi
+
+ if [ -s $redhat_version_file ]; then
+ os_type='el'
+ if [[ $(grep 'Alibaba Cloud Linux (Aliyun Linux) release 2' $redhat_version_file) ]]; then
+ os_version="7"
+ return
+ fi
+
+ is_aliyunos=$(cat $redhat_version_file | grep Aliyun)
+ if [ "$is_aliyunos" != "" ]; then
+ return
+ fi
+
+ if [[ $(grep "Red Hat" $redhat_version_file) ]]; then
+ os_type='el'
+ os_version=$(cat $redhat_version_file | grep "Red Hat" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]')
+ return
+ fi
+
+ if [[ $(grep "Alibaba Cloud Linux release 3 " /etc/redhat-release) ]]; then
+ os_type="ali-linux-"
+ os_version="3"
+ return
+ fi
+
+ if [[ $(grep "Alibaba Cloud" /etc/redhat-release) ]] && [[ $(grep al8 /etc/os-release) ]];then
+ os_type="ali-linux-"
+ os_version="al8"
+ return
+ fi
+
+ if [[ $(grep TencentOS /etc/redhat-release) ]]; then
+ os_type="TencentOS-"
+ os_version=$(cat /etc/redhat-release | grep TencentOS | grep -Eo '([0-9]+\.)+[0-9]+')
+ if [[ $os_version == "2.4" ]]; then
+ os_type="el"
+ os_version="7"
+ elif [[ $os_version == "3.1" ]]; then
+ os_version="3.1"
+ fi
+ return
+ fi
+
+ os_version=$(cat $redhat_version_file | grep CentOS | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]')
+ if [ "${os_version}" = "5" ]; then
+ os_version=""
+ fi
+ if [ -z "${os_version}" ]; then
+ os_version=$(cat /etc/redhat-release | grep Stream | grep -oE "8|9")
+ fi
+ else
+ os_type='ubuntu'
+ os_version=$(cat $deb_version_file | grep Ubuntu | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_type='debian'
+ os_version=$(cat $deb_version_file | grep Debian | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '[0-9]+')
+ if [ "${os_version}" = "" ]; then
+ os_version=$(cat $deb_version_file | grep Debian | grep -Eo '[0-9]+')
+ fi
+ if [ "${os_version}" = "8" ]; then
+ os_version=""
+ fi
+ if [ "${is64bit}" = '32' ]; then
+ os_version=""
+ fi
+ else
+ if [ "$os_version" = "14" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "12" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "19" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "21" ]; then
+ os_version=""
+ fi
+ if [ "$os_version" = "20" ]; then
+ os_version2004=$(cat /etc/issue | grep 20.04)
+ if [ -z "${os_version2004}" ]; then
+ os_version=""
+ fi
+ fi
+ fi
+ fi
+}
+
+Install_Openssl111(){
+ Get_Versions
+ if [ -f "/www/server/panel/openssl_make.pl" ]; then
+ openssl_make="yes"
+ rm -f /www/server/panel/openssl_make.pl
+ fi
+
+ CPU_arch=$(uname -m)
+ if [[ "${CPU_arch}" == "aarch64" ]];then
+ CPU_arch="-aarch64"
+ elif [[ "${CPU_arch}" == "x86_64" ]];then
+ # x86_64 默认为空
+ CPU_arch=""
+ else
+ openssl_make="yes"
+ fi
+
+ if [[ $os_type = "el" ]] && [[ $os_version == "7" ]] && [[ $openssl_make != "yes" ]]; then
+ wget --no-check-certificate -O openssl111.tar.gz ${download_Url}/install/src/openssl111${CPU_arch}.tar.gz -t 5 -T 20
+ tmp_size=$(du -b openssl111.tar.gz | awk '{print $1}')
+ if [ $tmp_size -lt 5014046 ]; then
+ rm -f openssl111.tar.gz
+ Red_Error "ERROR: Download openssl111.tar.gz fielded."
+ fi
+ tar zxvf openssl111.tar.gz -C /usr/local/
+ rm -f openssl111.tar.gz
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ];then
+ Red_Error "/usr/local/openssl111/bin/openssl file does not exist!"
+ fi
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ else
+ if [ -f "/usr/bin/yum" ] && [ -d "/etc/yum.repos.d" ]; then
+ yum install -y perl lksctp-tools-devel
+ else
+ apt install -y perl
+ fi
+ opensslVersion="1.1.1o"
+ wget --no-check-certificate -O openssl-${opensslVersion}.tar.gz ${download_Url}/src/openssl-${opensslVersion}.tar.gz -t 5 -T 20
+ tmp_size=$(du -b openssl-${opensslVersion}.tar.gz | awk '{print $1}')
+ if [ $tmp_size -lt 9056386 ]; then
+ rm -f openssl-${opensslVersion}.tar.gz
+ Red_Error "ERROR: Download openssl-${opensslVersion}.tar.gz fielded."
+ fi
+ tar -zxvf openssl-${opensslVersion}.tar.gz
+ if [ ! -d "openssl-${opensslVersion}" ];then
+ Red_Error "Decompression failed openssl-${opensslVersion} Directory does not exist!"
+ fi
+ cd openssl-${opensslVersion}
+ ./config --prefix=/usr/local/openssl111 --openssldir=/usr/local/openssl111 enable-md2 enable-rc5 sctp zlib-dynamic shared -fPIC
+ make -j$cpu_cpunt
+ make install
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ];then
+ Red_Error "Compilation failed /usr/local/openssl111/bin/openssl file does not exist!"
+ fi
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ cd ..
+ rm -rf openssl-${opensslVersion} openssl-${opensslVersion}.tar.gz
+ fi
+ openssl111Check=$(/usr/local/openssl111/bin/openssl version|grep 1.1.1)
+ if [ -z "${openssl111Check}" ];then
+ Red_Error "openssl-1.1.1 install failed!"
+ fi
+}
+
+Check_Openssl_Version(){
+ if [ -f "/etc/redhat-release" ]; then
+ check_os_version=$(cat /etc/redhat-release | grep -E "Red Hat|CentOS" | grep -Eo '([0-9]+\.)+[0-9]+' | grep -Eo '^[0-9]')
+ # echo "$check_os_version"
+ fi
+ OPENSSL_VER=$(openssl version|grep -oE '1.0|1.1.0')
+ if [ "$check_os_version" == "7" ] || [ "${OPENSSL_VER}" ]; then
+ if [ ! -f "/usr/local/openssl111/bin/openssl" ]; then
+ Install_Openssl111
+ else
+ export LD_LIBRARY_PATH=/usr/local/openssl111/lib:$LD_LIBRARY_PATH
+ openssl111Check=$(/usr/local/openssl111/bin/openssl version|grep 1.1.1)
+ if [ -z "${openssl111Check}" ];then
+ Install_Openssl111
+ fi
+ if [ ! -f "/etc/ld.so.conf.d/openssl111.conf" ] || [ ! -f "/etc/ld.so.conf.d/zopenssl111.conf" ]; then
+ echo "/usr/local/openssl111/lib" > /etc/ld.so.conf.d/zopenssl111.conf
+ ldconfig
+ fi
+ ldconfig
+ fi
+ Use_Openssl111="yes"
+ fi
+}
+
+Update_Py_Lib(){
+# Need to use Werkzeug 2.2.3
+ mypip="/www/server/panel/pyenv/bin/pip3"
+ Werkzeug_path="/www/server/panel/script/Werkzeug-2.2.3-py3-none-any.whl"
+ # pycountry_path="/www/server/panel/script/pycountry-24.6.1-py3-none-any.whl"
+ pyOpenSSL_path="/www/server/panel/script/pyOpenSSL-23.1.1-py3-none-any.whl"
+
+ #change_pip_package_list=$( $mypip list | grep -E "Werkzeug|lxml|pycountry" )
+ change_pip_package_list=$( $mypip list | grep -E "Werkzeug|lxml" )
+
+ Werkzeug_v=$(echo "$change_pip_package_list" | grep Werkzeug | grep 2.2.3)
+ if [ "$Werkzeug_v" = "" ];then
+ echo "Update Werkzeug"
+ $mypip uninstall Werkzeug -y
+ $mypip install $Werkzeug_path
+
+ Werkzeug_v_2=$($mypip list |grep Werkzeug | grep 2.2.3)
+ if [ "$Werkzeug_v_2" = "" ];then
+ $mypip install Werkzeug==2.2.3
+ fi
+ fi
+
+ # pycountry_v=$(echo "$change_pip_package_list" | grep pycountry)
+ # if [ "$pycountry_v" = "" ];then
+ # echo "Update pycountry"
+ # $mypip install $pycountry_path
+ # rm -f $pycountry_path
+
+ # pycountry_v_2=$($mypip list |grep pycountry)
+ # if [ "$pycountry_v_2" = "" ];then
+ # $mypip install pycountry
+ # fi
+ # fi
+
+ # pyOpenSSL_v=$(echo "$change_pip_package_list" | grep pyOpenSSL | grep 23.1.1)
+ # if [ "$pyOpenSSL_v" = "" ];then
+ # echo "Update pyOpenSSL"
+ # $mypip uninstall pyOpenSSL cryptography -y
+ # $mypip install $pyOpenSSL_path cryptography==40.0.2
+
+ # pyOpenSSL_v_2=$($mypip list |grep pyOpenSSL | grep 23.1.1)
+ # if [ "$pyOpenSSL_v_2" = "" ];then
+ # $mypip install pyOpenSSL==23.1.1 cryptography==40.0.2
+ # fi
+ # fi
+
+ lxml_v=$(echo "$change_pip_package_list" | grep lxml | grep 5.2.1)
+ if [ "$lxml_v" != "" ];then
+ echo "Update lxml"
+ $mypip uninstall lxml -y
+ # bt 16 升级脚本时安装,安装时间久 这里不开,下面进行处理了
+ # echo "Please wait a moment to install lxml, it will take a long time."
+ # $mypip install lxml==5.0.0
+
+ # lxml_v_2=$($mypip list |grep lxml | grep 5.2.1)
+ # if [ "$lxml_v_2" = "" ];then
+ # $mypip install lxml==5.0.0
+ # fi
+ fi
+
+}
+
+Install_Python_Lib() {
+
+ # openssl version is lower than 1.1.1 and needs to be installed, such as CentOS 7
+ Check_Openssl_Version
+
+ 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
+ is_ssl=$($python_bin -c "import ssl" 2>&1 | grep cannot)
+ $pyenv_path/pyenv/bin/python3.12 -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 --no-check-certificate -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/3.12/pip_en_3.12.txt -t 5 -T 20
+ $pyenv_path/pyenv/bin/pip install -U pip
+ $pyenv_path/pyenv/bin/pip install -U setuptools
+ $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
+
+ py_version="3.12.3"
+ python_version="-3.12"
+ mkdir -p $pyenv_path
+ echo "True" >/www/disk.pl
+ if [ ! -w /www/disk.pl ]; then
+ Red_Error "ERROR: Install python env fielded." "ERROR: path [www] cannot be written, please check the directory/user/disk permissions!"
+ fi
+ os_type='el'
+ os_version='7'
+ # is_export_openssl=0
+ Get_Versions
+ echo "OS: $os_type - $os_version"
+ is_aarch64=$(uname -m | grep aarch64)
+ if [ "$is_aarch64" != "" ]; then
+ is64bit="aarch64"
+ fi
+ if [ -f "/www/server/panel/pymake.pl" ]; then
+ os_version=""
+ rm -f /www/server/panel/pymake.pl
+ fi
+ if [ "${os_version}" != "" ]; then
+ pyenv_file="/www/pyenv.tar.gz"
+ wget --no-check-certificate -O $pyenv_file $download_Url/install/pyenv/3.12/pyenv-${os_type}${os_version}-x${is64bit}${python_version}.tar.gz -t 5 -T 20
+ if [ "$?" != "0" ];then
+ wget --no-check-certificate -O $pyenv_file $download_Url/install/pyenv/3.12/pyenv-${os_type}${os_version}-x${is64bit}${python_version}.tar.gz -t 5 -T 20
+ fi
+ tmp_size=$(du -b $pyenv_file | awk '{print $1}')
+ if [ $tmp_size -lt 122271175 ]; then
+ rm -f $pyenv_file
+ echo "ERROR: Download python env fielded."
+ else
+ echo "Install python env..."
+ tar zxvf $pyenv_file -C $pyenv_path/ >/dev/null
+ chmod -R 700 $pyenv_path/pyenv/bin
+ if [ ! -f $pyenv_path/pyenv/bin/python ]; then
+ Install_pyenv_fielded="yes"
+ rm -f $pyenv_file
+ Red_Error "ERROR: Install python env fielded. Please try again."
+ fi
+ $pyenv_path/pyenv/bin/python3.12 -V
+ if [ $? -eq 0 ]; then
+ rm -f $pyenv_file
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 /usr/bin/btpip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 /usr/bin/btpython
+ source $pyenv_path/pyenv/bin/activate
+ return
+ else
+ rm -f $pyenv_file
+ rm -rf $pyenv_path/pyenv
+ fi
+ fi
+ fi
+
+ Get_Pack_Manager
+ if [ "${PM}" = "yum" ]; then
+ Install_RPM_Pack
+ elif [ "${PM}" = "apt-get" ]; then
+ Install_Deb_Pack
+ fi
+
+ cd /www
+ python_src='/www/python_src.tar.xz'
+ python_src_path="/www/Python-${py_version}"
+ wget --no-check-certificate -O $python_src $download_Url/src/Python-${py_version}.tar.xz -t 5 -T 20
+ tmp_size=$(du -b $python_src | awk '{print $1}')
+ if [ $tmp_size -lt 10703460 ]; then
+ Install_pyenv_fielded="yes"
+ rm -f $python_src
+ Red_Error "ERROR: Download python source code fielded. Please try again."
+ fi
+ tar xvf $python_src
+ rm -f $python_src
+ cd $python_src_path
+ if [[ $Use_Openssl111 = "yes" ]]; then
+ # centos7 或者低openssl于1.1.1使用
+ export OPENSSL_DIR=/usr/local/openssl111
+ ./configure --prefix=$pyenv_path/pyenv \
+ LDFLAGS="-L$OPENSSL_DIR/lib" \
+ CPPFLAGS="-I$OPENSSL_DIR/include" \
+ --with-openssl=$OPENSSL_DIR
+ else
+ ./configure --prefix=$pyenv_path/pyenv
+ fi
+
+ make -j$cpu_cpunt
+ make install
+ if [ ! -f $pyenv_path/pyenv/bin/python3.12 ]; then
+ rm -rf $python_src_path
+ Install_pyenv_fielded="yes"
+ Red_Error "ERROR: Make python env fielded. Please try again."
+ fi
+ cd ~
+ rm -rf $python_src_path
+ wget --no-check-certificate -O $pyenv_path/pyenv/bin/activate $download_Url/install/pyenv/activate.panel -t 5 -T 20
+ wget --no-check-certificate -O $pyenv_path/pyenv/pip.txt $download_Url/install/pyenv/3.12/pip-3.12.3.txt -t 5 -T 20
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 $pyenv_path/pyenv/bin/pip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 $pyenv_path/pyenv/bin/python
+ ln -sf $pyenv_path/pyenv/bin/pip3.12 /usr/bin/btpip
+ ln -sf $pyenv_path/pyenv/bin/python3.12 /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 wheel==0.34.2
+ $pyenv_path/pyenv/bin/pip install -r $pyenv_path/pyenv/pip.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
+ Install_pyenv_fielded="yes"
+ Red_Error "ERROR: psutil/gevent install failed! Please try again."
+ fi
+}
+
+delete_useless_package() {
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-kms -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-core -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall aliyun-python-sdk-core-v3 -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall qiniu -y >/dev/null 2>&1
+ /www/server/panel/pyenv/bin/pip uninstall cos-python-sdk-v5 -y >/dev/null 2>&1
+}
+
+Upgrade_python312() {
+ # 获取/www目录所在分区的可用空间(以KB为单位)
+ available_kb=$(df -k /www | awk 'NR==2 {print $4}')
+
+ # 1GB = 1024MB = 1024*1024KB
+ available_gb=$((available_kb / 1024 / 1024))
+ echo "/www partition currently available space: "$available_gb" G"
+
+ # 判断可用空间是否小于1GB
+ if [ "$available_gb" -lt 1 ]; then
+ echo -e "\033[31m The available space is less than 1G.\033[0m"
+ echo -e "\033[31m It is recommended to clean or upgrade the server space before upgrading.\033[0m"
+ rm -f $Updating
+ exit 1;
+ fi
+ # /etc/init.d/bt stop
+
+ if [ -f /etc/init.d/bt_syssafe ]; then
+ echo "Turning off System hardening"
+ System_hardening="yes"
+ /etc/init.d/bt_syssafe stop
+ if [ -d "/etc/rc.d/" ]; then
+ chattr -iaR /etc/rc.d/
+ fi
+ chattr -iaR /etc/init.d
+ fi
+
+ if [ -d "/www/server/panel/pyenv" ]; then
+ echo "Backup old pyenv"
+
+ if [ -d "/www/server/panel/pyenv_update-panel" ];then
+ mv /www/server/panel/pyenv_update-panel /www/server/panel/pyenv_update-panel_$(date +%Y_%m_%d_%H_%M_%S)
+ fi
+
+ mv /www/server/panel/pyenv /www/server/panel/pyenv_update-panel
+ fi
+ Install_Python_Lib
+ delete_useless_package
+
+}
+
+Check_python_version() {
+ is_loongarch64=$(uname -a | grep loongarch64)
+ if [ "$is_loongarch64" != "" ]; then
+ echo "loongarch64 does not currently support upgrades"
+ rm -f $Updating
+ exit
+ fi
+ if [ -f "/www/server/panel/pyenv/bin/python" ]; then
+
+ get_python_version=$(/www/server/panel/pyenv/bin/python -V)
+ if [[ ${get_python_version} =~ "Python 3.7." ]]; then
+ echo ${get_python_version}
+ Upgrade_python312
+ else
+ if [[ ${get_python_version} =~ "Python 3.12." ]]; then
+ echo -e "Python3.12 No upgrade required"
+ else
+ Upgrade_python312
+ fi
+ fi
+ else
+ echo -e "/www/server/panel/pyenv/bin/python Does not exist, cannot determine python version"
+ Upgrade_python312
+ fi
+}
+
+Check_python_version
+
+Check_Openssl_Version
+
+# mypip="pip"
+# env_path=/www/server/panel/pyenv/bin/activate
+# if [ -f $env_path ];then
+# mypip="/www/server/panel/pyenv/bin/pip"
+# fi
+mypip="/www/server/panel/pyenv/bin/pip"
+
+pip_list=$($mypip list)
+setuptools_v=$(echo "$pip_list"|grep setuptools)
+if [ "$setuptools_v" = "" ];then
+ $mypip install setuptools
+fi
+
+requests_v=$(echo "$pip_list"|grep requests)
+if [ "$requests_v" = "" ];then
+ $mypip install requests
+fi
+
+openssl_v=$(echo "$pip_list"|grep pyOpenSSL)
+if [ "$openssl_v" = "" ];then
+ $mypip install -I pyOpenSSL
+fi
+
+pymysql=$(echo "$pip_list"|grep PyMySQL)
+if [ "$pymysql" = "" ];then
+ $mypip install PyMySQL
+fi
+
+GEVENT_V=$(echo "$pip_list"|grep "gevent "|awk '{print $2}'|cut -f 1 -d '.')
+if [ "${GEVENT_V}" -le "1" ];then
+ $mypip install -I gevent
+fi
+
+pycryptodome=$(echo "$pip_list"|grep pycryptodome)
+if [ "$pycryptodome" = "" ];then
+ $mypip install pycryptodome
+fi
+
+lxml=$(echo "$pip_list"|grep lxml | grep 5.2.1)
+if [ "$lxml" != "" ];then
+ $mypip uninstall lxml -y
+ echo "Please wait a moment to install lxml, it will take a long time."
+ $mypip install lxml==5.0.0
+fi
+lxml_2=$($mypip list|grep lxml)
+if [ "$lxml_2" = "" ];then
+ $mypip install lxml==5.0.0
+fi
+
+# $mypip install pyOpenSSL -I
+# $mypip install python-telegram-bot==20.3
+# $mypip install paramiko -I
+
+telegram_v=$(echo "$pip_list"|grep python-telegram-bot)
+if [ "$telegram_v" = "" ];then
+ $mypip install python-telegram-bot==20.3
+fi
+
+# pycountry_v=$(echo "$pip_list"|grep pycountry)
+# if [ "$pycountry_v" = "" ];then
+# $mypip install pycountry==24.6.1
+# fi
+
+if [ -f "/www/server/panel/plugin/linuxsys/linuxsys_main.py" ]; then
+ distro_v=$(echo "$pip_list"|grep distro)
+ if [ "$distro_v" = "" ];then
+ $mypip install distro
+ fi
+fi
+
+if [ -f "/www/server/panel/plugin/aws_s3/aws_s3_main.py" ]; then
+ boto3_v=$(echo "$pip_list"|grep boto3)
+ if [ "$boto3_v" = "" ];then
+ $mypip install boto3
+ fi
+fi
+
+if [ -f "/www/server/panel/plugin/frp/frp_main.py" ]; then
+ toml_v=$(echo "$pip_list"|grep toml)
+ if [ "$toml_v" = "" ];then
+ $mypip install toml
+ fi
+fi
+
+if [ -f "/www/server/panel/plugin/supervisor/supervisor_main.py" ]; then
+ pyasynchat_v=$(echo "$pip_list"|grep pyasynchat)
+ if [ "$pyasynchat_v" = "" ];then
+ $mypip install pyasynchat
+ fi
+ Supervisor_plugin=/www/server/panel/plugin/supervisor
+ Supervisor_py=/www/server/panel/pyenv/lib/python3.12/site-packages/supervisor
+
+ if [ -d "$Supervisor_py" ]; then
+ \cp -rpaf $Supervisor_py/options.py $Supervisor_plugin/options.py.bak
+ \cp -rpaf $Supervisor_plugin/options.py $Supervisor_py/options.py
+
+ \cp -rpaf $Supervisor_py/rpcinterface.py $Supervisor_plugin/rpcinterface.py.bak
+ \cp -rpaf $Supervisor_plugin/rpcinterface.py $Supervisor_py/rpcinterface.py
+ echo bt > $Supervisor_py/bt.pl
+ fi
+fi
+
+if [ -f "$setup_path/server/panel/pyenv/bin/python3.12" ] && [ ! -f "$setup_path/server/panel/data/upgrade_plugins_3.12.pl" ];then
+ chmod +x $setup_path/server/panel/tools.py
+ $setup_path/server/panel/pyenv/bin/python3 $setup_path/server/panel/tools.py upgrade_plugins
+fi
+
+
+if [[ "$System_hardening" == "yes" ]]; then
+ echo "Turning on System hardening"
+ /etc/init.d/bt_syssafe start
+fi
+
+only_update_pyenv312="/tmp/only_update_pyenv312.pl"
+if [ -f "$only_update_pyenv312" ]; then
+ Update_Py_Lib
+ rm -f $Updating $only_update_pyenv312
+ /etc/init.d/bt restart
+ echo "$only_update_pyenv312 file exists, Only update Python3.12 environment complete!"
+ exit 0;
+fi
+
+version=$(curl -Ss --connect-timeout 12 -m 2 $Btapi_Url/api/panel/getLatestOfficialVersion)
+
+check_version_num=$( echo "$version"|grep -Eo '^[0-9]+' )
+if [ "$check_version_num" = '' ];then
+ echo "Check version failed!"
+ version='7.0.13'
+fi
+
+if [ "$version" = '' ];then
+ version='7.0.13'
+fi
+
+# if [ "$1" ];then
+# version="$1"
+# fi
+
+
+wget --no-check-certificate -t 5 -T 20 -O /tmp/panel.zip $Btapi_Url/install/update/LinuxPanel_EN-${version}.zip
+
+dsize=$(du -b /tmp/panel.zip|awk '{print $1}')
+if [ $dsize -lt 10240 ];then
+ echo "Failed to get update package, please update or contact aaPanel Operation"
+ rm -f $Updating
+ exit;
+fi
+unzip -o /tmp/panel.zip -d $setup_path/server/ > /dev/null
+rm -f /tmp/panel.zip
+
+Update_Py_Lib
+
+cd $setup_path/server/panel/
+check_bt=`cat /etc/init.d/bt`
+if [ "${check_bt}" = "" ];then
+ chattr -i /etc/init.d/bt
+ rm -f /etc/init.d/bt
+ wget --no-check-certificate -O /etc/init.d/bt $download_Url/install/src/bt7_en.init -t 5 -T 20
+ chmod +x /etc/init.d/bt
+fi
+rm -f /www/server/panel/*.pyc
+rm -f /www/server/panel/class/*.pyc
+rm -f /www/server/panel/class/__pycache__/*.pyc
+rm -f /www/server/panel/class_v2/__pycache__/*.pyc
+
+rm -f /www/server/panel/class/*.so
+if [ ! -f /www/server/panel/data/userInfo.json ]; then
+ echo "{\"id\":1,\"uid\":1,\"last_login_ip\":\"127.0.0.1\",\"username\":\"Administrator\",\"email\":\"admin@aapanel.com\",\"status\":1,\"token\":\"aaa.bbb.ccc\"}" > /www/server/panel/data/userInfo.json
+fi
+
+grep "www:x" /etc/passwd > /dev/null
+if [ "$?" != 0 ];then
+ Run_User="www"
+ groupadd ${Run_User}
+ useradd -s /sbin/nologin -g ${Run_User} ${Run_User}
+fi
+chattr -i /etc/init.d/bt
+chmod +x /etc/init.d/bt
+echo "====================================="
+rm -f /dev/shm/bt_sql_tips.pl
+process=$(ps aux|grep -E "task.pyc|main.py"|grep -v grep|awk '{print $2}')
+if [ "$process" != "" ];then
+ kill $process
+fi
+/etc/init.d/bt restart
+# /etc/init.d/bt start
+# echo 'True' > /www/server/panel/data/restart.pl
+rm -f $Updating
+echo "Successfully upgraded to[$version]${Ver}";
+if [ -f "/www/server/panel/beta_git_1_line.log" ];then
+ rm -f /www/server/panel/beta_git_1_line.log
+fi
+if [ -f "/www/server/panel/pro_git_1_line.log" ];then
+ rm -f /www/server/panel/pro_git_1_line.log
+fi
\ No newline at end of file
diff --git a/public/static/file/en/kaixin.zip b/public/static/file/en/kaixin.zip
new file mode 100644
index 0000000..103ea3d
Binary files /dev/null and b/public/static/file/en/kaixin.zip differ
diff --git a/public/static/file/kaixin.zip b/public/static/file/kaixin.zip
index eb8664f..64d63cc 100644
Binary files a/public/static/file/kaixin.zip and b/public/static/file/kaixin.zip differ
diff --git a/public/static/images/aapanel.png b/public/static/images/aapanel.png
new file mode 100644
index 0000000..8c67bb2
Binary files /dev/null and b/public/static/images/aapanel.png differ
diff --git a/route/app.php b/route/app.php
index 189acbf..80d65d5 100644
--- a/route/app.php
+++ b/route/app.php
@@ -127,6 +127,22 @@ Route::group('api', function () {
Route::post('/Cert_cloud_deploy/get_cert_list', 'api/return_success');
Route::post('/Cert_cloud_deploy/del_cert', 'api/return_success');
+ Route::any('/panel/getSoftList', 'api/get_plugin_list_en');
+ Route::any('/panel/getSoftListEn', 'api/get_plugin_list_en');
+ Route::post('/panel/download_plugin', 'api/download_plugin_en');
+ Route::get('/plugin/download', 'api/download_plugin_other');
+ Route::get('/common/getClientIP', 'api/get_ip_address');
+ Route::post('/panel/checkDomain', 'api/check_domain');
+ Route::get('/panel/getBetaVersionLogs', 'api/get_beta_logs');
+ Route::any('/panel/updateLinuxEn', 'api/check_update_en');
+ Route::post('/user/verifyToken', 'api/return_success');
+ Route::post('/panel/nps/check', 'api/nps_check');
+ Route::post('/panel/nps/questions', 'api/nps_questions');
+ Route::post('/panel/nps/submit', 'api/nps_submit');
+ Route::post('/panel/submit_feature_invoked_bulk', 'api/return_success');
+ Route::post('/panel/submit_expand_pack_used', 'api/return_success');
+ Route::get('/panel/getLatestOfficialVersion', 'api/get_version_en');
+
Route::miss('api/return_error');
});
@@ -141,6 +157,7 @@ Route::group('admin', function () {
Route::post('/testbturl', 'admin/testbturl');
Route::get('/plugins', 'admin/plugins');
Route::get('/pluginswin', 'admin/pluginswin');
+ Route::get('/pluginsen', 'admin/pluginsen');
Route::post('/plugins_data', 'admin/plugins_data');
Route::post('/download_plugin', 'admin/download_plugin');
Route::get('/refresh_plugins', 'admin/refresh_plugins');
diff --git a/wiki/aapanel.md b/wiki/aapanel.md
new file mode 100644
index 0000000..4bb9d7d
--- /dev/null
+++ b/wiki/aapanel.md
@@ -0,0 +1,122 @@
+# aapanel面板官方更新包修改记录
+
+查询最新版本号:https://brandnew.aapanel.com/api/panel/getLatestOfficialVersion
+
+官方更新包下载链接:http://download.bt.cn/install/update/LinuxPanel_EN-版本号.zip
+
+假设搭建的宝塔第三方云端网址是 http://www.example.com
+
+- 将class文件夹里面所有的.so文件删除
+
+- 将aapanel/PluginLoader.py复制到class文件夹
+
+- 批量解密模块文件:执行 php think decrypt classdir <面板class文件夹路径>
+
+ php think decrypt classdir <面板class_v2文件夹路径>
+
+- 全局搜索替换 https://wafapi2.aapanel.com => http://www.example.com(需排除task.py、ipsModel.py、js文件)
+
+- 全局搜索替换 https://node.aapanel.com/install/update_7.x_en.sh => http://www.example.com/install/update_7.x_en.sh
+
+ https://node.aapanel.com/install/update_pro_en.sh => http://www.example.com/install/update_7.x_en.sh
+
+- 搜索并删除提交异常报告的代码 bt_error/index.php
+
+- class/ajax.py 文件 \#是否执行升级程序 下面的 public.get_url() 改成 public.OfficialApiBase()
+
+ class/ajax.py 文件 __official_url = 'https://www.aapanel.com' 改成 http://www.example.com
+
+ class/jobs.py 文件 \#尝试升级到独立环境 下面的 public.get_url() 改成 public.OfficialApiBase()
+
+ class/system.py 文件 RepPanel和UpdatePro方法内的 public.get_url() 改成 public.OfficialApiBase()
+
+- class/public/common.py
+
+ def OfficialApiBase(): 改成 return 'http://www.example.com'
+
+ def load_soft_list 去除 if force 部分
+
+ plugin_list_data = PluginLoader.get_plugin_list(0) 部分改成 plugin_list_data = PluginLoader.get_plugin_list(force)
+
+ 在 def check_domain_cloud(domain): 这一行下面加上 return
+
+ 在 def count_wp(): 这一行下面加上 return
+
+ 在 def err_collect 这一行下面加上 return
+
+ 在 def get_improvement(): 这一行下面加上 return False
+
+ 在free_login_area方法内get_free_ips_area替换成get_ips_area
+
+ 在login_send_body方法内,free_login_area(login_ip=server_ip_area的server_ip_area改成login_ip
+
+ 在 def write_request_log(reques=None): 这一行下面加上 return
+
+- class/panelPlugin.py 文件,set_pyenv方法内,temp_file = public.readFile(filename)这行代码下面加上
+
+ ```python
+ temp_file = temp_file.replace('http://download.bt.cn/install/public.sh', 'http://www.example.com/install/public.sh')
+ temp_file = temp_file.replace('https://download.bt.cn/install/public.sh', 'http://www.example.com/install/public.sh')
+ ```
+
+ def check_status(self, softInfo): 方法最后一行加上
+
+ ```python
+ if 'endtime' in softInfo:
+ softInfo['endtime'] = time.time() + 86400 * 3650
+ ```
+
+- class_v2/btdockerModelV2/flush_plugin.py 文件,删除clear_hosts()一行
+
+- install/install_soft.sh 在. 执行之前加入以下代码
+
+ ```shell
+ sed -i "s/http:\/\/download.bt.cn\/install\/public.sh/http:\/\/www.example.com\/install\/public.sh/" $name.sh
+ sed -i "s/https:\/\/download.bt.cn\/install\/public.sh/http:\/\/www.example.com\/install\/public.sh/" $name.sh
+ ```
+
+- install/public.sh 用官网最新版的[public.sh](http://download.bt.cn/install/public.sh)替换,并去除最下面bt_check一行
+
+- 去除无用的定时任务:task.py 文件 删除以下几行
+
+ "update_software_list": update_software_list,
+
+ "check_panel_msg": check_panel_msg,
+
+ "check_panel_auth": check_panel_auth,
+
+ "count_ssh_logs": count_ssh_logs,
+
+ "submit_email_statistics": submit_email_statistics,
+
+ "submit_module_call_statistics": submit_module_call_statistics,
+
+ "mailsys_domain_restrictions": mailsys_domain_restrictions,
+
+- [可选]去除各种计算题:将bt.js里面的内容复制到 BTPanel/static/vite/oldjs/public_backup.js 末尾
+
+- [可选]去除创建网站自动创建的垃圾文件:在class/panelSite.py,分别删除
+
+ htaccess = self.sitePath + '/.htaccess'
+
+ index = self.sitePath + '/index.html'
+
+ doc404 = self.sitePath + '/404.html'
+
+ 这3行及分别接下来的4行代码
+
+- [可选]关闭未绑定域名提示页面:在class/panelSite.py,root /www/server/nginx/html改成return 400
+
+- [可选]上传文件默认选中覆盖,在BTPanel/static/vite/oldjs/upload-drog.js,id="all_operation"加checked属性
+
+- [可选] BTPanel/static/vite/oldjs/site.js,优化SSL证书配置页面
+
+- [可选]新版vite页面去除需求反馈、各种广告、计算题等,执行 php think cleanvitejs <面板BTPanel/static/js路径>
+
+- 新增简体中文语言:修改BTPanel/languages/settings.json,并增加 zh/server.json、all/zh.json
+
+
+解压安装包[panel_7_en.zip](http://download.bt.cn/install/src/panel_7_en.zip),将更新包改好的文件覆盖到里面,然后重新打包,即可更新安装包。(
+
+别忘了删除class文件夹里面所有的.so文件)
+
diff --git a/wiki/files/aapanel/PluginLoader.py b/wiki/files/aapanel/PluginLoader.py
new file mode 100644
index 0000000..ef10afd
--- /dev/null
+++ b/wiki/files/aapanel/PluginLoader.py
@@ -0,0 +1,408 @@
+#coding: utf-8
+# +-------------------------------------------------------------------
+# | 宝塔Linux面板
+# +-------------------------------------------------------------------
+# | Copyright (c) 2015-2099 宝塔软件(http://bt.cn) All rights reserved.
+# +-------------------------------------------------------------------
+# | Author: hwliang
+# +-------------------------------------------------------------------
+
+#+--------------------------------------------------------------------
+#| 插件和模块加载器
+#+--------------------------------------------------------------------
+
+import public,os,sys,json,hashlib
+
+def plugin_run(plugin_name,def_name,args):
+ '''
+ @name 执行插件方法
+ @param plugin_name 插件名称
+ @param def_name 方法名称
+ @param args 参数对像
+ @return mixed
+ '''
+ if not plugin_name or not def_name: return public.returnMsg(False,'parameter incorrect: module_name and def_name cannot be empty.')
+
+ # 获取插件目录
+ plugin_path = public.get_plugin_path(plugin_name)
+ is_php = os.path.exists(os.path.join(plugin_path,'index.php'))
+
+ # 检查插件目录是否合法
+ if is_php:
+ plugin_file = os.path.join(plugin_path,'index.php')
+ else:
+ plugin_file = os.path.join(plugin_path, plugin_name + '_main.py')
+ if not public.path_safe_check(plugin_file): return public.returnMsg(False,'parameter incorrect: module_name and def_name cannot contains special symbols.')
+
+ # 检查插件入口文件是否存在
+ if not os.path.exists(plugin_file): return public.returnMsg(False,'plugin not found')
+
+ # 添加插件目录到系统路径
+ public.sys_path_append(plugin_path)
+
+ if not is_php:
+ # 引用插件入口文件
+ _name = "{}_main".format(plugin_name)
+ plugin_main = __import__(_name)
+
+ # 检查类名是否符合规范
+ if not hasattr(plugin_main,_name):
+ return public.returnMsg(False,'plugin class name is invalid')
+
+ try:
+ if sys.version_info[0] == 2:
+ reload(plugin_main)
+ else:
+ from imp import reload
+ reload(plugin_main)
+ except:
+ pass
+
+ # 实例化插件类
+ plugin_obj = getattr(plugin_main,_name)()
+
+ # 检查方法是否存在
+ if not hasattr(plugin_obj,def_name):
+ return public.returnMsg(False,'not find method [%s] in plugin [%s]' % (def_name,plugin_name))
+
+ if args is not None and 'plugin_get_object' in args and args.plugin_get_object == 1:
+ return getattr(plugin_obj, def_name)
+
+ # 执行方法
+ return getattr(plugin_obj,def_name)(args)
+ else:
+ if args is not None and 'plugin_get_object' in args and args.plugin_get_object == 1:
+ return None
+ import panelPHP
+ args.s = def_name
+ args.name = plugin_name
+ return panelPHP.panelPHP(plugin_name).exec_php_script(args)
+
+
+def get_module_list():
+ '''
+ @name 获取模块列表
+ @return list
+ '''
+ module_list = []
+ class_path = public.get_class_path()
+ for name in os.listdir(class_path):
+ path = os.path.join(class_path,name)
+ # 过滤无效文件
+ if not name or name.endswith('.py') or name[0] == '.' or not name.endswith('Model') or os.path.isfile(path):continue
+ module_list.append(name)
+ return module_list
+
+def module_run(module_name,def_name,args):
+ '''
+ @name 执行模块方法
+ @param module_name 模块名称
+ @param def_name 方法名称
+ @param args 参数对像
+ @return mixed
+ '''
+ if not module_name or not def_name: return public.returnMsg(False,'parameter incorrect: module_name and def_name cannot be empty.')
+ model_index = args.get('model_index',None)
+ class_path = public.get_class_path()
+ panel_path = public.get_panel_path()
+
+ module_file = None
+ if 'model_index' in args:
+ # 新模块目录
+ if model_index in ['mod']:
+ module_file = os.path.join(panel_path,'mod','project',module_name + 'Mod.py')
+ elif model_index:
+ # 旧模块目录
+ module_file = os.path.join(class_path,model_index+"Model",module_name + 'Model.py')
+ else:
+ module_file = os.path.join(class_path,"projectModel",module_name + 'Model.py')
+ else:
+ # 如果没指定模块名称,则遍历所有模块目录
+ module_list = get_module_list()
+ for name in module_list:
+ module_file = os.path.join(class_path,name,module_name + 'Model.py')
+ if os.path.exists(module_file): break
+
+ # 判断模块入口文件是否存在
+ if not os.path.exists(module_file):
+ return public.returnMsg(False,'module file [%s] not exist' % module_name)
+
+ # 判断模块路径是否合法
+ if not public.path_safe_check(module_file):
+ return public.returnMsg(False,'parameter incorrect: module_name and def_name cannot contains special symbols.')
+
+ def_object = public.get_script_object(module_file)
+ if not def_object: return public.returnMsg(False,'module [%s] not found' % module_name)
+
+ # 模块实例化并返回方法对象
+ try:
+ run_object = getattr(def_object.main(),def_name,None)
+ except:
+ return public.returnMsg(False,'module [%s] failed to instance class' % module_name)
+ if not run_object: return public.returnMsg(False,'not found method [%s] in module [%s]' % (def_name,module_name))
+
+ if 'module_get_object' in args and args.module_get_object == 1:
+ return run_object
+
+ # 执行方法
+ result = run_object(args)
+ return result
+
+
+def get_plugin_list(upgrade_force = False):
+ '''
+ @name 获取插件列表
+ @param upgrade_force 是否强制重新获取列表
+ @return dict
+ '''
+
+ api_root_url = public.OfficialApiBase()
+ api_url = api_root_url+ '/api/panel/getSoftListEn'
+ panel_path = public.get_panel_path()
+ data_path = os.path.join(panel_path,'data')
+
+ if not os.path.exists(data_path):
+ os.makedirs(data_path,384)
+
+ plugin_list = {}
+ plugin_list_file = os.path.join(data_path,'plugin_list.json')
+ if os.path.exists(plugin_list_file) and not upgrade_force:
+ plugin_list_body = public.readFile(plugin_list_file)
+ try:
+ plugin_list = json.loads(plugin_list_body)
+ except:
+ plugin_list = {}
+
+ if not os.path.exists(plugin_list_file) or upgrade_force or not plugin_list:
+ try:
+ res = public.HttpGet(api_url)
+ except Exception as ex:
+ raise public.error_conn_cloud(str(ex))
+ if not res: raise Exception(False,'failed to get soft list')
+
+ plugin_list = json.loads(res)
+ if type(plugin_list)!=dict or 'list' not in plugin_list:
+ if type(plugin_list)==str:
+ raise Exception(plugin_list)
+ else:
+ raise Exception('failed to parse soft list')
+ content = json.dumps(plugin_list)
+ public.writeFile(plugin_list_file,content)
+
+ plugin_bin_file = os.path.join(data_path,'plugin_bin.pl')
+ encode_content = __encode_plugin_list(content)
+ if encode_content:
+ public.writeFile(plugin_bin_file,encode_content)
+
+ return plugin_list
+
+def __encode_plugin_list(content):
+ try:
+ userInfo = public.get_user_info()
+ if not userInfo or 'server_id' not in userInfo: return None
+ block_size = 51200
+ uid = str(userInfo['uid'])
+ server_id = userInfo['server_id']
+ key = server_id[10:26] + uid + server_id
+ key = hashlib.md5(key.encode()).hexdigest()
+ iv = key + server_id
+ iv = hashlib.md5(iv.encode()).hexdigest()
+ key = key[8:24]
+ iv = iv[8:24]
+ blocks = [content[i:i + block_size] for i in range(0, len(content), block_size)]
+ encrypted_content = ''
+ for block in blocks:
+ encrypted_content += __aes_encrypt(block, key, iv) + '\n'
+ return encrypted_content
+ except:
+ pass
+ return None
+
+def get_module(filename):
+ if not filename: return public.returnMsg(False,'parameter error: get_module(filename)')
+ if filename[0:2] == './': return public.returnMsg(False,'filename cannot be relative path.')
+ if not public.path_safe_check(filename): return public.returnMsg(False,'filename cannot contains special symbols.')
+ if not os.path.exists(filename): return public.returnMsg(False,'file does not exist')
+ return __get_class_module(filename)
+
+def __get_class_module(filename):
+ _obj = sys.modules.get(filename, None)
+ if _obj: return _obj
+ _code = public.readFile(filename)
+ if _code.find('import') == -1:
+ en_arr = _code.split('\n')
+ de_text = ''
+ for data in en_arr:
+ data = str.strip(data)
+ if not data: continue
+ de_text += __aes_decrypt_module(data)
+ _code = de_text
+ if not _code or _code.find('import') == -1:
+ return public.returnMsg(False,'load failed: decode error')
+ _code_object = compile(_code, filename, 'exec')
+ from types import ModuleType
+ _obj = sys.modules.setdefault(filename, ModuleType(filename))
+ _obj.__file__ = filename
+ _obj.__package__ = ''
+ exec(_code_object, _obj.__dict__)
+ return _obj
+
+def start_total():
+ '''
+ @name 启动统计服务
+ @return dict
+ '''
+ pass
+
+def get_soft_list(args):
+ '''
+ @name 获取软件列表
+ @param args 参数对像
+ @return dict
+ '''
+ pass
+
+def db_encrypt(data):
+ '''
+ @name 数据库加密
+ @param args 参数对像
+ @return dict
+ '''
+ 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):
+ '''
+ @name 数据库解密
+ @param args 参数对像
+ @return dict
+ '''
+ 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')
+
+def plugin_end():
+ '''
+ @name 插件到期处理
+ @return dict
+ '''
+ pass
+
+def daemon_task():
+ '''
+ @name 后台任务守护
+ @return dict
+ '''
+ pass
+
+def daemon_panel():
+ '''
+ @name 面板守护
+ @return dict
+ '''
+ pass
+
+def flush_auth_key():
+ '''
+ @name 刷新授权密钥
+ @return dict
+ '''
+ pass
+
+def get_auth_state():
+ '''
+ @name 获取授权状态
+ @return 返回:0.免费版 1.专业版 2.企业版 -1.获取失败
+ '''
+ try:
+ softList = get_plugin_list()
+ if softList['ltd'] > -1:
+ return 2
+ elif softList['pro'] > -1:
+ return 1
+ else:
+ return 0
+ except:
+ return -1
+
+
\ No newline at end of file
diff --git a/wiki/files/aapanel/bt.js b/wiki/files/aapanel/bt.js
new file mode 100644
index 0000000..824ca5a
--- /dev/null
+++ b/wiki/files/aapanel/bt.js
@@ -0,0 +1,83 @@
+/*
+ *宝塔面板去除各种计算题与延时等待
+*/
+if("undefined" != typeof bt && bt.hasOwnProperty("show_confirm")){
+ bt.show_confirm = function(title, msg, fun, error) {
+ layer.open({
+ type: 1,
+ title: title,
+ area: "350px",
+ closeBtn: 2,
+ shadeClose: true,
+ btn: [lan['public'].ok, lan['public'].cancel],
+ content: "",
+ yes: function (index, layero) {
+ layer.close(index);
+ if (fun) fun();
+ }
+ });
+ }
+}
+if("undefined" != typeof bt && bt.hasOwnProperty("prompt_confirm")){
+ bt.prompt_confirm = function (title, msg, callback) {
+ layer.open({
+ type: 1,
+ title: title,
+ area: "480px",
+ closeBtn: 2,
+ btn: ['OK', 'Cancel'],
+ content: "",
+ yes: function (layers, index) {
+ layer.close(layers)
+ if (callback) callback()
+ }
+ });
+ }
+}
+if("undefined" != typeof bt && bt.hasOwnProperty("compute_confirm")){
+ bt.compute_confirm = function (config, callback) {
+ layer.open({
+ type: 1,
+ title: config.title,
+ area: '430px',
+ closeBtn: 2,
+ shadeClose: true,
+ btn: [lan['public'].ok, lan['public'].cancel],
+ content:
+ '',
+ yes: function (layers, index) {
+ layer.close(layers)
+ if (callback) callback()
+ }
+ });
+ }
+}
+function SafeMessage(j, h, g, f) {
+ if (f == undefined) f = '';
+ var mess = layer.open({
+ type: 1,
+ title: j,
+ area: "350px",
+ closeBtn: 2,
+ shadeClose: true,
+ content: ""
+ });
+ $(".bt-cancel").click(function(){
+ layer.close(mess);
+ });
+ $("#toSubmit").click(function() {
+ layer.close(mess);
+ g();
+ })
+}
\ No newline at end of file