Skip to content

Commit 69efc0a

Browse files
committed
feat: nfs.js to mount disk
1 parent 6b3e3b3 commit 69efc0a

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/commands/other/nfs.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { exec } = require("child_process");
2+
3+
// Define the commands
4+
const commands = [
5+
"sudo apt-get update",
6+
"sudo apt-get install -y nfs-common",
7+
`sudo mkdir /mnt/efs`,
8+
// Replace fs-12345678 with your actual file system ID and us-west-2 with your EFS region
9+
"sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 fs-060287caeafac2302.efs.us-east-1.amazonaws.com:/ /mnt/efs"
10+
];
11+
12+
// Function to execute each command
13+
const executeCommand = (command) => {
14+
return new Promise((resolve, reject) => {
15+
exec(command, (error, stdout, stderr) => {
16+
if (error) {
17+
console.warn(error);
18+
reject();
19+
}
20+
console.log(stdout);
21+
resolve();
22+
});
23+
});
24+
};
25+
26+
// Execute all commands in sequence
27+
const runCommands = async () => {
28+
for (const command of commands) {
29+
console.log(`Running: ${command}`);
30+
try {
31+
await executeCommand(command);
32+
} catch (error) {
33+
console.error(`Error executing ${command}`);
34+
break; // Exit if any command fails
35+
}
36+
}
37+
console.log("All commands executed successfully.");
38+
};
39+
40+
runCommands();

0 commit comments

Comments
 (0)