mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-09 05:26:36 +08:00
修改token获取逻辑
This commit is contained in:
parent
7acf1eace3
commit
a9cc1cb4b9
|
@ -14,7 +14,7 @@ export default class SshKeyService {
|
||||||
|
|
||||||
private generatePrivateKeyFile(alias: string, key: string): void {
|
private generatePrivateKeyFile(alias: string, key: string): void {
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(`${this.sshPath}/${alias}`, key, {
|
fs.writeFileSync(`${this.sshPath}/${alias}`, `${key}${os.EOL}`, {
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
mode: '400',
|
mode: '400',
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,6 +5,7 @@ import LoggerInstance from './loaders/logger';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import config from './config';
|
import config from './config';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
const tokenFile = path.join(config.configPath, 'token.json');
|
const tokenFile = path.join(config.configPath, 'token.json');
|
||||||
|
|
||||||
|
@ -25,9 +26,14 @@ async function getToken() {
|
||||||
|
|
||||||
async function writeFile(data: any) {
|
async function writeFile(data: any) {
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
fs.writeFile(tokenFile, JSON.stringify(data), { encoding: 'utf8' }, () => {
|
fs.writeFile(
|
||||||
resolve();
|
tokenFile,
|
||||||
});
|
`${JSON.stringify(data)}${os.EOL}`,
|
||||||
|
{ encoding: 'utf8' },
|
||||||
|
() => {
|
||||||
|
resolve();
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
shell/api.sh
11
shell/api.sh
|
@ -1,7 +1,16 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
get_token() {
|
get_token() {
|
||||||
token=$(cat $file_auth_token | jq -r .value)
|
if [[ -f $file_auth_token ]]; then
|
||||||
|
token=$(cat $file_auth_token | jq -r .value)
|
||||||
|
else
|
||||||
|
local token_command="ts-node-transpile-only ${dir_root}/back/token.ts"
|
||||||
|
local token_file="${dir_root}static/build/token.js"
|
||||||
|
if [[ -f $token_file ]]; then
|
||||||
|
token_command="node ${token_file}"
|
||||||
|
fi
|
||||||
|
token=$(eval "$token_command")
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
add_cron_api() {
|
add_cron_api() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user