Thod

DreamOS Installer

Mar 5th, 2021 (edited)
896
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ThodOS 18 Installer
  2. local brunning = true
  3. term.clear()
  4. term.setCursorPos(1,1)
  5.  
  6. term.setTextColor(colors.magenta)
  7. textutils.slowPrint("DreamOS Installer initializg...")
  8. local bground
  9. local adminSetup = "root"
  10. local passInput
  11. local confpassInput
  12. local confpassnomatch
  13. local missingpass
  14. local curUsers = {}
  15. local newUser
  16. local newPass
  17. local newConfPass
  18.  
  19. w,h = term.getSize()
  20. local slc = 1
  21. local selectedDSFile
  22. local function dlfile(pid,nFile)
  23.     local r = http.get("https://pastebin.com/raw/"..pid);
  24.     local f = fs.open( shell.resolve( nFile ), "w" );
  25.     f.write( r.readAll() ); f.close();
  26.     r.close()
  27. end
  28. if fs.exists("DreamOS") then
  29.     print("It appears there are already DreamOS file\(s\) files on your computer. Delete these?")
  30.     print("[Y/N]")
  31.     local filesFoundStartup = true
  32.     while filesFoundStartup do
  33.         local delInput = io.read()
  34.         if delInput == "Y" or delInput == "y" then
  35.             shell.run("delete","DreamOS")
  36.             print("Deleted.")
  37.             filesFoundStartup = false
  38.         elseif delInput == "N" or delInput == "n" then
  39.             print("Keeping these files is not recommended before installing, back them up and delete original?")
  40.             print("[Y/N]")
  41.             local filesFoundStartupBackup = true
  42.             while filesFoundStartupBackup do
  43.                 local delInputBackup = io.read()
  44.                 if delInputBackup == "Y" or delInputBackup == "y" then
  45.                     shell.run("rename","DreamOS","backup_DreamOS")
  46.                     print("Your file\(s\) have been backed up in \"backup_DreamOS\"")
  47.                     filesFoundStartupBackup = false
  48.                     filesFoundStartup = false
  49.                 elseif delInputBackup == "N" or delInputBackup == "n" then
  50.                     print("Continuing")
  51.                     filesFoundStartupBackup = false
  52.                     filesFoundStartup = false
  53.                 end
  54.             end
  55.         end
  56.     end
  57. end
  58.  
  59. textutils.slowPrint("Downloading required files...")
  60.  
  61. -- Thanks to Krakaen for Pastebin fix (https://www.youtube.com/channel/UC2P4zFOgP_gx8jDtTJpUjAA)
  62. dlfile("SyzKgTuT","DreamOS/installer/bground.nfp")
  63.  
  64. bground = "DreamOS/installer/bground.nfp"
  65.  
  66. local function drawBground()
  67.     term.setBackgroundColor(colors.cyan)
  68.     term.clear()
  69.     local loadBground = paintutils.loadImage(bground)
  70.     paintutils.drawImage(loadBground,1,1)
  71.     term.setCursorPos(1,1)
  72.     term.setBackgroundColor(colors.gray)
  73.     term.setTextColor(colors.magenta)
  74.     print("  DreamOS Installer  ")
  75. end
  76.  
  77. local function printRight(str,ypos)
  78.     term.setCursorPos(w/2-2,ypos)
  79.     term.setBackgroundColor(colors.cyan)
  80.     term.setTextColor(colors.gray)
  81.     print(str)
  82. end
  83.  
  84. local function page1()
  85.     term.setBackgroundColor(colors.green)
  86.     term.setTextColor(colors.white)
  87.     term.setCursorPos(3,5)
  88.     print("   BEGIN   ")
  89.     term.setBackgroundColor(colors.red)
  90.     term.setTextColor(colors.white)
  91.     term.setCursorPos(2,10)
  92.     print("   CANCEL    ")
  93.     printRight("Welcome to DreamOS!",5)
  94.     printRight("DreamOS is a branch of",6)
  95.     printRight("ThodOS18",7)
  96. end
  97.  
  98. local function page2()
  99.     printRight("Welcome to DreamOS",5)
  100.     printRight("We are downloading",6)
  101.     printRight("neccessary files,",7)
  102.     printRight("this'll likely be",8)
  103.     printRight("quicker than it takes",9)
  104.     printRight("to read this",10)
  105.     term.setCursorPos(2,4)
  106.     term.setTextColor(colors.gray)
  107.     term.setBackgroundColor(colors.blue)
  108.     print(" Downloading")
  109.     term.setCursorPos(2,5)
  110.     term.setBackgroundColor(colors.green)
  111.     --dl kernel
  112.     dlfile("jJ9nsr24","DreamOS/system/kernel")
  113.     write(" ")
  114.     write(" ")
  115.     --dl ccatch
  116.     dlfile("b5s4VujU","DreamOS/system/ccatch")
  117.     write(" ")
  118.     write(" ")
  119.     --dl core
  120.     dlfile("RLEbDRXn","DreamOS/system/desktop.ds")
  121.     write(" ")
  122.     write(" ")
  123.     --dl cfg
  124.     dlfile("AjVXvFhu","DreamOS/user/root/cfg/main.cfg")
  125.     write(" ")
  126.     write(" ")
  127.     --dl img1
  128.     dlfile("Wx3Vcg8W","DreamOS/system/img/powermenu.nfp")
  129.     dlfile("Bdiu9NQ6","DreamOS/system/pastebin.dsc")
  130.     write(" ")
  131.     write(" ")
  132.     --dl img2
  133.     dlfile("XTqhJbMk","DreamOS/system/img/setmenu.nfp")
  134.     dlfile("yFdEn1N1","DreamOS/system/filemanager.ds")
  135.     write(" ")
  136.     write(" ")
  137.     slc = 3
  138. end
  139.  
  140. local function page3()
  141.     printRight("Finished downloading!",5)
  142.     printRight("Now you can configure",6)
  143.     printRight("the system",7)
  144.     term.setCursorPos(3,6)
  145.     term.setTextColor(colors.white)
  146.     term.setBackgroundColor(colors.green)
  147.     print("    NEXT    ")
  148.     term.setBackgroundColor(colors.red)
  149.     term.setCursorPos(3,11)
  150.     print("   CANCEL   ")
  151. end
  152.  
  153. local function page4()
  154.     printRight("Paint your background",5)
  155.     printRight("or choose an existing",6)
  156.     printRight("file",7)
  157.     term.setCursorPos(3,5)
  158.     term.setBackgroundColor(colors.lightBlue)
  159.     term.setTextColor(colors.white)
  160.     print(" Paint ")
  161.     term.setCursorPos(3,10)
  162.     print(" File  ")
  163.     if selectedDSFile == nil then else
  164.         term.setCursorPos(2,h-1)
  165.         term.setBackgroundColor(colors.blue)
  166.         term.setTextColor(colors.white)
  167.         print(selectedDSFile)
  168.         term.setCursorPos(3,15)
  169.         term.setBackgroundColor(colors.green)
  170.         print(" Next  ")
  171.     end
  172.    
  173. end
  174.  
  175. local function page5()
  176.     while slc == 4.5 do
  177.         sleep(0.1)
  178.         term.setTextColor(colors.white)
  179.         term.setBackgroundColor(colors.yellow)
  180.         term.clear()
  181.         term.setCursorPos(1,1)
  182.         term.setBackgroundColor(colors.lightBlue)
  183.         term.clearLine()
  184.         term.setCursorPos(1,h-1)
  185.         term.setBackgroundColor(colors.lightBlue)
  186.         term.clearLine()
  187.         term.setCursorPos(2,h-1)
  188.         print(selectedDSFile)
  189.         term.setBackgroundColor(colors.green)
  190.         term.setCursorPos(w-6,h-1)
  191.         print("Select")
  192.         term.setCursorPos(1,1)
  193.         term.setBackgroundColor(colors.lightBlue)
  194.         print("Pick file")
  195.         term.setBackgroundColor(colors.yellow)
  196.         local fileList = fs.list("")
  197.         local fileListTable = {}
  198.         local lastDir = 0
  199.         for k,v in pairs(fileList) do
  200.             if fs.isDir(v) then
  201.                 table.insert(fileListTable,v)
  202.                 lastDir = lastDir + 1
  203.             end
  204.         end
  205.         for k,v in pairs(fileList) do
  206.             if not fs.isDir(v) then
  207.                 table.insert(fileListTable,v)
  208.             end
  209.         end
  210.         for k,v in pairs(fileListTable) do
  211.             if k <= h-3 then
  212.                 term.setCursorPos(2,k+1)
  213.                 if k <= lastDir then
  214.                     term.setTextColor(colors.green)
  215.                 else
  216.                     term.setTextColor(colors.white)
  217.                 end
  218.             elseif k >= h-2 then
  219.                 term.setCursorPos(w/2,k-(h-4))
  220.                 if k <= lastDir then
  221.                     term.setTextColor(colors.green)
  222.                 else
  223.                     term.setTextColor(colors.white)
  224.                 end
  225.             end
  226.             print(v)
  227.            
  228.         end
  229.         e = {os.pullEvent()}
  230.         if e[1] == "mouse_click" and e[2] == 1 then
  231.             for k,v in pairs(fileListTable) do
  232.                 if k <= h-2 then
  233.                     if e[3] >= 2 and e[3]<=#v and e[4] == k+1 then
  234.                         term.setCursorPos(1,1)
  235.                         term.setBackgroundColor(colors.lightBlue)
  236.                         term.clearLine()
  237.                         term.setCursorPos(2,h)
  238.                         term.setTextColor(colors.white)
  239.                         term.setBackgroundColor(colors.lightBlue)
  240.                         selectedDSFile = v
  241.                     end
  242.                 elseif k > h-3 then
  243.                     if e[3] >=w/2 and e[4] == k-(h-2)+2 then
  244.                         term.setCursorPos(1,1)
  245.                         term.setBackgroundColor(colors.lightBlue)
  246.                         term.clearLine()
  247.                         term.setCursorPos(2,h)
  248.                         term.setTextColor(colors.white)
  249.                         term.setBackgroundColor(colors.lightBlue)
  250.                         selectedDSFile = v
  251.                     end
  252.                 end
  253.             end
  254.             if e[3] >= w-6 and e[4] == (h-1) then
  255.                 slc = 4
  256.             end
  257.         end
  258.     end
  259. end
  260.  
  261. local function page6()
  262.     printRight("Set up the admin",5)
  263.     printRight("account. This account",6)
  264.     printRight("will have acces to all",7)
  265.     printRight("files and info stored",8)
  266.     printRight("on this computer.",9)
  267.     term.setCursorPos(2,5)
  268.     term.setTextColor(colors.white)
  269.     print("User: ")
  270.     term.setCursorPos(2,6)
  271.     print(adminSetup)
  272.     term.setCursorPos(2,8)
  273.     print("Password: ")
  274.     term.setCursorPos(2,11)
  275.     print("Confirm: ")
  276.     term.setCursorPos(2,15)
  277.     term.setBackgroundColor(colors.green)
  278.     print(" SUBMIT ")
  279.     if confpassnomatch then
  280.         term.setBackgroundColor(colors.blue)
  281.         term.setCursorPos(2,16)
  282.         term.setTextColor(colors.red)
  283.         print("Confirm pass \n and pass\n don't match.")
  284.         term.setTextColor(colors.white)
  285.     end
  286.     if missingpass then
  287.         term.setCursorPos(2,16)
  288.         term.setBackgroundColor(colors.blue)
  289.         term.setTextColor(colors.red)
  290.         print("Must include \n  a password.")
  291.         term.setTextColor(colors.white)
  292.     end
  293. end
  294.  
  295. local function page7()
  296.     printRight("Here you can add",5)
  297.     printRight("additional users",6)
  298.     term.setCursorPos(2,5)
  299.     term.setBackgroundColor(colors.lightBlue)
  300.     term.setTextColor(colors.white)
  301.     print("+Add user")
  302.     term.setCursorPos(2,12)
  303.     term.setBackgroundColor(colors.green)
  304.     term.setTextColor(colors.white)
  305.     print(" NEXT ")
  306.     term.setCursorPos(1,15)
  307.     for k,v in pairs(curUsers) do
  308.         term.setBackgroundColor(colors.gray)
  309.         term.setTextColor(colors.white)
  310.         write(" "..v.name..",")
  311.     end
  312.    
  313. end
  314.  
  315. local function page_add_user()
  316.     printRight("Set up account",5)
  317.     term.setCursorPos(2,5)
  318.     term.setTextColor(colors.white)
  319.     term.setBackgroundColor(colors.cyan)
  320.     print("User: ")
  321.     term.setCursorPos(2,6)
  322.     print(newUser)
  323.     term.setCursorPos(2,8)
  324.     print("Password: ")
  325.     local i = 0
  326.     term.setCursorPos(2,9)
  327.     if newPass == nil then else
  328.         while i < #newPass do
  329.             write("*")
  330.             i = i + 1
  331.         end
  332.     end
  333.     term.setCursorPos(2,11)
  334.     print("Confirm: ")
  335.     if newConfPass == nil then else
  336.         i = 0
  337.         term.setCursorPos(2,12)
  338.         while i < #newConfPass do
  339.             write("*")
  340.             i = i + 1
  341.         end
  342.     end
  343.     term.setCursorPos(2,15)
  344.     term.setBackgroundColor(colors.green)
  345.     print(" SUBMIT ")
  346.     if confpassnomatch then
  347.         term.setBackgroundColor(colors.blue)
  348.         term.setCursorPos(2,16)
  349.         term.setTextColor(colors.red)
  350.         print("Confirm pass \n and pass\n don't match.")
  351.         term.setTextColor(colors.white)
  352.     end
  353.     if missingpass then
  354.         term.setCursorPos(2,16)
  355.         term.setBackgroundColor(colors.blue)
  356.         term.setTextColor(colors.red)
  357.         print("Must include \n  a password.")
  358.         term.setTextColor(colors.white)
  359.     end
  360. end
  361.  
  362. local function exitInstaller()
  363.     term.setBackgroundColor(colors.black)
  364.     term.setTextColor(colors.magenta)
  365.     term.setCursorPos(1,1)
  366.     term.clear()
  367.     print("Exiting installer...")
  368.     print("Delete files?")
  369.     print("[Y/N]")
  370.     local delExit = true
  371.     while delExit do
  372.         local delInputExit = io.read()
  373.         if delInputExit == "Y" or delInputExit == "y" then
  374.             print("Deleting files...")
  375.             shell.run("delete","DreamOS")
  376.             delExit = false
  377.         elseif delInputExit == "N" or delInputExit == "n" then
  378.             print("Keeping files.")
  379.             delExit = false
  380.         end
  381.     end
  382.     brunning = false
  383. end
  384.  
  385. local function page8()
  386.     printRight("Setup complete!",5)
  387.     printRight("Note that DreamOS",6)
  388.     printRight("is in development,",7)
  389.     printRight("not all features may",8)
  390.     printRight("be implemented yet",9)
  391.     term.setCursorPos(2,5)
  392.     term.setBackgroundColor(colors.green)
  393.     term.setTextColor(colors.white)
  394.     print(" Finish ")
  395. end
  396.  
  397. local function finishInstall()
  398.     term.setBackgroundColor(colors.black)
  399.     term.clear()
  400.     term.setTextColor(colors.magenta)
  401.     term.setCursorPos(1,1)
  402.     print("DreamOS Installation complete!")
  403.     print("Run DreamOS on startup?")
  404.     print("[Y/N]")
  405.     local runInputFin = true
  406.     while runInputFin do
  407.         local runInput = io.read()
  408.         if runInput == "y" or runInput == "Y" then
  409.             local runStart = fs.open("startup","w")
  410.             runStart.write("term.clear\(\)\nshell.run\(\"DreamOS/system/desktop.ds\"\)")
  411.             runStart.close()
  412.             runInputFin = false
  413.         elseif runInput == "n" or runInput == "N" then
  414.             runInputFin = false
  415.         end
  416.     end
  417.     print("Thank you for installing DreamOS. You may run it through \"DreamOS/system/desktop.ds\"")
  418.     brunning = false
  419.     shell.run("delete",bground)
  420. end
  421.  
  422. while brunning do
  423.     sleep(0.1)
  424.     drawBground()
  425.     if slc == 1 then
  426.         page1()
  427.         e = {os.pullEvent()}
  428.         if e[1] == "mouse_click" and e[2] == 1 then
  429.             if e[3]>=3 and e[3]<=14 and e[4]==5 then
  430.                 slc = 2
  431.             elseif e[3]>2 and e[3]<=15 and e[4]==10 then
  432.                 exitInstaller()
  433.             end
  434.         end
  435.     elseif slc == 2 then
  436.         page2()
  437.     elseif slc == 3 then
  438.         page3()
  439.         e = {os.pullEvent()}
  440.         if e[1] == "mouse_click" and e[2] == 1 then
  441.             if e[3]>=3 and e[3]<=12 and e[4]==6 then
  442.                 slc = 6
  443.             elseif e[3]>=3 and e[3]<=15 and e[4]==11 then
  444.                 exitInstaller()
  445.             end
  446.         end
  447.     elseif slc == 4 then
  448.         page4()
  449.         e = {os.pullEvent()}
  450.         if e[1] == "mouse_click" and e[2] == 1 then
  451.             if e[3]>=3 and e[3]<=10 and e[4]==5 then
  452.                 shell.run("paint","DreamOS/Documents/Images/desktop.nfp")
  453.                 if fs.exists("DreamOS/Documents/Images/desktop.nfp") then
  454.                     selectedDSFile = "DreamOS/Documents/Images/desktop.nfp"
  455.                     slc = 5
  456.                 end
  457.             elseif e[3]>=3 and e[3]<=10 and e[4]==10 then
  458.                 slc = 4.5
  459.             elseif e[3]>3 and e[3]<=10 and e[4] == 15 then
  460.                 if not selectedDSFile == "DreamOS/Documents/Images/desktop.nfp" then
  461.                     shell.run("copy",selectedDSFile,"DreamOS/Documents/Images/desktop.nfp")
  462.                     selectedDSFile = "DreamOS/Documents/Images/desktop.nfp"
  463.                 end
  464.                 slc = 5
  465.             end
  466.            
  467.         end
  468.     elseif slc == 4.5 then
  469.         page5()
  470.        
  471.     elseif slc == 5 then
  472.         page7()
  473.         e = {os.pullEvent()}
  474.         if e[1] == "mouse_click" and e[2] == 1 then
  475.             if e[3]>=2 and e[3]<=11 and e[4] == 5 then
  476.                 missingpass = false
  477.                 confpassnomatch = false
  478.                 newUser = nil
  479.                 newPass = nil
  480.                 newConfPass = nil
  481.                 slc = 5.5
  482.             elseif e[3]>=2 and e[3]<=9 and e[4] == 12 then
  483.                 slc = 7
  484.             end
  485.         end
  486.     elseif slc == 5.5 then
  487.         page_add_user()
  488.         e = {os.pullEvent()}
  489.         if e[1] == "mouse_click" and e[2] == 1 then
  490.             if e[3]>=2 and e[3]<=11 and e[4]==9 then
  491.                 term.setCursorPos(2,9)
  492.                 term.setBackgroundColor(colors.blue)
  493.                 local i = 0
  494.                 if newPass == nil then else
  495.                     while i <= #newPass do
  496.                         write(" ")
  497.                         i = i + 1
  498.                     end
  499.                 end
  500.                 term.setBackgroundColor(colors.blue)
  501.                 term.setCursorPos(2,9)
  502.                 newPass = read("*")
  503.             elseif e[3]>=2 and e[3]<=10 and e[4]==12 then
  504.                 term.setCursorPos(1,12)
  505.                 term.setBackgroundColor(colors.blue)
  506.                 local i = 0
  507.                 if newConfPass == nil then else
  508.                     while i <= #newConfPass do
  509.                         write(" ")
  510.                         i = i + 1
  511.                     end
  512.                 end
  513.                 term.setBackgroundColor(colors.blue)
  514.                 term.setCursorPos(2,12)
  515.                 newConfPass = read("*")
  516.             elseif e[3]>=2 and e[3]<=10 and e[4] == 6 then
  517.                 term.setCursorPos(1,6)
  518.                 term.setBackgroundColor(colors.blue)
  519.                 local i = 0
  520.                 if newUser == nil then else
  521.                     while i <= #newUser do
  522.                         write(" ")
  523.                         i = i + 1
  524.                     end
  525.                 end
  526.                 term.setBackgroundColor(colors.blue)
  527.                 term.setCursorPos(2,6)
  528.                 newUser = read()
  529.             elseif e[3]>=2 and e[3]<=10 and e[4] == 15 then
  530.                 if newUser == nil then
  531.                     confpassnomatch = false
  532.                     missingpass = true
  533.                 else
  534.                     if newConfPass == newPass then
  535.                         local newUserInfo = {}
  536.                         newUserInfo["name"] = newUser
  537.                         newUserInfo["pass"] = newPass
  538.                         newUserInfo["confpass"] = newConfPass
  539.                         table.insert(curUsers, newUserInfo)
  540.                         slc = 5
  541.                     else
  542.                         missingpass = false
  543.                         confpassnomatch = true
  544.                     end
  545.                 end
  546.             elseif e[3]>=2 and e[4]<=8 and e[4] == 12 then
  547.                 slc = 7
  548.             end
  549.         end
  550.     elseif slc == 6 then
  551.         page6()
  552.         e = {os.pullEvent()}
  553.         if e[1] == "mouse_click" and e[2] == 1 then
  554.             if e[3]>=2 and e[3]<=11 and e[4]==9 then
  555.                 term.setBackgroundColor(colors.blue)
  556.                 term.setCursorPos(2,9)
  557.                 passInput = read("*")
  558.             elseif e[3]>=2 and e[3]<=10 and e[4]==12 then
  559.                 term.setBackgroundColor(colors.blue)
  560.                 term.setCursorPos(2,12)
  561.                 confpassInput = read("*")
  562.             elseif e[3]>=2 and e[3]<=10 and e[4] == 15 then
  563.                 if passInput == nil then
  564.                     confpassnomatch = false
  565.                     missingpass = true
  566.                 else
  567.                     if confpassInput == passInput then
  568.                         slc = 4
  569.                     else
  570.                         missingpass = false
  571.                         confpassnomatch = true
  572.                     end
  573.                 end
  574.             end
  575.         end
  576.     elseif slc == 7 then
  577.         page8()
  578.         e = {os.pullEvent()}
  579.         if e[1] == "mouse_click" and e[2] == 1 then
  580.             if e[3]>=2 and e[3]<=10 and e[4] == 5 then
  581.                 finishInstall()
  582.             end
  583.         end
  584.     end
  585. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×