Advertisement
Thod

DreamOS Installer

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