Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- print("MuSeOS Installer v2")
- io.write("Delete all files on hard drive? (Y/N)> ")
- local yn = io.read()
- yn = string.upper(yn)
- if yn == "Y" then
- print("Clearing hard drive...")
- for _,v in ipairs(fs.list("")) do
- if v ~= "disk" and not fs.isReadOnly(v) then
- print("Deleting: "..v)
- fs.delete(v)
- end
- os.sleep(0.5)
- end
- else
- print("Will not clear hard drive.")
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Installing MuSeOS...")
- os.sleep(0.5)
- print("Placing OS Folders...")
- fs.makeDir("os")
- fs.makeDir("os/logs")
- fs.makeDir("os/users")
- fs.makeDir("os/userSettings")
- fs.makeDir("apis/")
- fs.makeDir("modules/")
- fs.makeDir("bin/")
- os.sleep(0.5)
- print("Placing logfiles...")
- local fsLog = fs.open("os/logs/fileLog", "w")
- local osLog = fs.open("os/logs/OSLog", "w")
- local httpLog = fs.open("os/logs/HTTPLog", "w")
- local rsLog = fs.open("os/logs/RSLog", "w")
- fsLog.writeLine("[installer] Inital setup.")
- osLog.writeLine("[installer] Inital setup.")
- httpLog.writeLine("[installer] Inital setup.")
- rsLog.writeLine("[installer] Inital setup.")
- fsLog.close()
- osLog.close()
- httpLog.close()
- rsLog.close()
- print("Placing protected folders list...")
- local protectedFolders = fs.open("os/protected", "w")
- protectedFolders.close()
- print("Retrieving MuSeOS...")
- os.sleep(0.5)
- if http then
- print("HTTP API enabled, retrieving from pastebin...")
- shell.run("pastebin", "get", "fquZgJ5p", "MuSeOS")
- os.sleep(0.5)
- else
- print("HTTP API not enabled, copying from disk...")
- if not fs.exists("disk/MuSeOS", "r") then
- error("Can't access MuSeOS!")
- end
- local museOS = fs.open("disk/MuSeOS", "r")
- local OSFile = fs.open("MuSeOS", "w")
- OSFile.write(museOS.readAll())
- OSFile.close()
- os.sleep(0.5)
- end
- local startup = fs.open("startup", "w")
- startup.writeLine("shell.run('MuSeOS')")
- startup.close()
- print("Installing programs...")
- if http then
- print("Downloading installer from pastebin...")
- shell.run("pastebin", "get", "G33dymxf", "programInstaller")
- else
- print("Copying installer from disk...")
- if not fs.exists("disk/programInstaller") then
- error("Can't access program installer!")
- end
- local disk_installer = fs.open("disk/programInstalller", "r")
- local installerFile = fs.open("programInstaller", "w")
- installerFile.write(disk_installer.readAll())
- installerFile.close()
- os.sleep(0.5)
- end
- print("Retrieving man pages...")
- shell.run("pastebin", "get", "wfeGgwQH", "bin/man")
- os.sleep(2.5)
- shell.run("programInstaller")
- os.sleep(1) -- give it time to run
- fs.delete("programInstaller")
- if turtle then
- print("Making turtle settings file...")
- local settingsFile = fs.open("os/turtle", "w")
- settingsFile.writeLine("true")
- settingsFile.writeLine("true")
- settingsFile.writeLine("true")
- settingsFile.writeLine("true")
- settingsFile.close()
- end
- local function printRootPWDialog(startX, startY)
- local function readAdv(maxChars, startX, startY, replaceChar, returnToStart, backgroundChar)
- term.setCursorBlink(true)
- local function clearArea(clearLine, clearX, clearArea, replaceChar)
- local formerX,formerY = term.getCursorPos()
- for i=0, clearArea do
- term.setCursorPos(clearX+i, clearLine)
- if replaceChar ~= nil then
- io.write(replaceChar)
- else
- io.write(" ")
- end
- end
- term.setCursorPos(formerX,formerY)
- end
- local x,y = term.getCursorPos()
- term.setCursorPos(startX, startY)
- clearArea(startY, startX, maxChars, backgroundChar)
- local input = ""
- while true do
- local event, key = os.pullEvent()
- if event == "key" then
- if key == 28 or key == 156 then
- if returnToStart then
- term.setCursorPos(x,y)
- end
- return input
- elseif key == 14 then
- input = string.sub(input, 1, #input-1)
- term.setCursorPos(startX, startY)
- clearArea(startY, startX, maxChars, backgroundChar)
- if replaceChar == nil then
- io.write(input)
- else
- for i=1, #input do
- io.write(replaceChar)
- end
- end
- end
- elseif event == "char" then
- if maxChars ~= nil then
- if #input <= maxChars then
- input = input..key
- term.setCursorPos(startX, startY)
- clearArea(startY, startX, maxChars, backgroundChar)
- if replaceChar == nil then
- io.write(input)
- else
- for i=1, #input do
- io.write(replaceChar)
- end
- end
- end
- else
- input = input..key
- term.setCursorPos(startX, startY)
- clearArea(startY, startX, maxChars, backgroundChar)
- if replaceChar == nil then
- io.write(input)
- else
- for i=1, #input do
- io.write(replaceChar)
- end
- end
- end
- end
- end
- end
- term.setCursorPos(startX, startY)
- print("===========================")
- term.setCursorPos(startX, startY+1)
- print("|Type in a root password: |")
- term.setCursorPos(startX, startY+2)
- print("===========================")
- term.setCursorPos(startX, startY+3)
- print("| |")
- term.setCursorPos(startX, startY+4)
- print("===========================")
- return readAdv(24, startX+1, startY+3, nil, false, nil)
- end
- term.clear()
- term.setCursorPos(1,1)
- local rootPass = printRootPWDialog(12,4)
- term.setCursorBlink(false)
- local rootUser = fs.open("os/users/root", "w")
- fs.makeDir("os/userSettings/root/")
- local protectedList = fs.open("os/protected", "a")
- protectedList.writeLine("root")
- protectedList.close()
- rootUser.write(rootPass)
- rootUser.close()
- os.sleep(0.5)
- term.clear()
- term.setCursorPos(1,1)
- print(" ")
- print(" ")
- print("Inital username: root")
- print("Inital password: "..rootPass)
- print("KEEP YOUR ROOT PASSWORD SECURE.")
- print("ANYONE WITH ACCESS TO YOUR ROOT ACCOUNT CAN SEVERELY DAMAGE YOUR OS AND COMPUTER.")
- print(" ")
- os.sleep(1)
- print("This computer will reboot in 5 seconds.")
- if fs.exists("disk") and fs.isDir("disk") then
- print("We'll eject the disk for you.")
- disk.eject("right")
- disk.eject("left")
- disk.eject("top")
- disk.eject("bottom")
- disk.eject("front")
- disk.eject("back")
- end
- os.sleep(5)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement