Advertisement
RespawnTime

TimeOS Installer

Nov 20th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.11 KB | None | 0 0
  1.     local w, h = term.getSize()
  2.      
  3.     local fwrite = function(path, text)
  4.             local file = assert(io.open(path, "w"))
  5.             file:write(text)
  6.             file:close()
  7.     end
  8.      
  9.     local folders = {
  10.     "System";
  11.     "Programs";
  12.     "APIs";
  13.     "Documents";
  14.     "System/Images";
  15.     "System/Images/Icons";
  16.     ".firstTime";
  17.     "Documents/Pictures";
  18.     "Documents/Downloads";
  19.     "Documents/Pictures/Wallpapers";
  20.     "Documents/Projects";
  21.     }
  22.      
  23.     local files = {
  24.     "APIs/fLib";
  25.     "desktop";
  26.     "conf";
  27.     "startup";
  28.     "/Programs/LuaIDE";
  29.     "/System/crash";
  30.     "FileBrowser";
  31.     "task";
  32.     ".first";
  33.     "/System/kernel";
  34.     "version";
  35.     "desktop.cfg";
  36.     "settings.cfg";
  37.     }
  38.      
  39.     local URLs = {
  40.     "http://pastebin.com/raw.php?i=kLRPGier";
  41.     "http://pastebin.com/raw.php?i=Xt6XC1J6";
  42.     "http://pastebin.com/raw.php?i=hrbrU8LD";
  43.     "http://pastebin.com/raw.php?i=ht1xnfV7";
  44.     "http://pastebin.com/raw.php?i=kGQZ95se";
  45.     "http://pastebin.com/raw.php?i=8WqUjs6m";
  46.     "http://pastebin.com/raw.php?i=9MR8HHBR";
  47.     "http://pastebin.com/raw.php?i=vJbDHVMu";
  48.     "http://pastebin.com/raw.php?i=mL9aB25F";
  49.     "http://pastebin.com/raw.php?i=WgrW0t5v";
  50.     "http://pastebin.com/raw.php?i=PzTHYtEX";
  51.     "http://pastebin.com/raw.php?i=rjqBiQrN";
  52.     "http://pastebin.com/raw.php?i=tZBEW7fY";
  53.     }
  54.      
  55.     local draw = function()
  56.     term.setBackgroundColour(colors.white)
  57.     term.clear()
  58.     term.setTextColour(colors.blue)
  59.     term.setCursorPos(math.floor(w-#"Installing TimeOS")/2,math.floor(h)/2-2)
  60.     write("Installing TimeOS")
  61.     term.setCursorPos(math.floor(w-#"Please wait...")/2,math.floor(h)/2)
  62.     write("Please wait...")
  63.     end
  64.      
  65.     draw()
  66.      
  67.     for i,v in pairs(folders) do
  68.     if fs.exists(v) then
  69.     fs.delete(v)
  70.     end
  71.     end
  72.      
  73.     for i,v in pairs(files) do
  74.     if fs.exists(v) then
  75.     fs.delete(v)
  76.     end
  77.     end
  78.      
  79.      
  80.     for i,v in pairs(folders) do
  81.     if not fs.exists(v) then
  82.             fs.makeDir(v)
  83.     end
  84.     end
  85.      
  86.     for i,v in pairs(files) do
  87.     download = http.get(URLs[i])
  88.     fwrite(v, download.readAll())
  89.     end
  90.  
  91. os.loadAPI ("APIs/fLib")
  92.   term.setBackgroundColor (colors.white)
  93.   term.setTextColor (colors.blue)
  94.   term.clear()
  95.   term.setBackgroundColor (colors.gray)
  96.   term.setCursorPos (1,1)
  97.   term.clearLine()
  98.   term.setBackgroundColor (colors.white)
  99.   term.setCursorPos (1,2)
  100.   print ("Enter an Username:")
  101.   term.setCursorPos (1,3)
  102.   input = read()
  103.   fLib.replaceLine ("/conf", 1, input)
  104.   term.setCursorPos (1,5)
  105.   print ("Enter a password:")
  106.   term.setCursorPos (1,6)
  107.   passinput = read("*")
  108.   fLib.replaceLine ("/conf", 2, passinput)
  109. sleep (2)
  110. term.clear()
  111.  
  112.      
  113.     term.setBackgroundColour(colors.white)
  114.     term.clear()
  115.     term.setTextColour(colors.blue)
  116.     term.setCursorPos(math.floor(w-#"Installation complete!")/2,math.floor(h)/2-2)
  117.     write("Installation complete!")
  118.     term.setCursorPos(math.floor(w-#"Rebooting in 1 second...")/2,math.floor(h)/2)
  119.     write("Rebooting in 1 second...")
  120.     sleep (1)
  121.     os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement