Advertisement
erik0004

[ComputerCraft] OS '16 Alpha 1.0 Installer

Jun 28th, 2016
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.69 KB | None | 0 0
  1. local w,h = term.getSize()
  2.  
  3. function fwrite(path, text)
  4.     local file = assert(io.open(path, "w"))
  5.     file:write(text)
  6.     file:close()
  7. end
  8.  
  9. local files = {
  10.     "startup",
  11.     "startupAlternative",
  12.     ".ccYouTube/apis/box",
  13.     ".ccYouTube/apis/extStrLib",
  14.     ".ccYouTube/apis/loadingScreen",
  15.     ".ccYouTube/logos/ccytLogo",
  16.     ".ccYouTube/logos/home",
  17.     ".opt/GUI/config._conf",
  18.     ".opt/GUI/icoDName._conf",
  19.     ".opt/GUI/icoLoc._conf",
  20.     ".opt/GUI/icoName._conf",
  21.     ".opt/GUI/icoRun._conf",
  22.     ".opt/logon/.uacc",
  23.     ".opt/start/bios",
  24.     ".opt/start/bootloader",
  25.     ".sys/API/kernal",
  26.     ".sys/Backgrounds/advcomp.bg",
  27.     ".sys/Backgrounds/normcomp.bg",
  28.     ".sys/GUI/desktop",
  29.     ".sys/GUI/startmenu._GUI",
  30.     ".sys/GUI/startmenuAlternative._GUI",
  31.     ".sys/Programs/ccYT.16",
  32.     ".sys/Programs/fMan.16",
  33.     ".sys/Programs/mouse.cfg",
  34.     ".sys/Programs/npp.16",
  35.     ".sys/icons/OS16.ico",
  36.     ".sys/icons/icon1.nfp",
  37.     ".sys/icons/icon2.nfp",
  38.     ".sys/icons/icon3.nfp",
  39.     ".sys/logon/usr_login",
  40.     ".var/OSver/ver.16"
  41. }
  42.  
  43. local folders = {
  44.     ".ccYouTube",
  45.     ".ccYouTube/apis/",
  46.     ".ccYouTube/downloads/",
  47.     ".ccYouTube/logos/",
  48.     ".ccYouTube/recycleBin/",
  49.     ".opt",
  50.     ".opt/GUI/",
  51.     ".opt/logon/",
  52.     ".opt/start/",
  53.     ".sys/API/",
  54.     ".sys/Backgrounds/",
  55.     ".sys/GUI/",
  56.     ".sys/Programs/",
  57.     ".sys/icons/",
  58.     ".sys/logon/",
  59.     ".var",
  60.     ".var/OSver/"
  61. }
  62.  
  63. local urls = {
  64.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/startup",
  65.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/startupAlternative",
  66.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.ccYouTube/apis/box",
  67.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.ccYouTube/apis/extStrLib",
  68.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.ccYouTube/apis/loadingScreen",
  69.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.ccYouTube/logos/ccytLogo",
  70.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.ccYouTube/logos/home",
  71.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/GUI/config._conf",
  72.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/GUI/icoDName._conf",
  73.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/GUI/icoLoc._conf",
  74.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/GUI/icoName._conf",
  75.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/GUI/icoRun._conf",
  76.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/logon/.uacc",
  77.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/start/bios",
  78.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.opt/start/bootloader",
  79.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/API/kernal",
  80.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/Backgrounds/advcomp.bg",
  81.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/Backgrounds/normcomp.bg",
  82.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/GUI/desktop",
  83.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/GUI/startmenu._GUI",
  84.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/GUI/startmenuAlternative._GUI",
  85.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/Programs/ccYT.16",
  86.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/Programs/fMan.16",
  87.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/Programs/mouse.cfg",
  88.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/Programs/npp.16",
  89.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/icons/OS16.ico",
  90.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/icons/icon1.nfp",
  91.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/icons/icon2.nfp",
  92.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/icons/icon3.nfp",
  93.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.sys/logon/usr_login",
  94.     "http://erik0004.890m.com/cc/OS16/Alpha1.0/.var/OSver/ver.16"
  95. }
  96.  
  97. local function startInstaller()
  98.     if not http then
  99.     term.setBackgroundColor(colors.black)
  100.     term.clear()
  101.     term.setTextColor(colors.red)
  102.     term.setCursorPos(1,1)
  103.     print("You need the http API to run this installer.")
  104.     end
  105.     if not term.isColor() or term.isColour() or term.isColor or term.isColour then
  106.     term.setBackgroundColor(colors.black)
  107.     term.clear()
  108.     term.setTextColor(colors.red)
  109.     term.setCursorPos(1,1)
  110.     print("You need an Advanced Computer to use this OS.")
  111.     end
  112.     for i,v in pairs(folders) do
  113.     if fs.exists(v) then
  114.     term.setBackgroundColor(colors.black)
  115.     term.clear()
  116.     term.setTextColor(1)
  117.     term.setCursorPos(math.floor(w-#"Found an older version of OS'16,")/2,9)
  118.     print("Found an older version of OS'16,")
  119.     term.setCursorPos(math.floor(w-#"deleting it...")/2,10)
  120.     print("deleting it...")
  121.     sleep(1)
  122.     fs.delete(v)
  123.     end
  124.     end
  125.     for i,v in pairs(files) do
  126.     if fs.exists(v) then
  127.     term.setBackgroundColor(colors.black)
  128.     term.clear()
  129.     term.setTextColor(1)
  130.     term.setCursorPos(math.floor(w-#"Found an older version of OS'16,")/2,9)
  131.     print("Found an older version of OS'16,")
  132.     term.setCursorPos(math.floor(w-#"deleting it...")/2,10)
  133.     print("deleting it...")
  134.     sleep(1)
  135.     fs.delete(v)
  136.     end
  137.     end
  138. end
  139.  
  140. local function install()
  141.     startInstaller()
  142.     term.setBackgroundColor(2048)
  143.     term.clear()
  144.     term.setTextColor(1)
  145.     term.setCursorPos(math.floor(w-#"OS'16 Installer")/2,1)
  146.     print("OS'16 Installer")
  147.     term.setCursorPos(1,2)
  148.     print(string.rep("-",51))
  149.     term.setCursorPos(math.floor(w-#"Installing OS'16...")/2,9)
  150.     print("Installing OS'16...")
  151.     term.setCursorPos(math.floor(w-#"Making the OS Folders...")/2,10)
  152.     print("Making the OS Folders...")
  153.     for i,v in pairs(folders) do
  154.     fs.makeDir(v)
  155.     end
  156.     sleep(1)
  157.     term.setCursorPos(math.floor(w-#"Fetching files from the download website...")/2,10)
  158.     print("Fetching files from the download website...")
  159.     for i,v in pairs(files) do
  160.     dl = http.get(urls[i])
  161.     fwrite(v, dl.readAll())
  162.     sleep(3)
  163.     end
  164.     term.setCursorPos(1,10)
  165.     term.setBackgroundColor(2048)
  166.     term.clearLine()
  167.     term.setCursorPos(math.floor(w-#"OS'16 is succesfully installed. Rebooting..")/2,9)
  168.     print("OS'16 is succesfully installed. Rebooting..")
  169.     if fs.exists("/install") then
  170.     fs.delete("/install")
  171.     sleep(2)
  172.     os.reboot()
  173.     else
  174.     sleep(2)
  175.     os.reboot()
  176.     end
  177. end
  178. install()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement