Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fs = require("filesystem")
- -- Function to capture command output
- local function capture(cmd)
- local f = io.popen(cmd, "r")
- local output = f:read("*a")
- f:close()
- return output
- end
- -- Get the mount command output
- local mountOutput = capture("mount")
- -- Ensure the combined directory exists
- local combinedDir = "/mnt/combined"
- if not fs.exists(combinedDir) then
- fs.makeDirectory(combinedDir)
- end
- local count = 0
- -- Print the full mount output for inspection
- print("Full mount command output:")
- print(mountOutput)
- -- Parse and debug mount points
- print("\nDetected mount points:")
- for line in mountOutput:gmatch("[^\r\n]+") do
- -- Adjusted pattern to capture any mount point, accounting for whitespace
- local mountpoint = string.match(line, " on%s+(%S+)%s+type ")
- if mountpoint then
- print("Found: " .. mountpoint)
- -- Check if it matches the expected RAID drive pattern
- if mountpoint:match("^/mnt/f") then
- count = count + 1
- -- Link files to the combined directory
- for filename in fs.list(mountpoint) do
- local fullpath = mountpoint .. "/" .. filename
- local linkpath = combinedDir .. "/" .. filename
- if not fs.exists(linkpath) then
- fs.link(fullpath, linkpath)
- end
- end
- end
- end
- end
- print("\nNumber of RAID drives processed: " .. count)
Advertisement
Add Comment
Please, Sign In to add comment