修改环境变量加载逻辑

This commit is contained in:
whyour
2024-07-10 23:29:44 +08:00
parent 5afac3a3ac
commit e191aca41f
18 changed files with 210 additions and 343 deletions
+4 -3
View File
@@ -26,6 +26,7 @@ if (process.env.QL_DATA_DIR) {
}
const shellPath = path.join(rootPath, 'shell/');
const preloadPath = path.join(shellPath, 'preload/');
const tmpPath = path.join(rootPath, '.tmp/');
const samplePath = path.join(rootPath, 'sample/');
const configPath = path.join(dataPath, 'config/');
@@ -37,9 +38,9 @@ const uploadPath = path.join(dataPath, 'upload/');
const sshdPath = path.join(dataPath, 'ssh.d/');
const systemLogPath = path.join(dataPath, 'syslog/');
const envFile = path.join(configPath, 'env.sh');
const jsEnvFile = path.join(configPath, 'env.js');
const pyEnvFile = path.join(configPath, 'env.py');
const envFile = path.join(preloadPath, 'env.sh');
const jsEnvFile = path.join(preloadPath, 'env.js');
const pyEnvFile = path.join(preloadPath, 'env.py');
const confFile = path.join(configPath, 'config.sh');
const crontabFile = path.join(configPath, 'crontab.list');
const authConfigFile = path.join(configPath, 'auth.json');
+6
View File
@@ -11,6 +11,7 @@ if (process.env.QL_DATA_DIR) {
dataPath = process.env.QL_DATA_DIR.replace(/\/$/g, '');
}
const preloadPath = path.join(rootPath, 'shell/preload/');
const configPath = path.join(dataPath, 'config/');
const scriptPath = path.join(dataPath, 'scripts/');
const logPath = path.join(dataPath, 'log/');
@@ -38,6 +39,7 @@ export default async () => {
const authFileExist = await fileExist(authConfigFile);
const confFileExist = await fileExist(confFile);
const scriptDirExist = await fileExist(scriptPath);
const preloadDirExist = await fileExist(preloadPath);
const logDirExist = await fileExist(logPath);
const configDirExist = await fileExist(configPath);
const uploadDirExist = await fileExist(uploadPath);
@@ -59,6 +61,10 @@ export default async () => {
await fs.mkdir(scriptPath);
}
if (!preloadDirExist) {
await fs.mkdir(preloadPath);
}
if (!logDirExist) {
await fs.mkdir(logPath);
}
+1 -1
View File
@@ -12,7 +12,7 @@ export default async () => {
const subscriptionService = Container.get(SubscriptionService);
// 生成内置token
let tokenCommand = `tsx ${join(config.rootPath, 'back/token.ts')}`;
let tokenCommand = `ts-node-transpile-only ${join(config.rootPath, 'back/token.ts')}`;
const tokenFile = join(config.rootPath, 'static/build/token.js');
if (await fileExist(tokenFile)) {
+4
View File
@@ -33,6 +33,7 @@ import taskLimit from '../shared/pLimit';
import NotificationService from './notify';
import ScheduleService, { TaskCallbacks } from './schedule';
import SockService from './sock';
import os from 'os';
@Service()
export default class SystemService {
@@ -205,6 +206,9 @@ export default class SystemService {
});
let defaultDomain = 'https://dl-cdn.alpinelinux.org';
let targetDomain = 'https://dl-cdn.alpinelinux.org';
if (os.platform() !== 'linux') {
return;
}
const content = await fs.promises.readFile('/etc/apk/repositories', {
encoding: 'utf-8',
});