test(fuc-xb): template acceptance\n
This commit is contained in:
1 parent
ce2a2ad578
commit
89bbc2a211
1 file changed
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
declare(strict_types=1);umask(0077);
|
||||
$root='/var/www/wwwroot/fuc-xb-test/current';$dir='/var/www/wwwroot/fuc-xb-test/private/live-acceptance-20261104';
|
||||
putenv('XB_INSTANCE=fuc-xb-test');$_SERVER['XB_INSTANCE']=$_ENV['XB_INSTANCE']='fuc-xb-test';
|
||||
require $root.'/vendor/autoload.php';$a=require $root.'/bootstrap/app.php';$a->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
if(Illuminate\Support\Facades\DB::connection()->getDatabaseName()!=='fuc_xb_test')throw new RuntimeException('Wrong database');
|
||||
$path=$root.'/scripts/node-onboarding/sing-box-template.json';
|
||||
if(hash_file('sha256',$path)!=='32168fd207632602d4f99f6c66c4d2c3e2399dc0ec3726d9e5b0be1564db3d81')throw new RuntimeException('Reviewed modern template changed');
|
||||
$modern=file_get_contents($path);$old=App\Models\SubscribeTemplate::where('name','singbox')->firstOrFail();
|
||||
$current=json_decode($old->content,true,512,JSON_THROW_ON_ERROR);$new=json_decode($modern,true,512,JSON_THROW_ON_ERROR);
|
||||
if($current===$new){echo json_encode(['already_updated'=>true,'shared_code_changed'=>false]).PHP_EOL;exit;}
|
||||
$default=json_decode(file_get_contents($root.'/resources/rules/default.sing-box.json'),true,512,JSON_THROW_ON_ERROR);
|
||||
if($current!==$default)throw new RuntimeException('Unexpected custom template; do not overwrite');
|
||||
$backup=$dir.'/singbox-template-before.json';if(file_exists($backup))throw new RuntimeException('Existing backup; inspect current state');
|
||||
file_put_contents($backup,json_encode($old->getAttributes()));chmod($backup,0600);
|
||||
App\Models\SubscribeTemplate::setContent('singbox',$modern);
|
||||
if(App\Models\SubscribeTemplate::getContent('singbox')!==$modern)throw new RuntimeException('Template readback failed');
|
||||
echo json_encode(['updated_only_isolated_instance_template'=>true,'old_template_backed_up'=>true,'shared_code_changed'=>false,'other_instances_changed'=>false,'modern_template_sha256'=>hash('sha256',$modern)]).PHP_EOL;
|
||||
Reference in new issue
Block a user