print("Starting 1lann's rescue disk!")
clock = os.clock()
if clock > 1 then
print("This program wasn't run on startup!")
print("Please reboot your computer and try again")
elseif not fs.exists("/disk") then
print("This program is not ran from a disk")
print("Please put it on a disk as startup and try again")
elseif not fs.isDir("/disk") then
print("A file is obstructing the name disk")
print("Would you like move it or exit the rescue")
print("disk and shutdown the computer?")
print("Enter rename to move it or something other")
print("than rename to exit and shutdown")
input = read()
if input == "rename" then
print("Ok renaming file...")
f = io.open("/disk", "r")
disk = f:read("*a")
f:close()
f = io.open("/otherdisk", "w")
f:write(disk)
f:close()
print("Alright, renamed to \"otherdisk\")
print("Now we have to reboot the computer")
print("Press enter to reboot the computer")
blah = read()
os.reboot()
else
os.shutdown()
end
else
print("Did you modify startup since the last")
print("time you ran the rescue disk?")
print("Type something other than yes or no to go")
print("straight to the terminal")
print("\(If this is your first time, type yes\)")
print("yes/no")
option = read()
if (option) == "yes" then
term.clear()
term.setCursorPos(1, 1)
print("Alright, then I can't check your startup")
print("I\'m gonna open the editor for startup")
print("once you hit enter")
print("Editing and hitting save won't do anything")
print("to the actual startup")
blah = read()
f = io.read("/startup", "r")
file = f:read("*a")
f:close()
f = io.read("/disk/tempstartup", "w")
file = f:write(file)
f:close()
shell.run("/rom/programs/edit", "/disk/tempstartup")
fs.delete("/disk/tempstartup")
print("Was that startup file correct?")
print("yes/something other than yes")
option = read()
if option == "yes" then
print("Alright, I\'ll backup your startup file")
f = io.open("/disk/startbackup")
f:write(file)
f:close()
print("Backed up as \"startbackup\" on the disk")
print("Please eject the disk and press enter to")
print("Shutdown the computer")
blah = read()
os.shutdown()
else
restore()
end
if (option) == "no" then
restore()
else
term.clear()
end
end