Advertisement
rickydaan

LinuxOS 1.0.0 PRE 1

Feb 16th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. -- DONT EDIT THIS OR UPDATE / CHECKUPDATE IS RUINED
  2. version = "1.0.0"
  3. -- From here its safe ;)
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. print("Do you want to install Linux OS? ")
  7. ia = read()
  8. if ia == "yes" then
  9.  
  10. -- Making database
  11. shell.run("mkdir", "db")
  12. shell.run("mkdir", "db/users")
  13. shell.run("mkdir", "db/users/level")
  14. shell.run("mkdir", "db/users/pass")
  15. shell.run("mkdir", "db/users/blocked")
  16. shell.run("mkdir", "db/sys")
  17.  
  18. -- Asking admin data
  19. print("Admin username? ")
  20. ian = read()
  21. print("Admin password?")
  22. iap = read()
  23.  
  24. -- Registering admin data
  25. file = io.open("db/users/pass/"..ian, "w")
  26. file : write(iap)
  27. file : close()
  28.  
  29. file = io.open("db/users/level/".. ian, "w")
  30. file : write('6')
  31. file : close()
  32.  
  33. -- File installation
  34. file = io.open("startup", "w")
  35. file : write([[
  36. sleep(.1)
  37. term.clear()
  38. term.setCursorPos(1,1)
  39. print("---[ Linux OS - Main menu ]--------------------")
  40. print("I")
  41. print("I [1] login")
  42. print("I [2] Register")
  43. print("I")
  44. print("-----------------------------------------------")
  45. stop = false
  46. while not stop do
  47. event, char = os.pullEvent()
  48. if event == "key" and char == 2 then
  49. shell.run("login")
  50. stop = true
  51. elseif event == "key" and char == 3 then
  52. shell.run("register")
  53. stop = true
  54. end
  55. end
  56. ]])
  57. file : close()
  58.  
  59. file = io.open("login", "w")
  60. file : write([[
  61. function error()
  62. event = os.pullEvent()
  63. if event == "char" or event == "key" then
  64. shell.run("login")
  65. end
  66. end
  67. sleep(.1)
  68. term.clear()
  69. term.setCursorPos(1,1)
  70. print("---[ Linux OS - Login ]------------------------")
  71. print("I Enter at username: back, to go back")
  72. print("I Username:")
  73. print("I Password:")
  74. print("I Error:")
  75. print("I At a error press any key to continue")
  76. print("-----------------------------------------------")
  77.  
  78. term.setCursorPos(13,3)
  79. lname = read()
  80. if lname == "back" then
  81. shell.run("startup")
  82. end
  83.  
  84. term.setCursorPos(13,4)
  85. lpass = read()
  86.  
  87.  
  88. if fs.exists("db/users/pass/"..lname) then
  89. if fs.exists("db/users/blocked/"..lname) then
  90. term.setCursorPos(10,5)
  91. print("This user is blocked")
  92. error()
  93. else
  94. file = io.open("db/users/pass/"..lname, "r")
  95. gpass = file : read()
  96. file : close()
  97. if gpass == lpass then
  98. shell.run("loggedin")
  99. else
  100. term.setCursorPos(10,5)
  101. print("Password incorrect")
  102. error()
  103. end
  104. end
  105. else
  106. term.setCursorPos(10,5)
  107. print("Unknown username")
  108. error()
  109. end
  110.  
  111. ]])
  112. file : close()
  113.  
  114. file = io.open("register")
  115. file : write([[
  116. function acc()
  117. event = os.pullEvent()
  118. if event == "char" or event == "key" then
  119. shell.run("startup")
  120. end
  121. end
  122. function error()
  123. event = os.pullEvent()
  124. if event == "char" or event == "key" then
  125. shell.run("register")
  126. end
  127. end
  128. sleep(.1)
  129. term.clear()
  130. term.setCursorPos(1,1)
  131. print("---[ Linux OS - register ]---------------------")
  132. print("I Type back at the username to go back")
  133. print("I Username:")
  134. print("I Password:")
  135. print("I Error:")
  136. print("I At a error press any key to continue")
  137. print("-----------------------------------------------")
  138. term.setCursorPos(13,3)
  139. rname = read()
  140. if rname == "back" then
  141. shell.run("startup")
  142. end
  143.  
  144. term.setCursorPos(13,4)
  145. rpass = read()
  146.  
  147. if fs.exists("db/users/pass/"..rname) then
  148. term.setCursorPos(10,5)
  149. print("Username exists")
  150. error()
  151. else
  152. if fs.exists("db/users/blocked/"..rname) then
  153. term.setCursorPos(10,5)
  154. print("This user is blocked")
  155. error()
  156. else
  157. file = io.open("db/users/pass/"..rname, "w")
  158. file : write(rpass)
  159. file : close()
  160.  
  161. file = io.open("db/users/level/"..rname, "w")
  162. file : write('1')
  163. file : close()
  164. term.setCursorPos(3,5)
  165. print("Account created: Press any key to continue")
  166. acc()
  167. end
  168. end
  169.  
  170.  
  171.  
  172.  
  173. ]])
  174. file : close()
  175. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement