Skip to content

Commit

Permalink
ugh
Browse files Browse the repository at this point in the history
  • Loading branch information
shinohara-rin committed May 3, 2024
1 parent 48a626c commit 7fbb421
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
35 changes: 17 additions & 18 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31119,25 +31119,24 @@ function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey)
function setup_sshkey(pubkey, qemu_process, ready_callback) {
const pubkeyContent = fs.readFileSync(pubkey, { encoding: "utf-8" });
show_message("info", "Setting up SSH key for QEMU");
qemu_process.stdout.pipe(process.stdout); // let's see what's going on
qemu_process.stdin.write("root\n");
setTimeout(() => {
qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n");
qemu_process.stdin.write(`cat > /root/.ssh/authorized_keys <<<"${pubkeyContent}"\n`);
qemu_process.stdin.write(`cat /root/.ssh/authorized_keys`);
}, 10000);
setTimeout(() => { ready_callback(qemu_process) }, 2000);
// let waitForKey = (() => {
// let concat = ''
// return (data) => {
// concat += data.toString()
// if (concat.includes(pubkeyContent)) {
// ready_callback(qemu_process)
// waitForKey = () => { }
// }
// }
// })()
// qemu_process.stdout.on('data', waitForKey);
let waitForKey = (() => {
let concat = ''
return (data) => {
concat += data.toString()
if (concat.includes("root@freebsd:")) {
qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n");
qemu_process.stdin.write(`cat > /root/.ssh/authorized_keys <<<"${pubkeyContent}"\n`);
qemu_process.stdin.write(`cat /root/.ssh/authorized_keys`);
setTimeout(() => { ready_callback(qemu_process) }, 2000);
waitForKey = () => { }
}
}
})()
qemu_process.stdout.on('data', (data) => {
waitForKey(data)
process.stdout.write(data.toString())
});
}

function ensure_install_deps() {
Expand Down
35 changes: 17 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,24 @@ function start_vm(qemu_version, os, cpu, arch, bios, machine, filename, pubkey)
function setup_sshkey(pubkey, qemu_process, ready_callback) {
const pubkeyContent = fs.readFileSync(pubkey, { encoding: "utf-8" });
show_message("info", "Setting up SSH key for QEMU");
qemu_process.stdout.pipe(process.stdout); // let's see what's going on
qemu_process.stdin.write("root\n");
setTimeout(() => {
qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n");
qemu_process.stdin.write(`cat > /root/.ssh/authorized_keys <<<"${pubkeyContent}"\n`);
qemu_process.stdin.write(`cat /root/.ssh/authorized_keys`);
}, 10000);
setTimeout(() => { ready_callback(qemu_process) }, 2000);
// let waitForKey = (() => {
// let concat = ''
// return (data) => {
// concat += data.toString()
// if (concat.includes(pubkeyContent)) {
// ready_callback(qemu_process)
// waitForKey = () => { }
// }
// }
// })()
// qemu_process.stdout.on('data', waitForKey);
let waitForKey = (() => {
let concat = ''
return (data) => {
concat += data.toString()
if (concat.includes("root@freebsd:")) {
qemu_process.stdin.write("echo 'PermitRootLogin yes' >> /etc/ssh/sshd_config\n");
qemu_process.stdin.write(`cat > /root/.ssh/authorized_keys <<<"${pubkeyContent}"\n`);
qemu_process.stdin.write(`cat /root/.ssh/authorized_keys`);
setTimeout(() => { ready_callback(qemu_process) }, 2000);
waitForKey = () => { }
}
}
})()
qemu_process.stdout.on('data', (data) => {
waitForKey(data)
process.stdout.write(data.toString())
});
}

function ensure_install_deps() {
Expand Down

0 comments on commit 7fbb421

Please sign in to comment.