guanghulab/scripts/engine-one-liner.js

66 lines
4.0 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* 光湖驱动引擎 · 单行安装命令生成器
* Guanghu Drive Engine · One-liner Installer Generator
*
* 用途:生成一行命令,粘贴到任何服务器的终端即可安装引擎
*
* 运行node scripts/engine-one-liner.js
* 输出:一行 curl | bash 命令
*
* 版权:国作登字-2026-A-00037559 · TCS-0002∞
*/
const fs = require('fs');
const path = require('path');
// 引擎代码路径gatekeeper/index.js
const ENGINE_PATH = path.join(__dirname, '..', 'mcp-servers', 'zhuyuan-gateway', 'gatekeeper', 'index.js');
// ██████████████████████████████████████████████████████████████████████
// 第一步:读取引擎代码
// ██████████████████████████████████████████████████████████████████████
const engineCode = fs.readFileSync(ENGINE_PATH, 'utf-8');
const engineBase64 = Buffer.from(engineCode).toString('base64');
// 生成引擎文件名(带随机后缀防止多台服务器文件名冲突)
const FILENAME = 'ge.js';
// ██████████████████████████████████████████████████████████████████████
// 第二步:生成安装命令
// ██████████████████████████████████████████████████████████████████████
const oneLiner = `echo '${engineBase64}' | base64 -d > /tmp/${FILENAME} && node /tmp/${FILENAME} 3910 &`;
// ██████████████████████████████████████████████████████████████████████
// 第三步:输出
// ██████████████████████████████████████████████████████████████████████
console.log('');
console.log('╔══════════════════════════════════════════════════════════════╗');
console.log('║ 光湖驱动引擎 · 单行安装命令 ║');
console.log('╚══════════════════════════════════════════════════════════════╝');
console.log('');
console.log('▶ 复制下面这一整行命令,粘贴到服务器的终端,按回车:');
console.log('');
console.log(oneLiner);
console.log('');
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log('');
console.log('安装后:');
console.log(' 1. 引擎会在端口 3910 启动');
console.log(' 2. 第一次启动会自动生成 API 密钥');
console.log(' 3. 密钥显示在终端上(只看一次!)');
console.log(' 4. 把密钥复制下来发给铸渊');
console.log(' 5. 要验证: curl -X POST http://127.0.0.1:3910/health');
console.log('');
console.log('密钥保存在: ~/.gatekeeper/secret');
console.log('');
// 同时统计信息
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
console.log(` 引擎代码: ${engineCode.length} 字符`);
console.log(` 打包后: ${engineBase64.length} 字符`);
console.log(` 单行命令: ${oneLiner.length} 字符`);
console.log('');