Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Check if required files and directories exist
- local filesToCheck = {
- "/disk/os/gui/",
- "/disk/os/home.lua",
- "/disk/bootloader/VA11-ILLA.lua",
- "/disk/boot/error"
- }
- local diskPath = "/disk/"
- local recoveryPath = "/recovery/"
- -- Function to check if a file or directory exists
- local function fileExists(path)
- return fs.exists(path)
- end
- -- Function to delete a directory and its contents
- local function deleteDirectory(path)
- if fs.exists(path) then
- fs.delete(path)
- end
- end
- -- Function to copy a directory and its contents
- local function copyDirectory(source, destination)
- if fs.exists(source) then
- fs.copy(source, destination)
- end
- end
- -- Function to shut down the computer
- local function shutdownComputer()
- os.shutdown()
- end
- -- Main function to check and perform actions
- local function checkAndHandleFiles()
- while true do
- local deleteDisk = false
- for _, filePath in ipairs(filesToCheck) do
- if not fileExists(filePath) then
- deleteDisk = true
- break
- end
- end
- if deleteDisk then
- if fs.exists(recoveryPath) then
- deleteDirectory(diskPath)
- copyDirectory(recoveryPath, diskPath)
- else
- shutdownComputer()
- end
- end
- -- Sleep for 1 second before checking again
- os.sleep(1)
- end
- end
- -- Run the main function
- checkAndHandleFiles()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement