Advertisement
superkh

my os installer :)

Dec 26th, 2015 (edited)
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.08 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. --setup functons
  3. function cls()
  4.   term.clear()
  5. end
  6. function pos(x,y)
  7.  term.setCursorPos(x,y)
  8. end
  9. function bc(c)
  10.   term.setBackgroundColor(c)
  11. end
  12. function tc(c)
  13.   term.setTextColor(c)
  14. end
  15. --pastebin stuff
  16. local function get(paste)
  17.     local response = http.get(
  18.         "http://pastebin.com/raw/"..textutils.urlEncode( paste )
  19.     )
  20.     if response then
  21.         local sResponcse = response.readAll()
  22.         response.close()
  23.         return sResponcse
  24.     else
  25.         error(paste)
  26.     end
  27. end
  28. local function pastebin(sCode,path)
  29.     local sFile = path
  30.     local sPath = sFile
  31.     if fs.exists( sPath ) then
  32.         error("file exists")
  33.     end
  34.     --gets the contents from pastebin
  35.     local res = get(sCode)
  36.     if res then
  37.         local file = fs.open( sPath, "w" )
  38.         file.write( res )
  39.         file.close()
  40.     end
  41. end
  42. --error checking function
  43. function Error(err)
  44.     local size = { term.getSize() }
  45.     tc(colors.white)
  46.     bc(colors.blue)
  47.     cls()
  48.     pos(1,1)
  49.     write("+")
  50.     write(string.rep("=",size[1]-2))
  51.     write("+")
  52.     pos(1,size[2])
  53.     write("+")
  54.     write(string.rep("=",size[1]-2))
  55.     write("+")
  56.     function g(x)
  57.     local y = 2
  58.     while y<size[2] do
  59.       pos(x,y)
  60.       write("|")
  61.       y = y+1
  62.     end
  63.     end
  64.     g(1)
  65.     g(size[1])
  66.     local function cT(t,l)
  67.         local w,h = term.getSize()
  68.         pos(math.floor(w/2-t:len()/2 +.5),l)
  69.         write(t)
  70.     end
  71.     cT("Error!",3)
  72.     pos(2,4)
  73.     write(string.rep("-",size[1]-2))
  74.     cT(err,6)
  75.     sleep(2)
  76.     pos(2,size[2]-1)
  77. end
  78. --Updates files
  79. local function setup()
  80. --deleteing prior os
  81.     print("Setting up files")
  82.     if fs.exists("os") then
  83.         fs.delete("os")
  84.     end
  85. --make directorys
  86.     print("Installing directorys")
  87.     fs.makeDir("os")
  88.     fs.makeDir("os/APIS")
  89.     fs.makeDir("os/files")
  90.     fs.makeDir("os/files/UserData")
  91.     fs.makeDir("os/images")
  92.     fs.makeDir("os/images/icons")
  93.     fs.makeDir("os/programs")
  94.     fs.makeDir("os/users")
  95.     fs.makeDir("os/users/Admin")
  96. --get files
  97.     print("Installing Main files")
  98.     pastebin("RNNJq9ng","os/boot")
  99.     pastebin("nudDqAKx","os/os")
  100.     pastebin("TnfNSPja","os/login")
  101. --Main APIS
  102.     print("Installing APIS")
  103.     pastebin("vSQEBHjZ","os/APIS/A")
  104.     pastebin("BqUbtktC","os/APIS/update")
  105.     pastebin("H44JHjDF","os/APIS/fig")
  106.     pastebin("fh7vKWu5","os/APIS/buf")
  107.     pastebin("BhqTBiNE","os/APIS/manage")
  108.     pastebin("cQ4qpT1k","os/APIS/PastebinGet")
  109.     pastebin("nmvJHyBB","os/APIS/peripherals")
  110. --Config files
  111.     print("Installing Config files")
  112.     pastebin("pNKEE5hz","os/files/config")
  113.     pastebin("DYF22zCN","os/files/colorsC")
  114.     pastebin("xDRFMw5k","os/files/UserData/Uconfig")
  115. --Admin files
  116.     print("Installing Admin files")
  117.     pastebin("2akSg4Yz","os/users/Admin/Uconfig")
  118. --Main Images
  119.     print("Installing Images")
  120.     pastebin("TBpgmKAN","os/images/boot")
  121.     pastebin("is5w4ehg","os/images/input")
  122.     pastebin("V1h8nasT","os/images/update")
  123.     pastebin("WecmC3HF","os/images/config")
  124.     pastebin("2swxhSDt","os/images/setup")
  125.     pastebin("6yx5M49j","os/images/AsciiArt")
  126.     pastebin("FQEQDx7U","os/images/default")
  127.     pastebin("gu3WEEX1","os/images/icons/blank")
  128.     pastebin("yw3wtZSk","os/images/icons/icon1")
  129. --added images
  130.     print("Installing Icons")
  131.     pastebin("MtaqZ9fa","os/images/icons/fileM")
  132.     pastebin("M4Sb4JBm","os/images/icons/test")
  133. --added programs
  134.     print("Installing added Programs")
  135.     pastebin("C3KUFWWC","os/programs/ice")
  136.     pastebin("BCTAxDsP","os/programs/test") --Remove in First Uconfig
  137. --Create startup file
  138.     print("Installing startup and Configrations")
  139.     local file = fs.open( "startup", "w" )
  140.     file.writeLine("term.clear()")
  141.     file.writeLine("os.loadAPI('os/APIS/peripherals')")
  142.     file.writeLine("os.loadAPI('os/APIS/buf')")
  143.     file.writeLine("os.loadAPI('os/APIS/A')")
  144.     file.writeLine("shell.run('os/boot')")
  145.     file.close()
  146.     print("Install Done")
  147.     sleep(2)
  148. --Set up file
  149.     pastebin("CBd0hMBR","os/files/setup")  
  150. end
  151. function dm()
  152.         bc(colors.black)
  153.         tc(colors.white)
  154.         cls()
  155.         local function cT(t,l)
  156.             local w,h = term.getSize()
  157.             pos((math.floor(w/2-t:len()/2 +.5)),l)
  158.             write(t)
  159.         end
  160.         cT("Updating OS",1)
  161.         print(string.rep("=",51))
  162. end
  163. function main()
  164.     dm()
  165.     setup()
  166. end
  167. local ok, err = pcall(main)
  168. if not ok then
  169.     Error(err)
  170. else
  171.     shell.run("os/files/setup")
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement