diff --git a/back/config/index.ts b/back/config/index.ts index 1c426811..b9d33b85 100644 --- a/back/config/index.ts +++ b/back/config/index.ts @@ -38,6 +38,8 @@ 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 confFile = path.join(configPath, 'config.sh'); const crontabFile = path.join(configPath, 'crontab.list'); const authConfigFile = path.join(configPath, 'auth.json'); @@ -87,6 +89,8 @@ export default { sampleFile, confFile, envFile, + jsEnvFile, + pyEnvFile, dbPath, uploadPath, configPath, @@ -99,6 +103,8 @@ export default { 'crontab.list', 'dependence-proxy.sh', 'env.sh', + 'env.js', + 'env.py', 'token.json', ], writePathList: [configPath, scriptPath], diff --git a/back/services/env.ts b/back/services/env.ts index 836b7211..27a0b76d 100644 --- a/back/services/env.ts +++ b/back/services/env.ts @@ -196,6 +196,8 @@ export default class EnvService { }); const groups = groupBy(envs, 'name'); let env_string = ''; + let js_env_string = ''; + let py_env_string = 'import os\n'; for (const key in groups) { if (Object.prototype.hasOwnProperty.call(groups, key)) { const group = groups[key]; @@ -208,9 +210,18 @@ export default class EnvService { .replace(/'/g, "'\\''") .trim(); env_string += `export ${key}='${value}'\n`; + const _env_value = `'${group + .map((x) => x.value) + .join('&') + .replace(/\\/g, '\\\\') + .replace(/'/g, "\\'")}'`; + js_env_string += `process.env.${key}=${_env_value};\n`; + py_env_string += `os.environ['${key}']=${_env_value}\n`; } } } await fs.writeFile(config.envFile, env_string); + await fs.writeFile(config.jsEnvFile, js_env_string); + await fs.writeFile(config.pyEnvFile, py_env_string); } } diff --git a/shell/share.sh b/shell/share.sh index 44af0f73..e019c726 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -74,7 +74,9 @@ init_env() { import_config() { [[ -f $file_config_user ]] && . $file_config_user - [[ -f $file_env ]] && . $file_env + if [[ $LOAD_ENV != 'false' ]] && [[ -f $file_env ]]; then + . $file_env + fi ql_base_url=${QlBaseUrl:-"/"} ql_port=${QlPort:-"5700"}