Advertisement
MaximumFrank

install

Mar 25th, 2016
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. --installer
  2. rootPath = "/"
  3. prgPath = rootPath .. "program_files/"
  4. osFilesPath = rootPath .. "os_files/"
  5. sysPath = osFilesPath .. "sys/"
  6. usrPath = osFilesPath .. "usr/"
  7. regPath = sysPath .. "reg/"
  8. funcPath = sysPath .. "funcs/"
  9. restPath = sysPath .. "recovery/recovery_files/"
  10.  
  11. --recreate the folder structure
  12. fs.makeDir(osFilesPath)
  13. fs.makeDir(sysPath)
  14. fs.makeDir(funcPath)
  15. fs.makeDir(regPath)
  16. fs.makeDir(usrPath)
  17. fs.makeDir(usrPath .. "Admin")
  18. fs.makeDir(prgPath)
  19. if not fs.exists(prgPath) then
  20. fs.makeDir(prgPath)
  21. end
  22.  
  23. shell.run("pastebin","get", "R1U1Tbu3", restPath .. "Aset")
  24. shell.run("pastebin","get", "1aa8Wui8", restPath .. "calcPlus")
  25. shell.run("pastebin","get", "qByWkj7N", restPath .. "cred")
  26. shell.run("pastebin","get", "DQJi7wSM", restPath .. "func")
  27. shell.run("pastebin","get", "JwgvEBwM", restPath .. "ink")
  28. shell.run("pastebin","get", "ubWUJ3TZ", restPath .. "luaIDE")
  29. shell.run("pastebin","get", "CwRqhj7N", restPath .. "main")
  30. shell.run("pastebin","get", "ZYcCQk52", restPath .. "params")
  31. shell.run("pastebin","get", "PB2yNBmE", restPath .. "periph")
  32. shell.run("pastebin","get", "ZermQtR2", restPath .. "prg")
  33. shell.run("pastebin","get", "ufWg1kQf", restPath .. "startup")
  34. shell.run("pastebin","get", "k2vnjUsg", restPath .. "ui")
  35. shell.run("pastebin","get", "ScTChDUh", restPath .. "usr")
  36. shell.run("pastebin","get", "XtC0JPQw", sysPath .. "/recover/recovery")
  37.  
  38. --recreate the files
  39. fs.copy(restPath .. "cred", funcPath .. "cred")
  40. --fs.copy(restPath .. "debug", funcPath .. "debug")
  41. fs.copy(restPath .. "func", funcPath .. "func")
  42. fs.copy(restPath .. "periph", funcPath .. "periph")
  43. fs.copy(restPath .. "prg", regPath .. "prg")
  44. --fs.copy(restPath .. "settings", regPath .. "settings")
  45. fs.copy(restPath .. "usr", regPath .. "usr")
  46. fs.copy(restPath .. "main", sysPath .. "main")
  47. fs.copy(restPath .. "ui", sysPath .. "ui")
  48. fs.copy(restPath .. "Aset", usrPath .. "Admin/settings")
  49. fs.copy(restPath .. "startup", rootPath .. "startup")
  50. fs.copy(restPath .. "params", rootPath .. "params")
  51. fs.copy(restPath .. "luaIDE", prgPath .. "luaIDE")
  52. fs.copy(restPath .. "calcPlus", prgPath .. "calcPlus")
  53. fs.copy(restPath .. "ink", prgPath .. "ink")
  54.  
  55. function register()
  56. os.loadAPI(funcPath .. "func")
  57. os.loadAPI(rootPath .. "params")
  58.  
  59. _G.w, _G.h = term.getSize()
  60.  
  61. if term.isColor() then
  62. _G.tbCol = params.tbColMain
  63. _G.tbxCol = params.tbxColMain
  64. _G.txCol = params.txColMain
  65. _G.bgCol = params.bgCol
  66. _G.stxCol = params.stxColMain
  67. else
  68. _G.tbCol = params.tbMain
  69. _G.tbxCol = params.tbMain
  70. _G.txCol = params.txMain
  71. _G.bgCol = params.bgCol
  72. _G.stxCol = params.stxMain
  73. end
  74.  
  75. term.setBackgroundColor(bgCol)
  76.  
  77. func.clear()
  78.  
  79. local file = fs.open(regPath .. "usr", "r")
  80. local data = file.readAll()
  81. file.close()
  82.  
  83. func.drawRect(1, 1, w, 1, tbCol, txCol)
  84. func.drawCenteredX("Enter your username:", 1, tbCol, txCol)
  85.  
  86. local tUname = func.readCentered("> ")
  87.  
  88. if string.find(data, tUname .. " = 1") or string.find(data, tUname .. " = 2") then
  89. func.clear()
  90. func.drawCenteredX("Username already in use!", h / 2, bgCol, tbxCol)
  91. sleep(1.5)
  92. func.clear()
  93. return false
  94. end
  95.  
  96. func.clear()
  97.  
  98. func.drawRect(1, 1, w, 1, tbCol)
  99. func.drawCenteredX("Enter your password:", 1, tbCol, txCol)
  100.  
  101. local tPass = func.readCentered("> ", "*")
  102.  
  103. func.clear()
  104.  
  105. func.drawRect(1, 1, w, 1, tbCol)
  106. func.drawCenteredX("Re-enter your password:", 1, tbCol, txCol)
  107.  
  108. local txPass = func.readCentered("> ", "*")
  109.  
  110. if tPass ~= txPass then
  111. func.clear()
  112. func.drawCenteredX("Passwords did not match!", h / 2, bgCol, tbxCol)
  113. sleep(1.5)
  114. func.clear()
  115. return false
  116. end
  117.  
  118. local AP = true
  119.  
  120. func.clear()
  121.  
  122. local file = fs.open(regPath .. "usr", "a")
  123. if AP == false then
  124. file.writeLine(tUname .. " = 1")
  125. elseif AP == true then
  126. file.writeLine(tUname .. " = 2")
  127. end
  128. file.writeLine(tUname .. "pass = " .. tPass)
  129. file.close()
  130. func.clear()
  131.  
  132. fs.makeDir(usrPath .. tUname)
  133.  
  134. local file = fs.open(usrPath .. tUname .. "/settings", "w")
  135. file.writeLine("bgCol = "..bgCol)
  136. file.writeLine("tbCol = " .. tbCol)
  137. file.writeLine("tbxCol = " .. tbxCol)
  138. file.writeLine("txCol = " .. txCol)
  139. file.writeLine("stxCol = " .. stxCol)
  140. file.writeLine("lockout = 30")
  141. file.close()
  142.  
  143. return false
  144. end
  145.  
  146. doit = true
  147.  
  148. while doit do
  149. doit = register()
  150. end
  151.  
  152. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement