|
@@ -8,7 +8,6 @@ use App\Models\Devops\ServerConfig; |
|
@@ -8,7 +8,6 @@ use App\Models\Devops\ServerConfig; |
|
8
|
use App\Models\Devops\ServersIp;
|
8
|
use App\Models\Devops\ServersIp;
|
|
9
|
use App\Models\Domain\DomainInfo;
|
9
|
use App\Models\Domain\DomainInfo;
|
|
10
|
use App\Models\Project\Project;
|
10
|
use App\Models\Project\Project;
|
|
11
|
-use App\Models\Project\ProjectServerBackup;
|
|
|
|
12
|
use App\Services\BatchExportService;
|
11
|
use App\Services\BatchExportService;
|
|
13
|
use Illuminate\Console\Command;
|
12
|
use Illuminate\Console\Command;
|
|
14
|
use Symfony\Component\Process\Process;
|
13
|
use Symfony\Component\Process\Process;
|
|
@@ -29,13 +28,58 @@ class Temp extends Command |
|
@@ -29,13 +28,58 @@ class Temp extends Command |
|
29
|
*/
|
28
|
*/
|
|
30
|
protected $description = '临时脚本';
|
29
|
protected $description = '临时脚本';
|
|
31
|
|
30
|
|
|
|
|
31
|
+ /**
|
|
|
|
32
|
+ * 获取指定服务器所有项目
|
|
|
|
33
|
+ * @author Akun
|
|
|
|
34
|
+ * @date 2024/09/30 17:01
|
|
|
|
35
|
+ */
|
|
|
|
36
|
+ public function handle()
|
|
|
|
37
|
+ {
|
|
|
|
38
|
+ $server_id = 1;
|
|
|
|
39
|
+
|
|
|
|
40
|
+ $server_ip_model = new ServersIp();
|
|
|
|
41
|
+
|
|
|
|
42
|
+ $server_ip_ids = $server_ip_model->where('servers_id', $server_id)->get()->pluck('id')->toArray();
|
|
|
|
43
|
+
|
|
|
|
44
|
+ $project_list = Project::select(['id', 'serve_id', 'title'])->whereIn('serve_id', $server_ip_ids)->get();
|
|
|
|
45
|
+
|
|
|
|
46
|
+ $domain_model = new DomainInfo();
|
|
|
|
47
|
+ $data = [];
|
|
|
|
48
|
+ foreach ($project_list as $value) {
|
|
|
|
49
|
+ $domain_info = $domain_model->read(['project_id' => $value->id, 'status' => 1], ['id', 'domain']);
|
|
|
|
50
|
+ if (!$domain_info) {
|
|
|
|
51
|
+ //过滤未绑定正式域名的项目
|
|
|
|
52
|
+ continue;
|
|
|
|
53
|
+ }
|
|
|
|
54
|
+ $domain = $domain_info['domain'];
|
|
|
|
55
|
+
|
|
|
|
56
|
+ $data[] = [
|
|
|
|
57
|
+ $value->id,
|
|
|
|
58
|
+ $value->title,
|
|
|
|
59
|
+ $domain
|
|
|
|
60
|
+ ];
|
|
|
|
61
|
+ }
|
|
|
|
62
|
+ $map = ['项目id', '名称', '域名'];
|
|
|
|
63
|
+ if ($data) {
|
|
|
|
64
|
+ $table = new BatchExportService("240云服务器项目");
|
|
|
|
65
|
+ $file = $table->head($map)->data($data)->save();
|
|
|
|
66
|
+ if (!$file) {
|
|
|
|
67
|
+ $this->output('文件生成失败,请重试');
|
|
|
|
68
|
+ } else {
|
|
|
|
69
|
+ $this->output('export success');
|
|
|
|
70
|
+ }
|
|
|
|
71
|
+ } else {
|
|
|
|
72
|
+ $this->output('no data');
|
|
|
|
73
|
+ }
|
|
|
|
74
|
+ }
|
|
|
|
75
|
+
|
|
32
|
|
76
|
|
|
33
|
/**
|
77
|
/**
|
|
34
|
* 检查不在所属服务器解析上的域名
|
78
|
* 检查不在所属服务器解析上的域名
|
|
35
|
* @author Akun
|
79
|
* @author Akun
|
|
36
|
* @date 2024/09/26 10:48
|
80
|
* @date 2024/09/26 10:48
|
|
37
|
*/
|
81
|
*/
|
|
38
|
- public function handle()
|
82
|
+ public function handle1()
|
|
39
|
{
|
83
|
{
|
|
40
|
$server_id = 14;
|
84
|
$server_id = 14;
|
|
41
|
|
85
|
|
|
@@ -59,7 +103,7 @@ class Temp extends Command |
|
@@ -59,7 +103,7 @@ class Temp extends Command |
|
59
|
foreach ($check as $item) {
|
103
|
foreach ($check as $item) {
|
|
60
|
if (strpos($item, 'Address:') !== false) {
|
104
|
if (strpos($item, 'Address:') !== false) {
|
|
61
|
$ip = trim(str_replace('Address:', '', $item));
|
105
|
$ip = trim(str_replace('Address:', '', $item));
|
|
62
|
- if (strpos($ip,'#') === false) {
|
106
|
+ if (strpos($ip, '#') === false) {
|
|
63
|
$ip_info = $server_ip_model->read(['ip' => $ip]);
|
107
|
$ip_info = $server_ip_model->read(['ip' => $ip]);
|
|
64
|
if ($ip_info === false || $ip_info['servers_id'] != $server_id) {
|
108
|
if ($ip_info === false || $ip_info['servers_id'] != $server_id) {
|
|
65
|
$data[] = [
|
109
|
$data[] = [
|
|
@@ -80,10 +124,10 @@ class Temp extends Command |
|
@@ -80,10 +124,10 @@ class Temp extends Command |
|
80
|
$file = $table->head($map)->data($data)->save();
|
124
|
$file = $table->head($map)->data($data)->save();
|
|
81
|
if (!$file) {
|
125
|
if (!$file) {
|
|
82
|
$this->output('文件生成失败,请重试');
|
126
|
$this->output('文件生成失败,请重试');
|
|
83
|
- }else{
|
127
|
+ } else {
|
|
84
|
$this->output('export success');
|
128
|
$this->output('export success');
|
|
85
|
}
|
129
|
}
|
|
86
|
- }else{
|
130
|
+ } else {
|
|
87
|
$this->output('no data');
|
131
|
$this->output('no data');
|
|
88
|
}
|
132
|
}
|
|
89
|
}
|
133
|
}
|