LolzPB

test51

May 25th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 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 passwdwind()
  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. usn = usn..c
  120. elseif _ == "key" then
  121. if c == keys.backspace then
  122. usn = string.sub(usn, 1, #pswd-1)
  123. elseif c == keys.enter and pswd ~= "" then
  124. break
  125. end
  126. end
  127. end
  128. end
Add Comment
Please, Sign In to add comment