Advertisement
Guest User

cev

a guest
Nov 27th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1.  
  2. local time = os.time()
  3. term.clear()
  4. term.setCursorPos( 1, 1 )
  5. term.setTextColor( colors.yellow )
  6. if not fs.exists( "/.enterprise/" ) then
  7.   print ("Initializing first-time setup...")
  8.   fs.makeDir( "/.enterprise/" )
  9.   t = fs.open("/.enterprise/machinelog","w")
  10.   t.writeLine( "" )
  11.   t.close()
  12.   y = fs.open("/.enterprise/blockedapps","a")
  13.   print ("Please enter the names of the programs you would like to block (or type '&' to quit)")
  14.   function getnames()
  15.     write ("Name: ")
  16.     names = read()
  17.     if names == "&" then
  18.       print ("Setup complete!")
  19.       y.close()
  20.       print ("OS will reboot in 3 seconds...")
  21.       sleep( 3 )
  22.       os.reboot()
  23.     else
  24.       y.writeLine( names )
  25.       getnames()
  26.     end
  27.   end
  28.   getnames()    
  29. end
  30.  
  31. local formattedTime = textutils.formatTime(time, false)
  32. print (os.version().." Enterprise Edition")
  33. y = fs.open( ".enterprise/blockedapps", "r" )
  34. fileData = {} -- Declare a table to use to hold data.
  35. line = y.readLine() -- This function reads the next line in the file, until the end.
  36. repeat
  37. table.insert(fileData,line) -- Puts the value of the current line into the table we have.
  38. line = y.readLine() -- read the next line
  39. until line == nil -- readLine() returns nil when the end of the file is reached.
  40. y.close()
  41. function cli()
  42.   term.setTextColor( colors.yellow )
  43.   write ("> ")
  44.   term.setTextColor( colors.white )
  45.   command = read()
  46.   if fileData[command] then
  47.     h = fs.open( ".enterprise/machinelog", "a" )
  48.     h.writeLine("["..formattedTime.."] User attempted to run '"..command.."', attempt blocked!")
  49.     printError ("This program has been blocked by your local administrator!")
  50.     h.close()
  51.     cli()
  52.   else
  53.     shell.run( command )
  54.     cli()
  55.   end
  56. end
  57. cli()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement