LolzPB

test52

May 25th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. drive = "disk"
  2. os.loadAPI(drive.."/lib/libfs")
  3. os.loadAPI(drive.."/lib/text/textlib")
  4. os.loadAPI(drive.."/lib/libshell")
  5.  
  6. fs.makeDir("/etc")
  7. file = fs.open("/etc/fstab", "w")
  8. file.write("{[\"root\"]={\"/\", \"/bin\"},}")
  9. file.close()
  10. os.loadAPI("/disk/lib/libuser")
  11.  
  12. libuser.setUser("root")
  13. function draw()
  14. term.setBackgroundColor(colors.blue)
  15. term.clear()
  16. h, w = term.getSize()
  17. term.setCursorPos(8, 5)
  18. term.setBackgroundColor(colors.black)
  19. for i=9, 44 do
  20. term.setCursorPos(i, 17)
  21. term.write(" ")
  22. end
  23. term.setBackgroundColor(colors.lightGray)
  24. for b=4, 16 do
  25. for i=8, 43 do
  26. term.setCursorPos(i, b)
  27. term.write(" ")
  28. end
  29. end
  30. term.setBackgroundColor(colors.black)
  31. for i=5, 17 do
  32. term.setCursorPos(44, i)
  33. term.write(" ")
  34. end
  35. end
  36.  
  37.  
  38. function drawwind()
  39. draw()
  40. term.setCursorPos(9, 5)
  41. term.setTextColor(colors.black)
  42. term.setBackgroundColor(colors.lightGray)
  43. end
  44.  
  45.  
  46. for i, k in pairs(fs.list("/disk")) do
  47. if not fs.exists("/"..k) then
  48. fs.copy("/disk/"..k, "/"..k)
  49. else
  50. fs.delete("/"..k)
  51. fs.copy("/disk/"..k, "/"..k)
  52. end
  53. end
  54. fs.delete("/startup")
  55. fs.move("/startlinux", "/startup")
  56.  
  57. usn = ""
  58. function userwind()
  59. drawwind()
  60. term.write("Inserire il nome utente")
  61. term.setCursorPos(9, 7)
  62. term.setBackgroundColor(colors.lightGray)
  63. term.setTextColor(colors.black)
  64. usn = ""
  65. while true do
  66. term.setCursorPos(9, 7)
  67. term.setBackgroundColor(colors.red)
  68. term.setTextColor(colors.white)
  69. for i=9, 40 do
  70. term.setCursorPos(i, 7)
  71. term.write(" ")
  72. end
  73. term.setCursorPos(9, 7)
  74. term.write(usn)
  75. term.setBackgroundColor(colors.black)
  76. term.setCursorBlink(true)
  77. _, c = os.pullEvent()
  78. if _ == "char" and #usn < 31 then
  79. usn = usn..c
  80. elseif _ == "key" then
  81. if c == keys.backspace then
  82. usn = string.sub(usn, 1, #usn-1)
  83. elseif c == keys.enter and usn ~= "" then
  84. break
  85. end
  86. end
  87. end
  88. end
  89.  
  90. userwind()
  91.  
  92. libshell.run("/bin/useradd "..usn)
  93.  
  94. pswd = ""
  95.  
  96. function passwdwin()
  97. drawwind()
  98. term.write("Inserire la password")
  99. term.setCursorPos(9, 7)
  100. term.setBackgroundColor(colors.lightGray)
  101. term.setTextColor(colors.black)
  102. pswd = ""
  103. while true do
  104. term.setCursorPos(9, 7)
  105. term.setBackgroundColor(colors.red)
  106. term.setTextColor(colors.white)
  107. for i=9, 40 do
  108. term.setCursorPos(i, 7)
  109. term.write(" ")
  110. end
  111. term.setCursorPos(9, 7)
  112. for i=1, #pswd do
  113. term.write("*")
  114. end
  115. term.setBackgroundColor(colors.black)
  116. term.setCursorBlink(true)
  117. _, c = os.pullEvent()
  118. if _ == "char" and #usn < 31 then
  119. pswd = pswd..c
  120. elseif _ == "key" then
  121. if c == keys.backspace then
  122. pswd = string.sub(pswd, 1, #pswd-1)
  123. elseif c == keys.enter and pswd ~= "" then
  124. break
  125. end
  126. end
  127. end
  128. end
  129.  
  130. passwdwin()
  131.  
  132. file = fs.open("/etc/users/"..usn..".conf", "r")
  133. tabus = textutils.unserialize(file.readAll())
  134. file.close()
  135. tabus["password"] = pswd
  136. file1 = fs.open("/etc/users/"..usn..".conf", "w")
  137. file1.write(textutils.serialize(tabus))
  138. file1.close()
  139.  
  140.  
  141. host = ""
  142. function hostwind()
  143. drawwind()
  144. term.write("Inserire il nome della macchina")
  145. term.setCursorPos(9, 7)
  146. term.setBackgroundColor(colors.lightGray)
  147. term.setTextColor(colors.black)
  148. host = ""
  149. while true do
  150. term.setCursorPos(9, 7)
  151. term.setBackgroundColor(colors.red)
  152. term.setTextColor(colors.white)
  153. for i=9, 40 do
  154. term.setCursorPos(i, 7)
  155. term.write(" ")
  156. end
  157. term.setCursorPos(9, 7)
  158. term.write(host)
  159. term.setBackgroundColor(colors.black)
  160. term.setCursorBlink(true)
  161. _, c = os.pullEvent()
  162. if _ == "char" and #usn < 31 then
  163. host = host..c
  164. elseif _ == "key" then
  165. if c == keys.backspace then
  166. host = string.sub(host, 1, #host-1)
  167. elseif c == keys.enter and host ~= "" then
  168. break
  169. end
  170. end
  171. end
  172. end
  173.  
  174. hostwind()
  175.  
  176.  
  177.  
  178. rpswd = ""
  179.  
  180. function rpasswin()
  181. drawwind()
  182. term.write("Inserire la password per l'utente root")
  183. term.setCursorPos(9, 7)
  184. term.setBackgroundColor(colors.lightGray)
  185. term.setTextColor(colors.black)
  186. rpswd = ""
  187. while true do
  188. term.setCursorPos(9, 7)
  189. term.setBackgroundColor(colors.red)
  190. term.setTextColor(colors.white)
  191. for i=9, 40 do
  192. term.setCursorPos(i, 7)
  193. term.write(" ")
  194. end
  195. term.setCursorPos(9, 7)
  196. for i=1, #rpswd do
  197. term.write("*")
  198. end
  199. term.setBackgroundColor(colors.black)
  200. term.setCursorBlink(true)
  201. _, c = os.pullEvent()
  202. if _ == "char" and #usn < 31 then
  203. rpswd = rpswd..c
  204. elseif _ == "key" then
  205. if c == keys.backspace then
  206. rpswd = string.sub(rpswd, 1, #rpswd-1)
  207. elseif c == keys.enter and rpswd ~= "" then
  208. break
  209. end
  210. end
  211. end
  212. end
  213.  
  214. rpasswin()
Add Comment
Please, Sign In to add comment