|
...
|
...
|
@@ -43,7 +43,7 @@ class Temp extends Command |
|
|
|
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$this->check_no_cname_projects();
|
|
|
|
$this->change_cname_projects();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -600,15 +600,18 @@ class Temp extends Command |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 240服务器上解析cname的项目迁移
|
|
|
|
* 服务器上解析cname的项目迁移
|
|
|
|
* @author Akun
|
|
|
|
* @date 2025/02/17 14:21
|
|
|
|
*/
|
|
|
|
public function change_cname_projects_240()
|
|
|
|
public function change_cname_projects()
|
|
|
|
{
|
|
|
|
$origin_server_id = 20;//原服务器
|
|
|
|
$target_server_id = 27;//目标服务器
|
|
|
|
|
|
|
|
$server_ip_model = new ServersIp();
|
|
|
|
|
|
|
|
$server_ip_ids = $server_ip_model->where('servers_id', 1)->get()->pluck('id')->toArray();
|
|
|
|
$server_ip_ids = $server_ip_model->where('servers_id', $origin_server_id)->get()->pluck('id')->toArray();
|
|
|
|
|
|
|
|
$project_list = Project::select(['id', 'serve_id'])->whereIn('serve_id', $server_ip_ids)->get();
|
|
|
|
|
|
...
|
...
|
@@ -626,60 +629,70 @@ class Temp extends Command |
|
|
|
$domain = $domain_info['domain'];
|
|
|
|
|
|
|
|
//迁移主站
|
|
|
|
$check = dns_get_record($domain, DNS_A);
|
|
|
|
$host = $check[0]['host'] ?? '';
|
|
|
|
if ($host == 'cname.globalso.com') {
|
|
|
|
//获取主站备份证书
|
|
|
|
$ssl_info = DB::table('gl_domain_ssl_backup')->select(['private_key', 'private_cert'])->where('domain', $domain)->first();
|
|
|
|
if (!$ssl_info) {
|
|
|
|
$this->output('项目id:' . $project_id . ' | 未备份主站证书');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建主站建站任务
|
|
|
|
$task_info = DomainCreateTask::where('type', 1)->where('server_id', 20)->where('project_id', $project_id)->where('status', '!=', DomainCreateTask::STATUS_SUC)->first();
|
|
|
|
if (!$task_info) {
|
|
|
|
$task_model = new DomainCreateTask();
|
|
|
|
$task_model->type = 1;
|
|
|
|
$task_model->server_id = 20;
|
|
|
|
$task_model->project_id = $project_id;
|
|
|
|
$task_model->domain_id = $domain_id;
|
|
|
|
$task_model->certs = json_encode(['key' => $ssl_info->private_key, 'csr' => $ssl_info->private_cert]);
|
|
|
|
$task_model->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建主站页面生成任务
|
|
|
|
$notify_data = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'type' => 1,
|
|
|
|
'route' => 1,
|
|
|
|
'server_id' => 20,
|
|
|
|
'status' => ['!=', Notify::STATUS_FINISH_SITEMAP]
|
|
|
|
];
|
|
|
|
$notify = $notify_model->read($notify_data, ['id']);
|
|
|
|
// try {
|
|
|
|
// $check = dns_get_record($domain, DNS_A);
|
|
|
|
// $host = $check[0]['host'] ?? '';
|
|
|
|
// } catch (\Exception $e) {
|
|
|
|
// $this->output($domain . ' | 获取解析记录失败');
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if ($host != 'cname.globalso.com') {
|
|
|
|
// $this->output($domain . ' | 未解析cname');
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//获取主站备份证书
|
|
|
|
$ssl_info = DB::table('gl_domain_ssl_backup')->select(['private_key', 'private_cert'])->where('domain', $domain)->first();
|
|
|
|
if (!$ssl_info) {
|
|
|
|
$this->output($domain . ' | 未备份证书');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$notify) {
|
|
|
|
$notify_data['data'] = Arr::a2s(['domain' => $domain, 'url' => null, 'language' => []]);
|
|
|
|
$notify_data['status'] = Notify::STATUS_INIT;
|
|
|
|
$notify_model->add($notify_data);
|
|
|
|
}
|
|
|
|
//创建主站建站任务
|
|
|
|
$task_info = DomainCreateTask::where('type', 1)->where('server_id', $target_server_id)->where('project_id', $project_id)->where('status', '!=', DomainCreateTask::STATUS_SUC)->first();
|
|
|
|
if (!$task_info) {
|
|
|
|
$task_model = new DomainCreateTask();
|
|
|
|
$task_model->type = 1;
|
|
|
|
$task_model->server_id = $target_server_id;
|
|
|
|
$task_model->project_id = $project_id;
|
|
|
|
$task_model->domain_id = $domain_id;
|
|
|
|
$task_model->certs = json_encode(['key' => $ssl_info->private_key, 'csr' => $ssl_info->private_cert]);
|
|
|
|
$task_model->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建主站关键词页面生成任务
|
|
|
|
$notify_keyword_data = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'type' => 1,
|
|
|
|
'route' => 4,
|
|
|
|
'server_id' => 20,
|
|
|
|
'status' => ['!=', Notify::STATUS_FINISH_SITEMAP]
|
|
|
|
];
|
|
|
|
$notify_keyword = $notify_model->read($notify_keyword_data, ['id']);
|
|
|
|
// //创建主站页面生成任务
|
|
|
|
// $notify_data = [
|
|
|
|
// 'project_id' => $project_id,
|
|
|
|
// 'type' => 1,
|
|
|
|
// 'route' => 1,
|
|
|
|
// 'server_id' => 20,
|
|
|
|
// 'status' => ['!=', Notify::STATUS_FINISH_SITEMAP]
|
|
|
|
// ];
|
|
|
|
// $notify = $notify_model->read($notify_data, ['id']);
|
|
|
|
//
|
|
|
|
// if (!$notify) {
|
|
|
|
// $notify_data['data'] = Arr::a2s(['domain' => $domain, 'url' => null, 'language' => []]);
|
|
|
|
// $notify_data['status'] = Notify::STATUS_INIT;
|
|
|
|
// $notify_model->add($notify_data);
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// //创建主站关键词页面生成任务
|
|
|
|
// $notify_keyword_data = [
|
|
|
|
// 'project_id' => $project_id,
|
|
|
|
// 'type' => 1,
|
|
|
|
// 'route' => 4,
|
|
|
|
// 'server_id' => 20,
|
|
|
|
// 'status' => ['!=', Notify::STATUS_FINISH_SITEMAP]
|
|
|
|
// ];
|
|
|
|
// $notify_keyword = $notify_model->read($notify_keyword_data, ['id']);
|
|
|
|
//
|
|
|
|
// if (!$notify_keyword) {
|
|
|
|
// $notify_keyword_data['data'] = Arr::a2s(['domain' => $domain, 'url' => null, 'language' => []]);
|
|
|
|
// $notify_keyword_data['status'] = Notify::STATUS_INIT;
|
|
|
|
// $notify_model->add($notify_keyword_data);
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (!$notify_keyword) {
|
|
|
|
$notify_keyword_data['data'] = Arr::a2s(['domain' => $domain, 'url' => null, 'language' => []]);
|
|
|
|
$notify_keyword_data['status'] = Notify::STATUS_INIT;
|
|
|
|
$notify_model->add($notify_keyword_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($domain_info['amp_status'] == 1) {
|
|
|
|
//迁移amp站
|
|
...
|
...
|
@@ -693,44 +706,53 @@ class Temp extends Command |
|
|
|
}
|
|
|
|
$amp_domain = implode('.', $host_array);
|
|
|
|
|
|
|
|
$check_amp = dns_get_record($amp_domain, DNS_A);
|
|
|
|
$host_amp = $check_amp[0]['host'] ?? '';
|
|
|
|
if ($host_amp == 'cname.globalso.com') {
|
|
|
|
//获取amp站备份证书
|
|
|
|
$ssl_info_amp = DB::table('gl_domain_ssl_backup')->select(['private_key', 'private_cert'])->where('domain', $amp_domain)->first();
|
|
|
|
if (!$ssl_info_amp) {
|
|
|
|
$this->output('项目id:' . $project_id . ' | 未备份amp站证书');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建amp站建站任务
|
|
|
|
$task_info_amp = DomainCreateTask::where('type', 2)->where('server_id', 20)->where('project_id', $project_id)->where('status', '!=', DomainCreateTask::STATUS_SUC)->first();
|
|
|
|
if (!$task_info_amp) {
|
|
|
|
$task_model = new DomainCreateTask();
|
|
|
|
$task_model->type = 2;
|
|
|
|
$task_model->server_id = 20;
|
|
|
|
$task_model->project_id = $project_id;
|
|
|
|
$task_model->domain_id = $domain_id;
|
|
|
|
$task_model->certs = json_encode(['key' => $ssl_info_amp->private_key, 'csr' => $ssl_info_amp->private_cert]);
|
|
|
|
$task_model->save();
|
|
|
|
}
|
|
|
|
// try {
|
|
|
|
// $check_amp = dns_get_record($amp_domain, DNS_A);
|
|
|
|
// $host_amp = $check_amp[0]['host'] ?? '';
|
|
|
|
// } catch (\Exception $e) {
|
|
|
|
// $this->output($amp_domain . ' | 获取解析记录失败');
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if ($host_amp != 'cname.globalso.com') {
|
|
|
|
// $this->output($amp_domain . ' | 未解析cname');
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//获取amp站备份证书
|
|
|
|
$ssl_info_amp = DB::table('gl_domain_ssl_backup')->select(['private_key', 'private_cert'])->where('domain', $amp_domain)->first();
|
|
|
|
if (!$ssl_info_amp) {
|
|
|
|
$this->output($amp_domain . ' | 未备份证书');
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//创建amp站页面生成任务
|
|
|
|
$notify_amp_data = [
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'type' => 3,
|
|
|
|
'route' => 1,
|
|
|
|
'server_id' => 20,
|
|
|
|
'status' => ['!=', Notify::STATUS_FINISH_SITEMAP]
|
|
|
|
];
|
|
|
|
$notify_amp = $notify_model->read($notify_amp_data, ['id']);
|
|
|
|
|
|
|
|
if (!$notify_amp) {
|
|
|
|
$notify_amp_data['data'] = Arr::a2s(['domain' => $amp_domain, 'url' => null, 'language' => []]);
|
|
|
|
$notify_amp_data['status'] = Notify::STATUS_INIT;
|
|
|
|
$notify_model->add($notify_amp_data);
|
|
|
|
}
|
|
|
|
//创建amp站建站任务
|
|
|
|
$task_info_amp = DomainCreateTask::where('type', 2)->where('server_id', $target_server_id)->where('project_id', $project_id)->where('status', '!=', DomainCreateTask::STATUS_SUC)->first();
|
|
|
|
if (!$task_info_amp) {
|
|
|
|
$task_model = new DomainCreateTask();
|
|
|
|
$task_model->type = 2;
|
|
|
|
$task_model->server_id = $target_server_id;
|
|
|
|
$task_model->project_id = $project_id;
|
|
|
|
$task_model->domain_id = $domain_id;
|
|
|
|
$task_model->certs = json_encode(['key' => $ssl_info_amp->private_key, 'csr' => $ssl_info_amp->private_cert]);
|
|
|
|
$task_model->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
// //创建amp站页面生成任务
|
|
|
|
// $notify_amp_data = [
|
|
|
|
// 'project_id' => $project_id,
|
|
|
|
// 'type' => 3,
|
|
|
|
// 'route' => 1,
|
|
|
|
// 'server_id' => 20,
|
|
|
|
// 'status' => ['!=', Notify::STATUS_FINISH_SITEMAP]
|
|
|
|
// ];
|
|
|
|
// $notify_amp = $notify_model->read($notify_amp_data, ['id']);
|
|
|
|
//
|
|
|
|
// if (!$notify_amp) {
|
|
|
|
// $notify_amp_data['data'] = Arr::a2s(['domain' => $amp_domain, 'url' => null, 'language' => []]);
|
|
|
|
// $notify_amp_data['status'] = Notify::STATUS_INIT;
|
|
|
|
// $notify_model->add($notify_amp_data);
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|