Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Doggy OS USB Disk Management System for CC Tweaked
- local function autoDetectDisk()
- local disks = {}
- for i = 2, 4 do -- Assuming a maximum of 3 disk slots (disk2, disk3, disk4)
- local diskPath = "/disk" .. i
- if fs.exists(diskPath) then
- table.insert(disks, diskPath)
- end
- end
- return disks
- end
- local function createInstallDisk()
- print("Enter the path of the file to add to the disk:")
- local filePath = read()
- print("Enter a label for the disk:")
- local label = read()
- local disks = autoDetectDisk()
- if #disks == 0 then
- print("No disks found. Please insert a disk.")
- return
- end
- print("Found disks: ")
- for i, disk in ipairs(disks) do
- print(i .. ". " .. disk)
- end
- print("Select a disk (1-" .. #disks .. "):")
- local choice = tonumber(read())
- local selectedDisk = disks[choice]
- if not selectedDisk or not fs.exists(filePath) then
- print("Invalid selection or file does not exist.")
- return
- end
- -- Create a directory on the disk if it doesn't exist
- if not fs.exists(selectedDisk .. "/" .. label) then
- fs.makeDir(selectedDisk .. "/" .. label)
- end
- -- Copy the required files to the selected disk with the specified label
- local installDiskFile = selectedDisk .. "/" .. label .. "/DGY Installdsk"
- fs.copy(filePath, installDiskFile)
- print("Install file created successfully on " .. selectedDisk .. " with label: " .. label)
- end
- local function installFromDisk()
- local disks = autoDetectDisk()
- if #disks == 0 then
- print("No disks found. Please insert a disk.")
- return
- end
- print("Found disks: ")
- for i, disk in ipairs(disks) do
- print(i .. ". " .. disk)
- end
- print("Select a disk (1-" .. #disks .. "):")
- local choice = tonumber(read())
- local selectedDisk = disks[choice]
- if not selectedDisk then
- print("Invalid selection.")
- return
- end
- print("Enter the name you want to save the file as:")
- local saveFileName = read()
- print("Enter the path to save the file (e.g., /home/username/):")
- local savePath = read()
- local installFilePath = selectedDisk .. "/" .. fs.getName(saveFileName) -- Path of the file to copy from the disk
- if fs.exists(installFilePath) then
- print("Copying from disk " .. selectedDisk .. " to " .. savePath .. saveFileName)
- fs.copy(installFilePath, savePath .. saveFileName)
- print("Installation successful. File saved as: " .. savePath .. saveFileName)
- else
- print("Install file not found on " .. selectedDisk)
- end
- end
- local function encryptDisk()
- print("Enter password for encryption:")
- local password = read()
- local disks = autoDetectDisk()
- if #disks == 0 then
- print("No disks found. Please insert a disk.")
- return
- end
- print("Found disks: ")
- for i, disk in ipairs(disks) do
- print(i .. ". " .. disk)
- end
- print("Select a disk (1-" .. #disks .. "):")
- local choice = tonumber(read())
- local selectedDisk = disks[choice]
- if not selectedDisk then
- print("Invalid selection.")
- return
- end
- -- Implement encryption logic here
- local encryptionKey = computer.getPCID() .. password -- Simple example
- fs.write(selectedDisk .. "/encryption_key", encryptionKey)
- print("Disk " .. selectedDisk .. " encrypted successfully.")
- end
- local function decryptDisk()
- print("Enter password for decryption:")
- local password = read()
- local disks = autoDetectDisk()
- if #disks == 0 then
- print("No disks found. Please insert a disk.")
- return
- end
- print("Found disks: ")
- for i, disk in ipairs(disks) do
- print(i .. ". " .. disk)
- end
- print("Select a disk (1-" .. #disks .. "):")
- local choice = tonumber(read())
- local selectedDisk = disks[choice]
- if not selectedDisk then
- print("Invalid selection.")
- return
- end
- local encryptionKeyPath = selectedDisk .. "/encryption_key"
- if fs.exists(encryptionKeyPath) then
- local encryptionKey = fs.read(encryptionKeyPath)
- -- Implement decryption logic here
- print("Disk " .. selectedDisk .. " decrypted successfully.")
- else
- print("No encryption key found on " .. selectedDisk)
- end
- end
- -- Main menu
- while true do
- print("Doggy OS USB Disk Management")
- print("1. Create Install Disk")
- print("2. Install from Disk")
- print("3. Encrypt Disk")
- print("4. Decrypt Disk")
- print("5. Exit")
- local choice = tonumber(read())
- if choice == 1 then
- createInstallDisk()
- elseif choice == 2 then
- installFromDisk()
- elseif choice == 3 then
- encryptDisk()
- elseif choice == 4 then
- decryptDisk()
- elseif choice == 5 then
- break
- else
- print("Invalid choice. Please try again.")
- end
- end
Add Comment
Please, Sign In to add comment