Advertisement
MarcoPolo0306

M-OS Installer (1.2)

Apr 24th, 2017
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.21 KB | None | 0 0
  1. --This is my OS called M-OS.
  2. --It is pretty simple. But, it is fast, and easy to use!
  3. --I hope you enjoy my OS!
  4.  
  5. fs.delete("boot")
  6. fs.delete("setup")
  7.  
  8. function installingData(file)
  9.     term.setCursorPos(1,19)
  10.     term.clearLine()
  11.     print("Installing: " .. file)
  12. end
  13.  
  14. local function get(repoFile,saveTo)
  15. local download = http.get("https://raw.githubusercontent.com/MarcoPolo0306/M-OS/master/"..repoFile)
  16. installingData(saveTo)
  17. if download then
  18.    local handle = download.readAll()
  19.    download.close()
  20.    local file = fs.open(saveTo,"w")
  21.    file.write(handle)
  22.    file.close()
  23.   else
  24.    print("Unable to download the file "..repoFile)
  25.    print("Make sure you have the HTTP API enabled or")
  26.    print("an internet connection!")
  27.   end
  28. end
  29.  
  30. w,h = term.getSize()
  31. slc = 0
  32.  
  33. function menu()
  34.     term.setCursorPos(1,1)
  35.     paintutils.drawFilledBox(1,1,w, h, colors.white)
  36.     paintutils.drawLine(1,1,w, 1, colors.lightBlue)
  37.     term.setCursorPos(1,1)
  38.     term.setTextColor(colors.white)
  39.     term.setBackgroundColor(colors.lightBlue)
  40.     print(" M-OS Setup")
  41. end
  42.  
  43. function welcomeScreen()
  44.     slc = 1
  45.     term.setTextColor(colors.gray)
  46.     term.setBackgroundColor(colors.white)
  47.     term.setCursorPos(8,3)
  48.     print("Welcome to the M-OS installer.")
  49.     term.setCursorPos(8,4)
  50.     print('Click the "Next" button to continue.')
  51.     term.setCursorPos(36,14)
  52.     term.setBackgroundColor(colors.gray)
  53.     term.setTextColor(colors.lightGray)
  54.     print(" Next ")
  55. end
  56.  
  57. function copy()
  58.     slc = 0
  59.     term.setBackgroundColor(colors.black)
  60.     term.clear()
  61.     menu()
  62.     term.setTextColor(colors.gray)
  63.     term.setBackgroundColor(colors.white)
  64.     term.setCursorPos(8,3)
  65.     print("Backing up old files...")
  66. end
  67.  
  68. function installingData(msg)
  69.     term.setCursorPos(1,18)
  70.     term.setBackgroundColor(colors.white)
  71.     term.clearLine()
  72.     term.setTextColor(colors.lightGray)
  73.     print("Installing: " .. msg)
  74. end
  75.  
  76. function setPos()
  77.     term.setCursorPos(1,-100)
  78. end
  79.  
  80. function install()
  81.     slc = 2
  82.     term.setBackgroundColor(colors.black)
  83.     term.clear()
  84.     menu()
  85.     term.setTextColor(colors.gray)
  86.     term.setBackgroundColor(colors.white)
  87.     term.setCursorPos(8,3)
  88.     print("M-OS is installing...")
  89.     setPos()
  90.     get("startup","startup")
  91.     get("m-os/boot","m-os/boot")
  92.     get("m-os/desktop","m-os/desktop")
  93.     get("m-os/logon","m-os/logon")
  94.     get("m-os/monitior_detected","m-os/monitior_detected")
  95.     get("m-os/restore","m-os/restore")
  96.     get("m-os/settings","m-os/settings")
  97.     get("m-os/shutdown","m-os/shutdown")
  98.     get("m-os/config/bgPath","m-os/config/bgPath")
  99.     get("m-os/config/pass","m-os/config/pass")
  100.     get("m-os/config/showBiosOnStartup","m-os/config/showBiosOnStartup")
  101.     get("m-os/config/updateOnStartup","m-os/config/updateOnStartup")
  102.     get("m-os/config/theme","m-os/config/theme")
  103.     get("m-os/images/logo","m-os/images/logo")
  104.     get("m-os/images/backgrounds/cc","m-os/images/backgrounds/cc")
  105.     get("m-os/images/backgrounds/default","m-os/images/backgrounds/default")
  106.     get("m-os/images/backgrounds/mc","m-os/images/backgrounds/mc")
  107.     get("m-os/images/icons/file","m-os/images/icons/file")
  108.     get("m-os/images/icons/shell","m-os/images/icons/shell")
  109.     get("m-os/images/icons/unknown","m-os/images/icons/unknown")
  110.     get("m-os/images/icons/paint","m-os/images/icons/paint")
  111.     get("m-os/images/icons/nPaint","m-os/images/icons/nPaint")
  112.     get("m-os/images/UserPiciture","m-os/images/UserPiciture")
  113.     get("m-os/images/default-preview","m-os/images/default-preview")
  114.     get("m-os/images/mc-preview","m-os/images/mc-preview")
  115.     get("m-os/programs/appstore","m-os/programs/appstore")
  116.     get("m-os/programs/file_browser","m-os/programs/file_browser")
  117.     get("m-os/programs/installed_programs","m-os/programs/installed_programs")
  118.     get("m-os/programs/mshell","m-os/programs/mshell") 
  119.     get("m-os/programs/news","m-os/programs/news")
  120.     get("m-os/programs/programs","m-os/programs/programs")
  121.     get("setup2","setup2")
  122.     get("boot","boot")
  123.     finish()
  124. end
  125.  
  126. function finish()
  127.     slc = 3
  128.     term.setBackgroundColor(colors.black)
  129.     term.clear()
  130.     menu()
  131.     term.setTextColor(colors.gray)
  132.     term.setBackgroundColor(colors.white)
  133.     term.setCursorPos(8,3)
  134.     print("Thank you for intalling M-OS.")
  135.     term.setCursorPos(8,4)
  136.     print("Click Reboot to continue the setup.")
  137.     term.setCursorPos(36,14)
  138.     term.setBackgroundColor(colors.gray)
  139.     term.setTextColor(colors.lightGray)
  140.     print(" Reboot ")
  141. end
  142.  
  143. term.setBackgroundColor(colors.black)
  144. term.clear()
  145.  
  146. menu()
  147. welcomeScreen()
  148.  
  149. while true do
  150.     local event, button, X, Y = os.pullEvent()
  151.     if event == "mouse_click" then
  152.         if X>=36 and X<=41 and Y==14 and button ==1 and slc == 1 then
  153.             if fs.exists("m-os") then
  154.                 copy()
  155.                 if fs.exists(".m-os_BACKUP") then
  156.                     fs.delete(".m-os_BACKUP")
  157.                 end
  158.                 shell.run("cp","m-os",".m-os_BACKUP")
  159.                 fs.delete("m-os")
  160.                 sleep(1)
  161.                 install()
  162.             else
  163.                 install()
  164.             end
  165.         elseif X>=36 and X<=44 and Y==14 and slc == 3 then
  166.             fs.delete("install")
  167.             shell.run("boot")
  168.         end
  169.     end
  170.     if src == 2 then
  171.         input = read()
  172.     end
  173. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement