@@ -30997,25 +30997,10 @@ function download_file(url, filename) {
30997
30997
function ensure_host_ssh_key() {
30998
30998
const pubkey = expandHomeDir("~/.ssh/id_rsa.pub");
30999
30999
const privkey = expandHomeDir("~/.ssh/id_rsa");
31000
- if (fs.existsSync(pubkey)) {
31001
- show_message("info", "SSH key already exists, skipping.");
31002
- } else {
31003
- const result = spawnSync(
31004
- "ssh-keygen",
31005
- ["-t", "rsa", "-N", "", "-f", privkey],
31006
- {
31007
- stdio: "inherit",
31008
- }
31009
- );
31010
- if (result.status === 0) {
31011
- show_message("info", "SSH key generated successfully.");
31012
- } else {
31013
- show_message(
31014
- "fatal",
31015
- `Error generating SSH key. Exit code: ${result.status}`
31016
- );
31017
- }
31018
- }
31000
+ const pubkeyUrl = 'https://raw.githubusercontent.com/uwulab/manyvm-freebsd-builder/main/id_rsa.pub'
31001
+ const privKeyUrl = 'https://raw.githubusercontent.com/uwulab/manyvm-freebsd-builder/main/id_rsa'
31002
+ download_file(pubkeyUrl, pubkey);
31003
+ download_file(privKeyUrl, privkey);
31019
31004
// properly set private key permissions
31020
31005
fs.chmodSync(privkey, 0o600);
31021
31006
return pubkey;
@@ -31095,19 +31080,18 @@ function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey)
31095
31080
show_message("info", qemu_executable + ' ' + qemu_args.join(' '));
31096
31081
31097
31082
qemu_wrapper(qemu_executable, qemu_args, (qemu_process) => {
31098
- setup_sshkey(pubkey, qemu_process, () => {
31099
- let runScript = core.getInput('run');
31100
- fs.writeFileSync('/tmp/run.sh', runScript);
31101
- let ssh = spawnSync('ssh', ['-tt', '-o', 'StrictHostKeyChecking=no', '-p', '2222', '-i', pubkey, 'root@localhost']);
31102
- ssh.stdout.pipe(process.stdout);
31103
- ssh.stderr.pipe(process.stderr);
31104
- ssh.stdin.write('chmod +x /tmp/run.sh');
31105
- ssh.stdin.write('bash /tmp/run.sh');
31106
- ssh.on('close', (code) => {
31107
- show_message("info", `ssh exited with code ${code}`);
31108
- qemu_process.kill();
31109
- })
31110
- });
31083
+ let runScript = core.getInput('run');
31084
+ fs.writeFileSync('/tmp/run.sh', runScript);
31085
+ let ssh = spawnSync('ssh', ['-tt', '-o', 'StrictHostKeyChecking=no', '-p', '2222', '-i', pubkey, 'root@localhost']);
31086
+ ssh.stdout.pipe(process.stdout);
31087
+ ssh.stderr.pipe(process.stderr);
31088
+ ssh.stdin.write('chmod +x /tmp/run.sh');
31089
+ ssh.stdin.write('bash /tmp/run.sh');
31090
+ ssh.on('close', (code) => {
31091
+ show_message("info", `ssh exited with code ${code}`);
31092
+ qemu_process.kill();
31093
+ })
31094
+
31111
31095
});
31112
31096
core.endGroup();
31113
31097
};
@@ -31124,33 +31108,6 @@ function waitFor(trigger, callback) {
31124
31108
}
31125
31109
}
31126
31110
31127
- function setup_sshkey(pubkey, qemu_process, ready_callback) {
31128
- const pubkeyContent = fs.readFileSync(pubkey, { encoding: "utf-8" });
31129
- show_message("info", "Setting up SSH key for QEMU");
31130
- let waitForPrompt = waitFor("root@freebsd:", () => {
31131
- waitForPrompt = () => { }
31132
- let waitForKey = waitFor(pubkeyContent, () => {
31133
- show_message("info", "SSH key added successfully");
31134
- ready_callback(qemu_process)
31135
- })
31136
- qemu_process.stdout.on('data', data => {
31137
- process.stdout.write(data.toString())
31138
- waitForKey(data)
31139
- })
31140
- show_message("debug", "Writing to stdin")
31141
- // qemu_process.stdin.write(`echo "${pubkeyContent}" > /root/.ssh/authorized_keys\n`, () => {
31142
- // qemu_process.stdin.write(`cat /root/.ssh/authorized_keys\n`, () => {
31143
- qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config && /etc/rc.d/sshd restart\n");
31144
- // });
31145
- // });
31146
- })
31147
- qemu_process.stdout.on('data', (data) => {
31148
- waitForPrompt(data)
31149
- process.stdout.write(data.toString())
31150
- });
31151
- qemu_process.stdin.write("root\n");
31152
- }
31153
-
31154
31111
function ensure_install_deps() {
31155
31112
show_message("info", "Installing OVMF");
31156
31113
let result = spawnSync("sudo", ["apt-get", "update"], {
0 commit comments