Skip to content

Commit 7759d1d

Browse files
committed
core: allow customKeyfile for command runner
1 parent 6469c02 commit 7759d1d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/server/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type: server # server | domjudge | hydro
2424
viewPass: ${String.random(8)} # use admin / viewPass to login
2525
secretRoute: ${String.random(12)}
2626
seatFile: /home/icpc/Desktop/seats.txt
27+
customKeyfile:
2728
# if type is server, the following is not needed
2829
server:
2930
token:
@@ -63,6 +64,7 @@ const serverSchema = Schema.intersect([
6364
viewPass: Schema.string().default(String.random(8)),
6465
secretRoute: Schema.string().default(String.random(12)),
6566
seatFile: Schema.string().default('/home/icpc/Desktop/seat.txt'),
67+
customKeyfile: Schema.string().default(''),
6668
}).description('Basic Config'),
6769
Schema.union([
6870
Schema.object({

packages/server/utils/commandRunner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import child from 'child_process';
33
import fs from 'fs';
44
import { homedir } from 'os';
55
import { Logger } from './index';
6+
import { config } from '../config';
67

78
const logger = new Logger('runner');
89

@@ -36,7 +37,8 @@ export async function asyncCommand(command: string | string[], timeout = 10000)
3637
});
3738
}
3839

39-
const keyfile = fs.existsSync(`${homedir()}.ssh/id_rsa`) ? '.ssh/id_rsa' : '.ssh/id_ed25519';
40+
const keyfile = config.customKeyfile ? config.customKeyfile
41+
: (fs.existsSync(`${homedir()}.ssh/id_rsa`) ? '.ssh/id_rsa' : '.ssh/id_ed25519');
4042

4143
export async function executeOnHost(host: string, command: string, timeout = 10000) {
4244
logger.info('executing', command, 'on', host);

0 commit comments

Comments
 (0)